Last active
December 13, 2015 19:19
Revisions
-
jwatte revised this gist
Feb 15, 2013 . 1 changed file with 35 additions and 15 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,36 +1,56 @@ public class DrawingFeature : Feature { public ReactiveProperty<Drawing> Drawing = new ReactiveProperty<Drawing>(this.OnFeatureChanged); } // use: theDrawingFeature.Drawing.It = ...; // theDrawingFeature.Drawing.Change += new EventHandler( ... ); public class ReactiveProperty<T> { public ReactiveProperty(ParentChange del) { parent_ = del; } private ParentChange parent_; private T it_; public event EventHandler Changed; private bool inChanged_; protected void OnChanged() { if (!inChanged_) { inChanged_ = true; try { if (Changed != null) { Changed(this, EventArgs.Empty); } if (parent_) { parent_(); } } finally { inChanged_ = false; } } } public T It { get { return it_; } set { it_ = value; OnChanged(); } } } public delegate void ParentChanged(); -
jwatte created this gist
Feb 15, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ public class DrawingFeature : Feature { private Drawing drawing_; public event EventHandler DrawingChanged; private bool inDrawingChanged_; protected void OnDrawingChanged() { if (!inDrawingChanged_) { inDrawingChanged_ = true; try { if (DrawingChanged != null) { DrawingChanged(this, EventArgs.Empty); } OnFeatureChanged(); } finally { inDrawingChanged_ = false; } } } public Drawing Drawing { get { return drawing_; } set { drawing_ = value; OnDrawingChanged(); } } }