PointTracker for Winform (simple implementation)

Oystein Bjorke il y a 10 ans 0
This discussion was imported from CodePlex

heromyth wrote at 2012-05-09 04:29:

It's using a TextLabel to implement the tracker. It's just better than nothing.

diff -r 93124cd413d6 Source/OxyPlot.WindowsForms/Plot.cs
--- a/Source/OxyPlot.WindowsForms/Plot.cs    Thu Apr 26 21:11:20 2012 +0200
+++ b/Source/OxyPlot.WindowsForms/Plot.cs    Wed May 09 10:21:11 2012 +0800
@@ -223,6 +223,7 @@
         /// </summary>
         public void HideTracker()
         {
+            m_label.Visible = false;
         }
 
         /// <summary>
@@ -381,8 +382,20 @@
         /// </param>
         public void ShowTracker(TrackerHitResult data)
         {
-            // not implemented for WindowsForms
+            if (m_label == null)
+            {
+                m_label = new Label();
+                m_label.Parent = this;
+                m_label.BackColor = Color.LightSkyBlue;
+                m_label.AutoSize = true;
+            }
+
+            m_label.Text = data.ToString();
+            m_label.Top = (int)data.Position.Y - this.Top;
+            m_label.Left = (int)data.Position.X - this.Left;
+            m_label.Visible = true;
         }
+        private Label m_label;
 
         /// <summary>
         /// The show zoom rectangle.


objo wrote at 2012-05-11 00:17:

thanks for the code, I will add this soon! I agree that a Label is better than nothing :)


objo wrote at 2014-02-02 20:57:

Sorry I forgot about this one... I have included the simple tracker, and created a work issue to improve it: https://oxyplot.codeplex.com/workitem/10125