Skip to content

Instantly share code, notes, and snippets.

View idiotandrobot's full-sized avatar

Michael Phillips idiotandrobot

View GitHub Profile
@idiotandrobot
idiotandrobot / MoreObservableCollection.cs
Created July 16, 2014 15:29
MoreObservableCollection
public class MoreObservableCollection<T> : ObservableCollection<T>
{
public MoreObservableCollection()
: base()
{
CollectionChanged += new NotifyCollectionChangedEventHandler(ObservableCollection_CollectionChanged);
}
public MoreObservableCollection(IEnumerable<T> collection)
: base(collection)
@idiotandrobot
idiotandrobot / BoolToInvisibilityConverter
Created July 31, 2014 19:26
Bool to Visibility converters
public class BoolToInvisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool isInvisible = (bool)value;
if (BoolToVisibilityConverter.IsVisibilityInverted(parameter))
isInvisible = !isInvisible;
return (isInvisible ? Visibility.Collapsed : Visibility.Visible);
@idiotandrobot
idiotandrobot / StringFormatConverter.cs
Last active August 29, 2015 14:20
Windows Phone 8.1 StringFormatConverter
public sealed class StringFormatConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (value == null)
return null;
if (parameter == null)
return value;
@idiotandrobot
idiotandrobot / "Unsupported".xaml
Last active August 29, 2015 14:20
Windows Phone 8.1 TextBlock StringFormat support
<Style TargetType="controls:Clock">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Clock">
<TextBlock Text="{Binding DateTime,
StringFormat=T,
RelativeSource={RelativeSource TemplatedParent}}" />
</ControlTemplate>
</Setter.Value>
</Setter>
@idiotandrobot
idiotandrobot / Read.md.regex
Created April 27, 2015 08:31
Regex for Read.md
\*{2}(?<Year>\d{4})\*{2}\r?\n\r?\n(?<Read>- \*{2}(?<Day>\d{1,2})-(?<Month>\w{3})\*{2} (?<Title>.*) by (?<Author>.*)\r\n)+
@idiotandrobot
idiotandrobot / FontAwesome.css
Created April 27, 2015 08:46
Haacked FontAwesome support method
@font-face {
font-family: 'FontAwesome';
src: url("/blog/font/fontawesome-webfont.eot");
src: url("/blog/font/fontawesome-webfont.eot?#iefix") format("embedded-opentype"),
url("/blog/font/fontawesome-webfont.woff") format("woff"),
url("/blog/font/fontawesome-webfont.ttf") format("truetype"),
url("/blog/font/fontawesome-webfont.svgz#FontAwesomeRegular") format("svg"),
url("/blog/font/fontawesome-webfont.svg#FontAwesomeRegular") format("svg");
font-weight: normal;
font-style: normal;
@idiotandrobot
idiotandrobot / Embed
Last active August 29, 2015 14:20
Embedding Gists in Jekyll Posts
{% gist 92b3fce859806a435a96 %}
@idiotandrobot
idiotandrobot / PercentageConverter.cs
Created June 24, 2015 07:40
Percentage IValueConverter
public class PercentageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var fraction = decimal.Parse(value.ToString());
return fraction.ToString("P1");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
@idiotandrobot
idiotandrobot / 1 - Original Listbox.xaml
Last active August 29, 2015 14:23
Simple Listbox Ordering using a CollectionViewSource
<ListBox ItemsSource="{Binding List}" />
@idiotandrobot
idiotandrobot / IObservableContainerItem.cs
Created September 22, 2015 09:59
ObservableContainer
public interface IObservableContainerItem<T>
{
T Observed { get; set; }
}