Skip to content

Instantly share code, notes, and snippets.

namespace DataGridDummy
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
Names= new ObservableCollection<string>(new List<string>(){"Johan"});
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
Names= new ObservableCollection<Person>(new List<Person>(){new Person(){Name = "Johan"}});
this.DataContext = Names;
InitializeComponent();
public class A : IXmlSerializable
{
public XmlSchema GetSchema()
{
throw new NotImplementedException();
}
public void ReadXml(XmlReader reader)
{
throw new NotImplementedException();
<UserControl x:Class="Whitepad.Views.ColorButtons"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ViewModels="clr-namespace:Whitepad.ViewModels"
mc:Ignorable="d" d:DataContext="{d:DesignInstance IsDesignTimeCreatable=true, Type={x:Type ViewModels:ColorButtonsViewModel}}" d:DesignHeight="32" d:DesignWidth="128">
<UserControl.Resources>
<Style x:Key="MyFocusVisual">
<Setter Property="Control.Template">
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
this.scanDir=1;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.fire();
robot.ahead(1);
public class DummyVm : INotifyPropertyChanged
{
public DummyVm()
{
this.Items= new ObservableCollection<DummyItem>(new List<DummyItem>
{
new DummyItem(){Name = "Maverick", Country = "England"},
new DummyItem(){Name = "Johan", Country = "SwedenLand"},
new DummyItem(){Name = "Gregory", Country = "England"},
new DummyItem(){Name = "Jackomel", Country = "Unknown"}
public class DummyViewModel : INotifyPropertyChanged
{
public DummyViewModel()
{
Values= new ObservableCollection<Reading>();
_timer = new Timer((o) =>
{
this.TextFromSerialPort = DateTime.Now.ToString();
App.Current.Dispatcher.Invoke(()=>this.Values.Add(new Reading(DateTime.Now,"FakeValue " + DateTime.Now.ToString())));
}, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(0.1));
[Test]
public void RegexTest()
{
var pattern = @"^(CONNECT|DELETE|HEAD|GET|OPTIONS|POST|PUT|TRACE) (\/[\S]*) HTTP\/(1.0|1.1)$";
var line = "test";
var stopWatch = Stopwatch.StartNew();
for (int i = 0; i < 2; i++)
{
stopWatch.Restart();
@JohanLarsson
JohanLarsson / KeyState
Created May 29, 2013 17:25
PInvoke to get system wide key state
public static class KeyState
{
public static bool IsKeyDown(VirtualKeyStates key)
{
return GetKeyState(VirtualKeyStates.VK_LBUTTON) < 0;
}
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern short GetKeyState(VirtualKeyStates nVirtKey);
}
namespace Enum.Extensions {
/// http://stackoverflow.com/a/1086742/1069200
public static class EnumerationExtensions {
public static bool Has<T>(this System.Enum type, T value) {
try {
return (((int)(object)type & (int)(object)value) == (int)(object)value);
}
catch {
return false;