/// <summary> /// Clicks away from the given screen object by the given offset using the left mouse button. /// The click is executed using a 'true' mouse event. Horizontal positive direction is left, /// vertical positive direction is down. /// The simple element locators are automationId, className, controlType, text and those are used as: /// automationId=myId, className=myClassName, controlType=MenuItem, text=someText. /// The xpath is much more versatile locator, which combines the controlType, simple element locator and index, for example /// | RightClickWithOffset | automationId=myId | 100 | 100 | /// | RightClickWithOffset | text=Some Text | 10 | -10 | /// | RightClickWithOffset | xpath=//Button[@text='Some text'] | 0 | 100 | /// | RightClickWithOffset | xpath=//MenuItem[@className=File][@text='Some Item'] |-20 | -20 | /// | RightClickWithOffset | xpath=//MenuItem[1] | 24 | 0 | /// | RightClickWithOffset | xpath=//Edit[@automationId='001234'][@text='Some Text'][2] | 4 | 4 | /// | RightClickWithOffset | xpath=//Pane[@text='x']/descendant::Button[@text='Ok'][3] | 0 | 0 | /// </summary> /// <param name="elementId"></param> /// <param name="xOff"></param> /// <param name="yOff"></param> public void RightClickWithOffset(String elementId, String xOff, String yOff) { System.Windows.Point po = findUIObject(elementId).Bounds.BottomRight; po.Offset(1.0 * Convert.ToInt32(xOff), 1.0 * Convert.ToInt32(yOff)); Mouse.Instance.RightClick(po); }
private void pnl2D_MouseMove(object sender, MouseEventArgs e) { if (e.X == lastX && e.Y == lastY) { return; } PointF end = R2V(new PointF(e.X, e.Y)); float theta0 = 0; float phi0 = 0; switch (projectionType) { case ProjectionType.AZIMUTHAL: { PointF p = ToPolar(new PointF((float)(end.X - center.X), (float)(center.Y - end.Y))); theta0 = p.Y; phi0 = p.X / radiusX * (float)Math.PI; break; } case ProjectionType.MERCATOR: { theta0 = (float)((end.X - center.X + radiusX) * Math.PI / radiusX - 3 * Math.PI / 2); if (end.Y >= center.Y) { phi0 = (float)(2 * Math.Atan(Math.Exp((end.Y - center.Y) * Math.PI / radiusX))); } else { phi0 = (float)(Math.PI - 2 * Math.Atan(Math.Exp((center.Y - end.Y) * Math.PI / radiusX))); } break; } } float latitude = 90 - RadToDeg(phi0); float longitude = RadToDeg(theta0) + 90; // Show in status bar the geographic coordinates of the mouse position above the projection (2D panel). tsslText.Text = "Latitute: " + DegToDegMinSec(Math.Abs(latitude)) + (latitude > 0 ? "N" : latitude < 0 ? "S" : "") + " Longitude: " + DegToDegMinSec(Math.Abs(longitude)) + (longitude > 0 ? "E" : longitude < 0 ? "W" : ""); int dx = e.X - lastX; int dy = e.Y - lastY; if (moving) { center.Offset(dx, dy); pnl2D.Invalidate(); } else if (resizing) { radiusX += dx / 2F; if (projectionType == ProjectionType.MERCATOR) { radiusY += dy / 2F; center.Offset(dx / 2F, dy / 2F); } pnl2D.Invalidate(); } else if (drawingWithPencil) { using (Graphics g = Graphics.FromImage(foregroundImage)) { using (Pen pen = new Pen(btnColor.BackColor, 2)) { PointF start = R2V(new PointF(lastX, lastY)); g.DrawLine(pen, start, end); } } pnl2D.Invalidate(); } else if (drawingWithLine) { using (Graphics g = Graphics.FromImage(drawingImage)) { g.Clear(System.Drawing.Color.Transparent); using (Pen pen = new Pen(btnColor.BackColor, 2)) { PointF start = R2V(new PointF(startX, startY)); g.DrawLine(pen, start, end); } } pnl2D.Invalidate(); } else if (drawingWithGeodesic) { PointF start = R2V(new PointF(startX, startY)); switch (projectionType) { case ProjectionType.AZIMUTHAL: DrawGeodesicAzimuthal(start, end); break; case ProjectionType.MERCATOR: DrawGeodesicMercator(start, end); break; } pnl2D.Invalidate(); } lastX = e.X; lastY = e.Y; }