Last active
November 30, 2018 23:02
-
-
Save Grabacr07/8911896 to your computer and use it in GitHub Desktop.
@hivesbee 誕生日おめでとう
This file contains hidden or 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 partial class MainWindow : Window | |
| { | |
| /// <summary> | |
| /// D&D の軌跡のコレクションのコレクション。 | |
| /// </summary> | |
| private readonly List<List<Point>> points = new List<List<Point>>(); | |
| public MainWindow() | |
| { | |
| InitializeComponent(); | |
| Observable.FromEventPattern<MouseEventHandler, MouseEventArgs>( | |
| h => this.MouseMove += h, | |
| h => this.MouseMove -= h) | |
| .SkipUntil(Observable | |
| .FromEventPattern<MouseButtonEventHandler, MouseButtonEventArgs>( | |
| h => this.MouseDown += h, | |
| h => this.MouseDown -= h) | |
| .Do(_ => this.CaptureMouse())) | |
| .TakeUntil(Observable | |
| .FromEventPattern<MouseButtonEventHandler, MouseButtonEventArgs>( | |
| h => this.MouseUp += h, | |
| h => this.MouseUp -= h) | |
| .Do(_ => this.ReleaseMouseCapture())) | |
| .Select(x => x.EventArgs.GetPosition(null)) | |
| .Do(x => this.TextBlock.Text = string.Format("X: {0}, Y:{1}", x.X, x.Y)) | |
| .Aggregate(new List<Point>(), (l, x) => { l.Add(x); return l; }) | |
| .Finally(() => this.TextBlock.Text = "Completed") | |
| .Repeat() | |
| .Subscribe(x => this.points.Add(x)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment