Skip to content

Instantly share code, notes, and snippets.

View philcleveland's full-sized avatar

Phil Cleveland philcleveland

View GitHub Profile
public class AreaFallowed
{
public AreaFallowed(string gardenID, NodaTime.LocalDate date, int x, int y, int width, int length)
{
GardenId = gardenID;
Date = date;
X = x;
Y = y;
Width = width;
Length = length;
@philcleveland
philcleveland / App.xaml
Created April 24, 2014 16:04
Answer for SO question
<Application
x:Class="Approve.App"
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:local="clr-namespace:Approve">
<!--Application Resources-->
@philcleveland
philcleveland / DandD.cs
Created December 12, 2013 21:30
Drag and drop with Rx
var mouseDown = Observable.FromEventPattern<MouseButtonEventArgs>(this, "MouseDown")
.Select(x => x.EventArgs.GetPosition(this));
var mouseUp = Observable.FromEventPattern<MouseButtonEventArgs>(this, "MouseUp")
.Select(x => x.EventArgs.GetPosition(this));
var mouseMove = Observable.FromEventPattern<MouseEventArgs>(this, "MouseMove")
.Select(x => x.EventArgs.GetPosition(this));
mouseMove.SkipUntil(mouseDown)
@philcleveland
philcleveland / ABetterKeyPressCapture.cs
Last active January 17, 2020 01:06
Shows how to use Rx to capture keypress events. I use it for fastforward and reverse in the media sense. ABetterKeyPressCapture.cs was written by Chris Harris @cwharris. I appreciate his answer on StackOverflow.
using System;
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows.Forms;
namespace RxStuff
{
class Program
{
@philcleveland
philcleveland / StreamTrackedContentViewModel.cs
Created December 2, 2013 00:43
PlayingWithReactiveUIandTwitter
public class StreamTrackedContentViewModel : ReactiveObject
{
public StreamTrackedContentViewModel(Twitter twitterApi)
{
Tweets = new ReactiveList<Tweet>();
TweetViewModels = Tweets.CreateDerivedCollection(tweet => new TweetTileViewModel(tweet.CreatedAt,
tweet.UserPic,
tweet.UserName,
tweet.ScreenName,
tweet.Text));
@philcleveland
philcleveland / App.cs
Last active December 28, 2015 03:29
RxUI Search example
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
//ghetto bootstrap - IS THIS OK?
var searchView = new SearchView();
searchView.ViewModel = new SearchViewModel();
searchView.DataContext = searchView.ViewModel;
@philcleveland
philcleveland / rx_OAPHprop.snippet
Last active June 28, 2016 23:05
RxUI VS snippets
<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Rx ObservableAsPropertyHelper</Title>
<Shortcut>rxOAPH</Shortcut>
<Description>Code snippet for a ReactiveUI ObservableAsPropertyHelper</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
@philcleveland
philcleveland / SearchViewModel.cs
Created November 5, 2013 19:40
SearchViewModel with ReactiveUI
using ReactiveUI;
using System.Threading.Tasks;
using System.Windows.Input;
using TwitterFeedAPI;
namespace FeedManagement.WPF.Search
{
public class SearchViewModel : ReactiveObject, ISearchViewModel
{
public IScreen HostScreen { get; protected set; }
@philcleveland
philcleveland / gist:7159081
Created October 25, 2013 18:01
Trying to pass variable from TFS to WiX
I have a Variable defined in my TFS Build template
Name:TFSGenProductVersion
Type:String
Scope:Sequence
Default:"3.1.2"
I added this to the wixproj
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>Debug;MyProductVersion=0.0.0.1</DefineConstants>
@philcleveland
philcleveland / GetEventStoreEventDispatcher.cs
Last active December 16, 2015 05:19
GetEventStore Event Dispatcher EventStore.ClientAPI compatable v1.1.0
//Special thanks to Andrii Nakryiko and James Nugent
//for their help with this code.
namespace Infrastructure.EventStorage
{
using System;
using System.Collections.Concurrent;
using System.Net;
using System.Text;
using System.Threading;
using EventStore.ClientAPI;