Skip to content

Instantly share code, notes, and snippets.

Avatar

Bruno Van Thournout BrunoVT1992

View GitHub Profile
@BrunoVT1992
BrunoVT1992 / DpiToPixelConverter.cs
Last active May 13, 2016
Converter to convert dpi sizes to pixel sizes in Xamarin Android
View DpiToPixelConverter.cs
using Android.App;
using Android.Content;
namespace Droid
{
public static class DpiToPixelConverter
{
public static int Convert(int dpi)
{
float scale = Application.Context.Resources.DisplayMetrics.Density;
@BrunoVT1992
BrunoVT1992 / BytesConverter.cs
Last active May 13, 2016
Converter to convert number of bytes to kB, MB, GB, TB or PB in C#
View BytesConverter.cs
using System;
namespace CSharp
{
public static class BytesConverter
{
public static double ConvertBytesToKB(long bytes)
{
return bytes / 1024f;
}
@BrunoVT1992
BrunoVT1992 / StringConverter.cs
Created May 13, 2016
Converter to capitalize the first character of a string in C#
View StringConverter.cs
namespace CSharp
{
public static class StringConverter
{
public static string Capitalized(string text)
{
if (string.IsNullOrEmpty(text))
{
return text;
}
@BrunoVT1992
BrunoVT1992 / UIImageConverter.cs
Last active May 13, 2016
Converter to blur an UIImage in Xamarin iOS
View UIImageConverter.cs
using UIKit;
using CoreImage;
namespace iOS
{
public static class UIImageConverter
{
public static UIImage Blur(UIImage image)
{
var ciImage = new CIImage(image);
@BrunoVT1992
BrunoVT1992 / ThreadUtil.cs
Created Jun 23, 2016
Extension to see if a thread is the main(UI) thread for Xamarin Android.
View ThreadUtil.cs
using Android.OS;
using Java.Lang;
namespace Droid
{
public static class ThreadUtil
{
public static bool IsMainThread(this Thread currentThread)
{
return currentThread == Looper.MainLooper.Thread;
@BrunoVT1992
BrunoVT1992 / UIImageExtensions.cs
Created Jul 20, 2017
UIImage extension to get a pixel color for Xamarin iOS
View UIImageExtensions.cs
using System.Drawing;
using System.Runtime.InteropServices;
using CoreGraphics;
using UIKit;
namespace iOS
{
public static class UIImageExtensions
{
public static string GetPixelHexColor(this UIImage image, float x, float y)
@BrunoVT1992
BrunoVT1992 / FreeDrawUIView.cs
Created Jul 27, 2017
Free draw view for Xamarin iOS
View FreeDrawUIView.cs
using CoreGraphics;
using Foundation;
using UIKit;
namespace iOS
{
public class FreeDrawUIView : UIView
{
UIBezierPath _path;
@BrunoVT1992
BrunoVT1992 / FreeDrawView.cs
Created Jul 27, 2017
Free draw view for Xamarin Android
View FreeDrawView.cs
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Views;
namespace Droid
{
public class FreeDrawView : View
{
Path _drawPath;
@BrunoVT1992
BrunoVT1992 / StackView.cs
Created Sep 18, 2017
StackView for Xamarin.iOS without the need for AutoLayout constraints
View StackView.cs
using System;
using System.Linq;
using CoreGraphics;
using UIKit;
namespace iOS
{
public class StackView : UIView
{
nfloat _previousWidth;
@BrunoVT1992
BrunoVT1992 / ScaleImageView.cs
Last active Jun 23, 2018
Scaleable / zoomable imageview for Xamarin Android
View ScaleImageView.cs
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Views;
using Android.Widget;
namespace Droid
You can’t perform that action at this time.