Zoom a custom user control on mouse move event - c#

I am trying to zoom a custom usercontrol which contains a polygon, say paralellogram, which I created with the help of four points with X,Y coordinate but, when I try to zoom it on mouse move event, it stays at the same position and doesn't work out. Any suggestions ?

Related

How to get the closest point on bounds when I'm inside the bounds?

I’m making an VR game where the user can load a 3D model from a server and place tooltips over it to display info about specific points, so, I’m creating the logic to place the tooltips in a 3D space.
I need to get the closest point on bounds to create a vector between it and the tooltip’s attach point, so I can use that direction to place the tooltip without colliding with the mesh, the problem is, the meshes are concave most of the times, therefore the anchor point of the tooltip is inside the bounds, so Collider.ClosestPointOnBounds will not work properly.
Is there a way to get ClosestPointOnBounds when the position is inside the bounds?

How to detect whether the Mouse Hovers above a drawn line in C#

I have a panel on a form. On this panel there are drawn a few lines. I would like to know how to detect when the Mouse is above one of the lines and get the details of the line.
Keep track of your lines in a data structure, e.g. an array, as you draw them.
Create a handler for the panel's MouseMove event.
In the handler, iterate over the (array of) lines and compute the distance from the mouse's position to the nearest point on the line (see this article for the math).
If the distance is below a certain threshold, display the information.

Drag map with limits

I have a map (2d) which is about 5 times the size of the screen area. I can touch drag the map. However the user must only be able to drag it as far as the map is still showing. So the empty area outside map isn't showing.
So my question is: which of the two methods are best:
1) have colliders at the side of the screen and then put colliders on each side of the map. Then checking for collision and if so move the map so its collider does not touch the screen collider.
Or
2) check for the position of the map (i have an adjustable screen size according to device) and then stop the drag if it gets dragged further than visibility of screen. Using coordinates and math.
Will it take up more space (the ios/android) file if I use solution 1?
Thanks.

ILNumerics zoom selection rectangle and accessing the plotted data in ILPlotcube

I plot a surface in a Plot Cube with TwoDMode = true, when I try to zoom using the mouse left drag, the selection zoom rectangle goes behind the surface, therefore, it is not properly shown. Is it possible to force the selection rectangle to be on top of the surface? Moreover, is it possible by hovering or clicking the mouse on the surface, the X, Y and Z values be shown in some textboxes? Thank you very much.
Surfaces are inherently 3D objects. By default, they are intended to be used with ILPlotCube.TwoDMode set to false. But you can try to access the selection rectangle object and modify it accordingly. Try starting with plotCube.ZoomRectangle.Lines.Positions by raising its Z coordinate in order to move it closer to the camera.
Archieving the point of the surface under the cursor is not easy - but doable. Keep in mind, only the vertices of the surface tiles are known explicitly. You can use picking and the mouse events to get informed, if the mouse is over the surface:
surface.MouseMove += (_s,_a) => { yourHandler(_a); }
Afterwards, you are on your own. First, you will have to find the actual surface 3D coordinates. If you can be sure that the surface has not been rotated, you can take a look here.
The method in that thread gives you the surface X and Y coordinates. You can go further and (manually) find the corresponding tile for that position. For the final and exact X,Y,Z coordinates, you would have to interpolate the tile (triangle) vertices to the actual mouse position, using barycentric interpolation.
In order to show the 3D coordinate, you can simply use an ILLabel. You may or may not want to put that into an ILScreenObject.

Form off Screen - Cursor off Form Area

Following this post
I've thought a "simple" solution.
My goal is to prevent mouse movement when my winForm has reached the allowed coordinates.
For instance, if offScreen is for maxX (right border), user will can move mouse in all direction except for left to right.
Is there some event (native too) to accomplish that?

Categories

Resources