Permalink
Browse files

Add a unique identifier to TimeValue, and propagate the TimeValue in …

…TimeValueAdded
  • Loading branch information...
1 parent 1ff1593 commit 1c2338e379c671ae1cad3e064108645367e5c2fe @jschementi committed Jul 26, 2011
Showing with 6 additions and 4 deletions.
  1. +6 −4 Schementi.Controls.Sparkline/Sparkline.xaml.cs
@@ -29,14 +29,15 @@
namespace Schementi.Controls {
public class TimeValue {
+ public string Id;
public DateTime Time;
public double Value;
}
public class TimeSeries : ObservableCollection<TimeValue> {
public void AddTimeValue(double value, DateTime? dateTime = null) {
if (dateTime == null) dateTime = DateTime.Now;
- Add(new TimeValue { Time = dateTime.Value, Value = value });
+ Add(new TimeValue {Id = Guid.NewGuid().ToString(), Time = dateTime.Value, Value = value });
}
}
@@ -260,16 +261,17 @@ private void OnShowWatermarksPropertyChanged()
public class TimeValueAddedEventArgs : EventArgs {
public Point Point { get; set; }
public Panel Panel { get; set; }
+ public TimeValue TimeValue { get; set; }
}
public delegate void TimeValueAddedHandler(Sparkline obj, TimeValueAddedEventArgs eventArgs);
public event TimeValueAddedHandler TimeValueAdded;
- protected void OnTimeValueAdded(Point po, Panel pa) {
+ protected void OnTimeValueAdded(Point po, Panel pa, TimeValue timeValue) {
var handler = TimeValueAdded;
if (handler != null) {
- handler(this, new TimeValueAddedEventArgs { Point = po, Panel = pa });
+ handler(this, new TimeValueAddedEventArgs { Point = po, Panel = pa, TimeValue = timeValue });
}
}
#endregion
@@ -367,6 +369,7 @@ public class TimeValueAddedEventArgs : EventArgs {
private void DrawTimeValue(TimeValue newTimeValue) {
var point = GetPoint(newTimeValue);
AddPoint(point);
+ OnTimeValueAdded(point, Canvas, newTimeValue);
ScrollViewer.ScrollToRightEnd();
}
@@ -392,7 +395,6 @@ public class TimeValueAddedEventArgs : EventArgs {
// Canvas.Children.Add(textbox);
//#endif
_nextXValue++;
- OnTimeValueAdded(point, Canvas);
}
private Path DrawDot(Point center) {

0 comments on commit 1c2338e

Please sign in to comment.