Skip to content

Instantly share code, notes, and snippets.

View programmation's full-sized avatar

David Dancy programmation

View GitHub Profile
@programmation
programmation / CustomLabelRenderer.cs
Created September 1, 2015 13:18
Vertical centring UILabel subclass implementing Xamarin.Forms LabelRenderer
using System;
using System.ComponentModel;
using CoreGraphics;
using CustomRendererTest.Controls;
using CustomRendererTest.iOS.Renderers;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer (typeof(CustomLabel), typeof(CustomLabelRenderer))]
@programmation
programmation / CustomApplication.cs
Created August 27, 2015 06:00
Android Application subclass with AltBeacon support
using System;
using AltBeaconOrg.BoundBeacon;
using AltBeaconOrg.BoundBeacon.Powersave;
using AltBeaconOrg.BoundBeacon.Startup;
using Android.App;
using Android.Runtime;
namespace CustomApp.Droid
{
[Application]
// http://forums.xamarin.com/discussion/comment/144204/#Comment_144204
// Projects is an ObservableCollection
<ListView x:Name="projectListView"
ItemsSource="{Binding Projects}"
SelectedItem="{Binding SelectedProject, Mode=TwoWay}">
<ListView.ItemTemplate>
<DataTemplate>
<TextCell x:Name="textCell"
Text="{Binding Name}"
@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
@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 / 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 / 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 / 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 / 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 / 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;