Exemple #1
0
        private void formsPlot1_MouseMove(object sender, MouseEventArgs e)
        {
            double mouseX = formsPlot1.Plot.GetCoordinateX(e.Location.X);
            double mouseY = formsPlot1.Plot.GetCoordinateY(e.Location.Y);

            sph.HighlightClear();
            var(x, y, index) = sph.HighlightPointNearest(mouseX, mouseY);
            formsPlot1.Render();

            label1.Text = $"Closest point to ({mouseX:N2}, {mouseY:N2}) " +
                          $"is index {index} ({x:N2}, {y:N2})";

            if (cbTooltip.Checked)
            {
                PointF highlightedPoint = new PointF(formsPlot1.Plot.GetPixelX(x), formsPlot1.Plot.GetPixelY(y));
                double dX = e.Location.X - highlightedPoint.X;
                double dY = e.Location.Y - highlightedPoint.Y;
                double distanceToPoint = Math.Sqrt(dX * dX + dY * dY);
                if (distanceToPoint < 15)
                {
                    tooltip.Show($"{x}, {y}", this,
                                 (int)highlightedPoint.X + formsPlot1.Location.X,
                                 (int)highlightedPoint.Y + formsPlot1.Location.Y);
                }
                else
                {
                    tooltip.Hide(this);
                }
            }
        }
Exemple #2
0
 private void formsPlot1_MouseMove(object sender, MouseEventArgs e)
 {
     (double x, double y) = formsPlot1.GetMouseCoordinates();
     vline.position       = x;
     hline.position       = y;
     sph.HighlightClear();
     sph.HighlightPointNearest(x, y);
     formsPlot1.Render();
 }
Exemple #3
0
        private void wpfPlot1_MouseMove(object sender, MouseEventArgs e)
        {
            (double mouseX, double mouseY) = wpfPlot1.GetMouseCoordinates();

            sph.HighlightClear();
            var(x, y, index) = sph.HighlightPointNearest(mouseX, mouseY);
            wpfPlot1.Render();

            label1.Content = $"Closest point to ({mouseX:N2}, {mouseY:N2}) " +
                             $"is index {index} ({x:N2}, {y:N2})";
        }