@@ -18,7 +18,11 @@ public static class TrackerExamples
1818 [ Example ( "No interpolation" ) ]
1919 public static PlotModel NoInterpolation ( )
2020 {
21- var model = new PlotModel { Title = "No tracker interpolation" , Subtitle = "Used for discrete values or scatter plots." } ;
21+ var model = new PlotModel
22+ {
23+ Title = "No tracker interpolation" ,
24+ Subtitle = "Used for discrete values or scatter plots." ,
25+ } ;
2226 var l = new Legend
2327 {
2428 LegendSymbolLength = 30
@@ -27,16 +31,16 @@ public static PlotModel NoInterpolation()
2731 model . Legends . Add ( l ) ;
2832
2933 var s1 = new LineSeries
30- {
31- Title = "Series 1" ,
32- CanTrackerInterpolatePoints = false ,
33- Color = OxyColors . SkyBlue ,
34- MarkerType = MarkerType . Circle ,
35- MarkerSize = 6 ,
36- MarkerStroke = OxyColors . White ,
37- MarkerFill = OxyColors . SkyBlue ,
38- MarkerStrokeThickness = 1.5
39- } ;
34+ {
35+ Title = "Series 1" ,
36+ CanTrackerInterpolatePoints = false ,
37+ Color = OxyColors . SkyBlue ,
38+ MarkerType = MarkerType . Circle ,
39+ MarkerSize = 6 ,
40+ MarkerStroke = OxyColors . White ,
41+ MarkerFill = OxyColors . SkyBlue ,
42+ MarkerStrokeThickness = 1.5
43+ } ;
4044 for ( int i = 0 ; i < 63 ; i ++ )
4145 {
4246 s1 . Points . Add ( new DataPoint ( ( int ) ( Math . Sqrt ( i ) * Math . Cos ( i * 0.1 ) ) , ( int ) ( Math . Sqrt ( i ) * Math . Sin ( i * 0.1 ) ) ) ) ;
@@ -50,7 +54,11 @@ public static PlotModel NoInterpolation()
5054 [ Example ( "TrackerChangedEvent" ) ]
5155 public static PlotModel TrackerChangedEvent ( )
5256 {
53- var model = new PlotModel { Title = "Handling the TrackerChanged event" , Subtitle = "Press the left mouse button to test the tracker." } ;
57+ var model = new PlotModel
58+ {
59+ Title = "Handling the TrackerChanged event" ,
60+ Subtitle = "Press the left mouse button to test the tracker." ,
61+ } ;
5462 model . Series . Add ( new FunctionSeries ( Math . Sin , 0 , 10 , 100 ) ) ;
5563 model . TrackerChanged += ( s , e ) =>
5664 {
@@ -59,5 +67,51 @@ public static PlotModel TrackerChangedEvent()
5967 } ;
6068 return model ;
6169 }
70+
71+ [ Example ( "Specified distance of the tracker fires" ) ]
72+ public static Example TrackerFiresDistance ( )
73+ {
74+ var model = new PlotModel
75+ {
76+ Title = "Specified distance of the tracker fires" ,
77+ Subtitle = "Press the left mouse button to test the tracker." ,
78+ } ;
79+ model . Series . Add ( new FunctionSeries ( Math . Sin , 0 , 10 , 100 ) ) ;
80+
81+ // create a new plot controller with default bindings
82+ var plotController = new PlotController ( ) ;
83+
84+ // remove a tracker command to the mouse-left/touch down event by default
85+ plotController . Unbind ( PlotCommands . SnapTrack ) ;
86+ plotController . Unbind ( PlotCommands . SnapTrackTouch ) ;
87+
88+ // add a tracker command to the mouse-left/touch down event with specified distance
89+ plotController . BindMouseDown (
90+ OxyMouseButton . Left ,
91+ new DelegatePlotCommand < OxyMouseDownEventArgs > ( ( view , controller , args ) =>
92+ controller . AddMouseManipulator (
93+ view ,
94+ new TrackerManipulator ( view )
95+ {
96+ Snap = true ,
97+ PointsOnly = false ,
98+ FiresDistance = 2.0 ,
99+ CheckDistanceBetweenPoints = true ,
100+ } ,
101+ args ) ) ) ;
102+ plotController . BindTouchDown (
103+ new DelegatePlotCommand < OxyTouchEventArgs > ( ( view , controller , args ) =>
104+ controller . AddTouchManipulator (
105+ view ,
106+ new TouchTrackerManipulator ( view )
107+ {
108+ Snap = true ,
109+ PointsOnly = false ,
110+ FiresDistance = 2.0 ,
111+ } ,
112+ args ) ) ) ;
113+
114+ return new Example ( model , plotController ) ;
115+ }
62116 }
63117}
0 commit comments