![]() ![]() NET WinForms applications, call SetHighDpiMode().įor more information see Setting the default DPI awareness for a process and Mixed-Mode DPI Scaling and DPI-aware APIs. NET platform you target and how your Program.cs is configured. Windows forms may or may not support display scaling depending on which. If display scaling is enabled, mouse coordinates are automatically scaled to match the pixel units of the Bitmap that is displayed. Display scaling is handled differently by different GUI systems, so this detection logic lives inside the ScottPlot controls. That last code works great but is missing the relative position of the window. ScottPlot automatically detects and compensates for display scaling, so you probably donât need to worry about it. include // defines for POINT, and GetCursorPos().Iterate over every data point to determine its distance from the cursor and record which is closest. Since the user has access to the data being plotted and GetMouseCoordinates() this task is relatively straightforward. However, but this functionality is easy to implement by the user. Not all Plottables Have Mouse Helper Methods Users interested in high mouse interactivity should consider creating their own user control specifically designed for their application. When these two points combine on a large dataset, mouse-interactive performance may suffer. Locating the nearest point to the cursor requires an operation that (1) loops over every point in the dataset and (2) has to run every time the cursorâs pixel position changes. The Mouse Info application displays the current XY coordinates of the mouse cursor, as well as the RGB color information of the pixel directly under the cursor. When working with Signal plots, call GetPointNearestX(x) instead.Äownload the full source code for this demo The input desktop must be the current desktop when you call GetCursorPos. The calling process must have WINSTAREADATTRIBUTES access to the window station. ![]() Unlike Scatter plots which use GetPointNearest(x, y), Signal plots display evenly-spaced data points and only track the mouse horizontally. The cursor position is always specified in screen coordinates and is not affected by the mapping mode of the window that contains the cursor. update the GUI to describe the highlighted point Text = $"Point index )" render if the highlighted point chnaged if (LastHighlightedIndex != pointIndex) place the highlight over the point of interest HighlightedPoint.X = pointX ( double pointX, double pointY, int pointIndex) = MyScatterPlot.GetPointNearest(mouseCoordX, mouseCoordY, xyRatio) determine point nearest the cursor ( double mouseCoordX, double mouseCoordY) = formsPlot1.GetMouseCoordinates() Äouble xyRatio = .PxPerUnit / .PxPerUnit Private void formsPlot1_MouseMove( object sender, MouseEventArgs e) Add a red circle we can move around later as a highlighted point indicator HighlightedPoint = (0, 0) create a scatter plot from some random data and save it Random rand = new Random(0) Äouble xs = (rand, pointCount) Äouble ys = (rand, pointCount, multiplier: 1_000) ![]()
0 Comments
Leave a Reply. |