Skip to content

Instantly share code, notes, and snippets.

View mrlacey's full-sized avatar
😇

Matt Lacey mrlacey

😇
View GitHub Profile
@mrlacey
mrlacey / CanPin-before
Last active December 14, 2015 22:48
On low spec WP8 devices we had an issue where the UI option to create a secondary tile wasn't always being enabled properly. After identifying the most likely cause as the `CanPin()` method I had to refactor it to make it debuggable and in doing so made the binding/timing issue go away (solved it).
internal bool CanPin()
{
return !this.IsPinned()
&& this.UnderlyingModel != null
&& !this.IsRunningInKidsCorner()
&& (this.UnderlyingModel.IsSpecial
|| string.IsNullOrWhiteSpace(this.UnderlyingModel.ArtUrl)
|| (!string.IsNullOrWhiteSpace(this.UnderlyingModel.ArtUrl)
&& this.imageCacher.IsCached(this.UnderlyingModel.ArtUrl)));
}
@mrlacey
mrlacey / CanPin-after
Last active December 15, 2015 05:29
On low spec WP8 devices we had an issue where the UI option to create a secondary tile wasn't always being enabled properly. After identifying the most likely cause as the `CanPin()` method I had to refactor it to make it debuggable and in doing so made the binding/timing issue go away (solved it).
internal bool CanPin()
{
if (this.IsPinned())
{
Debug.WriteLine("Cannot pin as already pinned");
return false;
}
if (this.UnderlyingModel == null)
{
@mrlacey
mrlacey / JsonSerializationComparison
Created August 20, 2013 11:24
A comparison of how to serialize and deserialize objects to and from JSON with both Json.Net and ServiceStack.Text
namespace JsonSerialization
{
using System;
class Program
{
static void Main(string[] args)
{
var firstObject = new MyClass { Something = "a value", Anotherthing = "another value" };
@mrlacey
mrlacey / CaretBrushResourceExample
Last active December 28, 2015 16:19
XAML that demonstrates issue with CaretBrush and shared resources
<phone:PhoneApplicationPage
x:Class="CaretBrushTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
SupportedOrientations="Portrait"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
@mrlacey
mrlacey / gist:7779172
Created December 3, 2013 22:58
GlobeKeyReplacement
private static List<AlphaKeyGroup<PhoneContact>> CreateGroups(SortedLocaleGrouping slg)
{
var list = new List<AlphaKeyGroup<PhoneContact>>();
foreach (string key in slg.GroupDisplayNames)
{
var k = key;
if (key == "...")
{
k = "🌐"; // &#x1F310;
@mrlacey
mrlacey / gist:7779351
Created December 3, 2013 23:08
Alphabetic JumpList contact names
<phone:LongListSelector
ItemsSource="{Binding}"
IsGroupingEnabled="True"
HideEmptyGroups="True"
LayoutMode="List"
toolkit:TiltEffect.IsTiltEnabled="True">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
@mrlacey
mrlacey / AlternateRows.cs
Last active January 3, 2016 22:38
CodeBehind for Alternate row highlighting demo
namespace AlternateRows
{
using System;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Windows.Media;
using Microsoft.Phone.Controls;
public partial class MainPage : PhoneApplicationPage
@mrlacey
mrlacey / AlternateRows.xaml
Created January 20, 2014 21:25
XAML for Alternate row highlighting demo
<phone:PhoneApplicationPage
x:Class="AlternateRows.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:alternateRows="clr-namespace:AlternateRows"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait"
// CAREERS AT CONTOSO - TRIAL #2
// TITLE: Punch Card Puzzle
// AUTHOR: Vogel
// DESCRIPTION: Send screenshot of su ccessful output to @contosoishiring
<x:Code><![CDATA[private void mutYUUJ U7(object ksn8879, RoutedEventArgs khJJUh3){
System.Collections.Generic.Dictionary <int, Color>RX99RTOOUKL = new System.Collections.Generic.Diction
ary<int, Color>();
RX99RTOOUKL.Add(0, Color.FromRgb(0, 0 , 0));RX99RTOOUKL.Add(1, Color.FromRgb(255, 255, 255));
RX99RTOOUKL.Add(2, Color.FromRgb(224, 64, 64));RX99RTOOUKL.Add(3, Color.FromRgb(96, 255, 255));
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Text;
using System.Threading.Tasks;
using Windows.Web.Http;
using Windows.Web.Http.Headers;
using Newtonsoft.Json;