Пример #1
0
        private void formsPlot1_MouseMove(object sender, MouseEventArgs e)
        {
            double mouseX = formsPlot1.plt.CoordinateFromPixelX(e.Location.X);
            double mouseY = formsPlot1.plt.CoordinateFromPixelY(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 = formsPlot1.plt.CoordinateToPixel(x, 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);
                }
            }
        }
Пример #2
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})";
        }
Пример #3
0
        private void MouseMove(object sender, PointerEventArgs e)
        {
            (double mouseX, double mouseY) = avaPlot1.GetMouseCoordinates();

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

            this.Find <TextBlock>("label1").Text = $"Closest point to ({mouseX:N2}, {mouseY:N2}) " +
                                                   $"is index {index} ({x:N2}, {y:N2})";
        }
Пример #4
0
        private void wpfPlot1_MouseMove(object sender, MouseEventArgs e)
        {
            var    mousePos = e.MouseDevice.GetPosition(wpfPlot1);
            double mouseX   = wpfPlot1.plt.CoordinateFromPixelX(mousePos.X);
            double mouseY   = wpfPlot1.plt.CoordinateFromPixelY(mousePos.Y);

            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})";
        }