Skip to content

Instantly share code, notes, and snippets.

View ScottIsAFool's full-sized avatar

Scott Lovegrove ScottIsAFool

View GitHub Profile
@ScottIsAFool
ScottIsAFool / BooleanToValueConverter.cs
Last active December 16, 2015 17:18
A base converter that can be used to create converters that require a true/false value.
using System;
using System.Windows.Data;
namespace ScottIsAFool.WindowsPhone.Converters
{
public class BoolToValueConverter<T> : IValueConverter
{
public T FalseValue { get; set; }
public T TrueValue { get; set; }
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
namespace ScottIsAFool.WindowsPhone.Bindings
{
public class ScaledImageSource
{
public static object GetSource(DependencyObject obj)
@ScottIsAFool
ScottIsAFool / TimeZone.cs
Created February 9, 2014 21:04
Holds all the timezones as well as their offsets, for platforms that don't have http://msdn.microsoft.com/en-us/library/system.timezoneinfo.getsystemtimezones(v=vs.110).aspx (like Windows Phone)
using Newtonsoft.Json;
namespace TimeZones
{
public class TimeZone
{
[JsonProperty("Name")]
public string Name { get; set; }
[JsonProperty("Offset")]
@ScottIsAFool
ScottIsAFool / TimeZoneHelper.cs
Last active August 29, 2015 13:56
TimeZoneHelper for Windows Phone
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace ScottIsAFool.WindowsPhone.Helpers
{
public static class TimeZoneHelper
{
private const string TimeZonesJson = "[{\"Name\":\"(UTC-12:00) International Date Line West\",\"Offset\":\"-12:00:00\"},{\"Name\":\"(UTC-11:00) Co-ordinated Universal Time-11\",\"Offset\":\"-11:00:00\"},{\"Name\":\"(UTC-10:00) Hawaii\",\"Offset\":\"-10:00:00\"},{\"Name\":\"(UTC-09:00) Alaska\",\"Offset\":\"-09:00:00\"},{\"Name\":\"(UTC-08:00) Baja California\",\"Offset\":\"-08:00:00\"},{\"Name\":\"(UTC-08:00) Pacific Time (US & Canada)\",\"Offset\":\"-08:00:00\"},{\"Name\":\"(UTC-07:00) Arizona\",\"Offset\":\"-07:00:00\"},{\"Name\":\"(UTC-07:00) Chihuahua, La Paz, Mazatlan\",\"Offset\":\"-07:00:00\"},{\"Name\":\"(UTC-07:00) Mountain Time (US & Canada)\",\"Offset\":\"-07:00:00\"},{\"Name\":\"(UTC-06:00) Central America\",\"Offset\":\"-06:00:00\"},{\"Name\":\"(UTC-06:00) Central Time (US & Canada)\",\"Offset\":\"-06:00:00\"},{\"Name\":\"(UTC-0
@ScottIsAFool
ScottIsAFool / SlideViewFrame.cs
Created March 16, 2014 18:16
Hide appbar when using SlideView
using System;
using System.Windows;
using Microsoft.Phone.Controls;
using System.Windows.Controls;
namespace SlideView.Library
{
[TemplatePart(Name = SlideViewName, Type = typeof(SlideView))]
public class SlideApplicationFrame : TransitionFrame
{
@ScottIsAFool
ScottIsAFool / SystemTrayProgressIndicatorBehaviour.cs
Created April 3, 2014 08:59
A behaviour to allow you to have a custom colour for the system tray's progressindicator
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
using System.Windows.Media;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace ScottIsAFool.WindowsPhone.Behaviours
@ScottIsAFool
ScottIsAFool / AttributeExtensions.cs
Created April 3, 2014 09:29
Get Attribute Extension
public static class AttributeExtensions
{
public static string GetDescription(this object en)
{
var type = en.GetType();
var memInfo = type.GetTypeInfo().DeclaredMembers;
var attrs = memInfo.FirstOrDefault(x => x.Name == en.ToString());
if (attrs != null)
{
@ScottIsAFool
ScottIsAFool / TileService.cs
Created May 19, 2014 20:29
Save UserControl for tile
private async Task ToImage(UIElement element, string filename, double height, double width)
{
element.UpdateLayout();
element.Measure(new Size(width, height));
element.UpdateLayout();
element.Arrange(new Rect { Height = height, Width = width });
var bitmap = new WriteableBitmap((int)width, (int)height);
bitmap.Render(element, null);
bitmap.Invalidate();
@ScottIsAFool
ScottIsAFool / YLAD.xml
Created May 27, 2014 12:44
YLAD custom control
<Item Title="built by"
Type="xaml">
<scott:FerretLabs xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:scott="clr-namespace:ScottIsAFool.WindowsPhone;assembly=ScottIsAFool.WindowsPhone"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"/>
</Item>
@ScottIsAFool
ScottIsAFool / Style.xaml
Created August 18, 2014 14:27
EmptyButtonStyle with Tilt
<Style x:Key="EmptyButtonStyle"
TargetType="ButtonBase">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Padding"
Value="0" />
<Setter Property="HorizontalContentAlignment"
Value="Stretch" />
<Setter Property="HorizontalAlignment"
Value="Stretch" />