Skip to content

Instantly share code, notes, and snippets.

View programmation's full-sized avatar

David Dancy programmation

View GitHub Profile
@programmation
programmation / delayed_text_entry
Created June 21, 2015 23:20
How to delay response to user text entry until after user finishes typing
// http://forums.xamarin.com/discussion/comment/133731/#Comment_133731
public partial class Page1
{
public Page1()
{
this.InitializeComponent();
this.Entry.TextChanged += this.EntryOnTextChanged;
}
//
@programmation
programmation / threadsafe_imagesource
Created June 22, 2015 00:33
How to make sure only one ImageSource load is in flight at a time
// https://bugzilla.xamarin.com/show_bug.cgi?id=21981#c5
using Xamarin.Forms;
[assembly: ExportImageSourceHandler(typeof(UriImageSource), typeof(iOS.Renderers.ImageLoaderSourceHandler))]
namespace iOS.Renderers
{
using System.Collections.Generic;
using System.Threading;
@programmation
programmation / task_dependency_manager
Created June 22, 2015 02:20
Task dependency manager from Stephen Toub MSDN article. Similar to NSOperationQueue / NSOperation on MacOS / iOS.
// https://msdn.microsoft.com/en-us/magazine/dd569760.aspx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OperationQueueTest
@programmation
programmation / Dsp.cs
Last active August 29, 2015 14:25 — forked from praeclarum/Dsp.cs
using System;
using System.Runtime.InteropServices;
namespace Circuit
{
public static class Dsp
{
class FftSetupD : IDisposable
{
public IntPtr Handle;
@programmation
programmation / ByteArrayToImageSource.cs
Created July 27, 2015 02:53
Convert byte array to ImageSource
// http://forums.xamarin.com/discussion/comment/89964/#Comment_89964
namespace Core.Converters
{
public class ByteArrayToImageSource : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null || value is DBNull)
return null;
@programmation
programmation / ResultPage.cs
Created July 28, 2015 01:21
Xamarin Forms page returning a result
// http://forums.xamarin.com/discussion/comment/129611/#Comment_129611
public interface IPageWithResult<out T>
{
T PageResult { get; }
}
public static class PageExtensions
{
public static Task<TResult> ShowModalAsync<TPage, TResult>(this TPage page)
@programmation
programmation / gist:a83ce6fae103029493a6
Created July 28, 2015 01:30
Xamarin Forms Search bar
<SearchBar x:Name="search" Placeholder="Search"
SearchCommandParameter="{Binding Text, Source={x:Reference search}}" />
@programmation
programmation / SkinnableApp.txt
Last active October 20, 2015 04:30
Foundations of a skinnable app
// SkinnableApp/App.xaml
<?xml version="1.0" encoding="UTF-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SkinnableApp.App">
<Application.Resources>
<ResourceDictionary>
</ResourceDictionary>
</Application.Resources>
</Application>
@programmation
programmation / RoundRectLabel.cs
Created July 28, 2015 02:02
Xamarin Forms Label control with rounded rects. Invisible for configurable value.
// RoundRectLabel.cs
using System;
using Xamarin.Forms;
namespace App
{
public class RoundRectLabel : Label
{
public static readonly BindableProperty BorderColorProperty =
@programmation
programmation / ConcreteTypeConverter.cs
Created July 28, 2015 02:15
Json type converter used as attribute on convertible class
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Xamarin.Forms;
namespace App
{
public class ConcreteTypeConverter<T>
: JsonConverter