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. ScottPlot automatically detects and compensates for display scaling, so you probably donât need to worry about it. 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. The current mouse pointer position is still shown.:-) If you want to change .ToString with MousePosition.X. Doing the code this way it does not matter if you move the mouse pointer over a button or a LABEL or whatever. However, but this functionality is easy to implement by the user. Hi cesno, Add two Labels to a FORM and try this code then please. 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. That last code works great but is missing the relative position of the window. When these two points combine on a large dataset, mouse-interactive performance may suffer. include // defines for POINT, and GetCursorPos().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. When working with Signal plots, call GetPointNearestX(x) instead.Äownload the full source code for this demo Unlike Scatter plots which use GetPointNearest(x, y), Signal plots display evenly-spaced data points and only track the mouse horizontally. update the GUI to describe the highlighted point Text = $"Point index )" ![]() render if the highlighted point chnaged if (LastHighlightedIndex != pointIndex) These numbers can be used to control attributes of. ![]() ![]() place the highlight over the point of interest HighlightedPoint.X = pointX The cursor position is read by computer programs as two numbers, the x-coordinate and the y-coordinate. ( 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. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |