This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CodeTimer : IDisposable | |
{ | |
readonly string message; | |
readonly DateTime start; | |
public CodeTimer(string message) | |
{ | |
this.message = message; | |
start = DateTime.UtcNow; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static string Minimize(XDocument document) | |
{ | |
//take out the comments | |
document.DescendantNodes().OfType<XComment>().Remove(); | |
//take out the mc:ignorables | |
XNamespace mc = "http://schemas.openxmlformats.org/markup-compatibility/2006"; | |
var ignorable = document.Root.Attribute(mc + "Ignorable"); | |
if (ignorable != null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NodeList<TKey, TValue> : IEnumerable<KeyValuePair<TKey, TValue>> where TKey : IComparable<TKey> | |
{ | |
readonly Node start = new Node(default(TKey), default(TValue)); | |
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() | |
{ | |
for (Node n = start.GetNext(); n != null; n = n.GetNext()) | |
{ | |
yield return new KeyValuePair<TKey, TValue>(n.key, n.value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
glob:Debug | |
glob:*.user | |
glob:_ReSharper* | |
glob:*.cachefile | |
glob:*.suo | |
glob:~$* | |
glob:*.tmp | |
glob:*/bin/* | |
glob:*/obj/* | |
glob:*.orig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Style x:Key="ShadowBorder" TargetType="ContentControl"> | |
<Setter Property="Foreground" Value="#FF000000"/> | |
<Setter Property="HorizontalContentAlignment" Value="Left"/> | |
<Setter Property="VerticalContentAlignment" Value="Top"/> | |
<Setter Property="Template"> | |
<Setter.Value> | |
<ControlTemplate TargetType="ContentControl"> | |
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> | |
<Grid Margin="2,1,2,-3" RenderTransformOrigin="0.5,0"> | |
<Grid.RenderTransform> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Windows; | |
using System.Windows.Controls; | |
using System.Windows.Media; | |
using Gma.QrCodeNet.Encoding; | |
namespace Gma.QrCodeNet.Wpf | |
{ | |
public class QrCodeElement : Control |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class ApiDocumentor | |
{ | |
[TestMethod] | |
public void PrintApiMethods() | |
{ | |
var methods = from m in typeof(Api).GetMethods() | |
let url = GetUrl(m) | |
where url != null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// C# port of http://raksy.dyndns.org/cycle_collection.py via http://stackoverflow.com/questions/8946563/add-square-to-polygon-composed-of-squares | |
/// </summary> | |
static class SquaresToPolygonGenerator | |
{ | |
static readonly Coordinate[] directions = new[] | |
{ | |
Coordinate.West, | |
Coordinate.South, | |
Coordinate.East, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TileCanvas : Canvas | |
{ | |
public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(TileCanvas), new PropertyMetadata(null, ImageSourceChanged)); | |
private Size lastActualSize; | |
public TileCanvas() | |
{ | |
LayoutUpdated += OnLayoutUpdated; | |
} |