I have an activity to provide Intellesence functionality to the user for RadRichTextBox placed inside RadGridView. I have implemented the functionality for intellesence by using RadListBox.
But i am facing problem while displying the RadListBox at certain location where user is typing.
To resolve the problem, a need to calculate the X-Y coordinates of GridViewCell in which my RadRichTextBox is placed.
Once i will get the coordinates for GridViewCell than that can be used to calculate the actual position where user is typing.
SO what i finally want the GridViewCell X-Y coordinates relative to my current view on GUI.
This functionality will be implemented in a Silverlight application using Telerik controls.
I got the solution:
GeneralTransform globalTransform = gridViewParent.CurrentCell.TransformToVisual(Application.Current.RootVisual);
Point transformedPoint = globalTransform.Transform(new Point(0, 0));
Related
I'm new to C# and windowsforms applications. I'm trying to create a, at least to some extend, interactive chart. As of now I have not found a library or a built-in method to do what I have in mind.
I want to be able to:
Set a cursor when I click in the chart, set a 2nd cursor when I click again.
When 2 cursors are set, I want to be able to move them with the mouse (click to grab).
(If possible side by side with cursor click-placing:
"Zoom the chart by drawing a rectangle in the chart by clicking and moving the mouse".
My intention is to enable zoom as in: MS Chart Control: prevent zoom when clicking)
I'd like to do this to analyze data (see: Cursor setting example.png). With the cursors it should be possible to easily get the values of the two cursor positions (yellow and red lines) and to measure the distance in between (purple line).
Does anyone of you know how to do this with a mouse_click event OR know a chart library to easily do that?
Thanks for your help!
-Phill
Found another solution to my question and posted it as an answer there: How to retrieve the selected range in the .Net WinForms Chart Control?
To add colored cursors I also add 2 dataseries that are yellow and red to the method private void chart1_SelectionRangeChanging(object sender, CursorEventArgs e):
chart1.Series["CursorX1"].Points.AddXY(x1,y1Min);`
chart1.Series["CursorX1"].Points.AddXY(x1,y1Max);
chart1.Series["CursorX1"].Points.Color = Color.Red;
chart1.Series["CursorX2"].Points.AddXY(x2,y2Min);`
chart1.Series["CursorX2"].Points.AddXY(x2,y2Max);
chart1.Series["CursorX2"].Points.Color = Color.Yellow;
I'm using the WPF version of GMaps.net. Certain functionalities such as polygon selection is not that obvious.
What I need to do is detect a polygon click on the map, and then change properties of the polygon (opacity etc) to show that it is selected. A custom way to achieve this is by getting the mouse coordinates with a mouse click event, and do a polygon intersection test with some vector maths, however I'm sure there must be a built-in way to do this?
For clarity sake, this is how I create my polygons:
GMapPolygon polygon = new GMapPolygon(polyPointList);
polygon.RegenerateShape(gMapControl1);
(polygon.Shape as Path).Stroke = Brushes.DarkBlue;
(polygon.Shape as Path).Opacity = 0.5;
gMapControl1.Markers.Add(polygon);
I believe you're right, the WPF version of the polygon doesn't offer it right out of the box.
Think you could use the PointLatLng of your click and check if that's within the bounds of the polygon. Take the WinForms version of it and adapt it. In the end it's just that bit of math that's lacking.
I created simple form and now I want to draw single objects (rectangle, circle, lines..) in relative coordinates.
Main problem for me here is to create 2D cartesian coordinate system in middle of the form.Is it possible and how to do it??
Main question is how to efficiently transform absolute coordinates to relative? How to create my own system so I get results in numbers (negative, positive depending on quadrant) and not in pixel?
.
Currently I made MouseMove event to display current location of mouse with Cursor.Position.X, Cursor.Position.Y and display it in label. Displayed coordinates are pixels, how to change that? I've read something about converting with PointToClient method but I don't really understand it.
I am tied to windows forms becouse I already made a program in win forms and now I just want to add this feature to it.
Thanks
What you're most likely looking for are Graphics.TranslateTransform and Graphics.ScaleTransform.
private void Transform(PaintEventArgs e)
{
e.Graphics.ScaleTransform(width, height);
e.Graphics.TranslateTransform(xOffset, yOffset);
}
You'll also need to make sure that whatever drawing method you're using has an overload for either PointF structures or Singles.
Of course, you could also just handle all of this on your end. Scaling your input/output coordinates by the width and height of the form and then translating by half of that will give you the same results.
Edit- To add some clarity, Windows always expects your coordinates to be in pixel form. You can use the above transformations to do your work at a different scale and then transform into the form that Windows expects.
Setting the translation should be straightforward. If you want the middle of the form, you simply want to translate by half the width and half the height. How you choose to scale your coordinates is going to depend on the range that you need to work in (ie, -1.0 to 1.0, -0.5 to 0.5, etc.).
i am using in my c# project visio activex to import visio floorplan drawings.
and i need to get the vertices of the shapes in that drawing, and i can't find any method or property for it.
if someone has any ideas please help.
You can use the BoundingBox method on the shape class to retrieve the dimensions of the box around a shape.
This MSDN page will give you more information about the method, it returns the top, bottom, left and right of the box, so it should be possible to work out the vertices from that.
Visio uses a PinX and a PinY to describe the location of a shape using the shapes Height and Width will allow you to calculate the vertices.
The thing is I have some graphics shown in a form, rectangle for example, and I want to capture when the point gets over thees fields. So I Thoght I try to find the corrrdinates for thees rectangles, but as thay are the coords in the form it dose not match the ones with the mouse location.
So I wonder is there a way to find what coord on the screen a Point has on the screen and not in the form or controller?
Each control hs PointToFoo methods for conversion. Note that you should call this from the parent of the object who's location you want:
Point scrPos = this.PointToScreen(panel1.Location);
Alternatively, you can get the panel's screen coordinates with:
Point scrPos = panel1.PointToScreen(new Point(0,0));
Note that the above two examples could gve different result due to the border-size of the panel.
If you are using the graphics object for the form by calling this.CreateGraphics() within the form, then the coordinates used when you draw the rectangle should be exactly the same as those returned by the click event on the form.
Do you know what coordinates your pointer is in? You can get the coordinates for your window with a call to GetWindowRect() and subtract the top/left from your mouse cursor to get client coordinates.
I seem to remember there being a function to do that for you in fact, but it's been some time since I dabbled in custom GUI controls.