Skip to content

Instantly share code, notes, and snippets.

@dkudelko
dkudelko / XamarinFormsBindableProperty.cs
Created December 21, 2015 15:41
BindableProperty XamarinForms
public static readonly BindableProperty FoobarProperty=BindableProperty.Create<YourClass, bool>( p => p.Foobar, false );
public bool Foobar
{
get
{
return (bool)GetValue(FoobarProperty);
}
set
{
@dkudelko
dkudelko / CircleImageAndroid.cs
Created December 7, 2015 12:50 — forked from jamesmontemagno/CircleImageAndroid.cs
Circle Image from Xamarin Evolve
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
@dkudelko
dkudelko / FileCache.cs
Created December 3, 2015 13:54
xamarin FileCache
using System;
using System.Threading.Tasks;
using System.Security.Cryptography;
using System.Text;
using System.IO;
using System.Net;
using System.Collections.Generic;
namespace XamarinStore
{
@dkudelko
dkudelko / UserInFrozenRole.cs
Created November 30, 2015 12:29
CRM Plugin sample code get/check user in specific role
private static bool UserInFrozenRole(IPluginExecutionContext context, IOrganizationService organizationService, IEnumerable<string> settingRoles)
{
var jjQuery = new QueryExpression()
{
EntityName = "role",
ColumnSet = new ColumnSet("name"),
LinkEntities =
{
new LinkEntity
{
@dkudelko
dkudelko / BaseUrl_Android.cs
Created November 24, 2015 13:15
XamarinForms.BaseUrl
using System;
using Xamarin.Forms;
using App.Android;
[assembly: Dependency (typeof (BaseUrl_Android))]
namespace App.Android
{
public class BaseUrl_Android : IBaseUrl
{
public string Get ()
@dkudelko
dkudelko / ConsoleAppMainAsync.cs
Created October 6, 2015 10:56
async console applicatiion main
class Program
{
static void Main(string[] args)
{
CancellationTokenSource cts = new CancellationTokenSource();
Console.CancelKeyPress += (s, e) =>
{
e.Cancel = true;
cts.Cancel();
};
@dkudelko
dkudelko / ToObservableCollection.cs
Created September 23, 2015 09:12
ToObservableCollection<T>
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> enumerable)
{
var col = new ObservableCollection<T>();
foreach (var cur in enumerable)
{
col.Add(cur);
}
return col;
}
@dkudelko
dkudelko / Shared.Helpers.Extension.cs
Last active August 29, 2015 14:21
ToNSString() extension xamarin ios
#if __IOS__
public static Foundation.NSString ToNSString (this object source)
{
if (source == null) { //todo логирование
throw new ArgumentNullException ("ToNSString source is null");
}
return new Foundation.NSString (source.ToString ());
}
#endif
@dkudelko
dkudelko / scale.cs
Last active August 29, 2015 14:17 — forked from nicwise/scale.cs
public static UIImage ScaleImage(UIImage image, int maxSize)
{
UIImage res;
using (CGImage imageRef = image.CGImage)
{
CGImageAlphaInfo alphaInfo = imageRef.AlphaInfo;
CGColorSpace colorSpaceInfo = CGColorSpace.CreateDeviceRGB();
if (alphaInfo == CGImageAlphaInfo.None)