/// <summary> /// Click on an accessible object. The caller should make sure that the /// accessible object is visible before making this call. /// </summary> /// <param name="accessibleObject">A child accessible object to click on</param> /// <param name="clicks">The number of clicks (1 for single click, 2 for double)</param> /// <param name="location">The location in the accessible object to click on</param> /// <param name="xOffset">A horizontal offset (in pixels) from the specified click location.</param> /// <param name="yOffset">A vertical offset (in pixels) from the specified click location.</param> public void ClickAccessibleObject(AccessibleObject accessibleObject, int clicks, ClickLocation location, int xOffset, int yOffset) { Rectangle rect = accessibleObject.Bounds; PointF pt; switch (location) { case ClickLocation.UpperLeft: pt = new PointF((float)rect.Left + xOffset, (float)rect.Top + yOffset); break; case ClickLocation.Center: default: pt = new PointF(((float)rect.Left + rect.Right) / 2 + xOffset, ((float)rect.Top + rect.Bottom) / 2 + yOffset); break; } Rectangle screenBounds = Screen.GetBounds(myClientView); MoveMouseClose(screenBounds, pt); int dx = (int)(pt.X / screenBounds.Width * 65535f); int dy = (int)(pt.Y / screenBounds.Height * 65535f); SendKeys.Flush(); mouse_event(MouseEventFlags.Move | MouseEventFlags.Absolute, dx, dy, 0, 0); SendKeys.Flush(); while (clicks > 0) { mouse_event(MouseEventFlags.LeftDown | MouseEventFlags.Absolute, dx, dy, 0, 0); SendKeys.Flush(); mouse_event(MouseEventFlags.LeftUp | MouseEventFlags.Absolute, dx, dy, 0, 0); SendKeys.Flush(); --clicks; } SendKeys.Flush(); }
public void LegendDoubleClick(int handle, ClickLocation location, ref bool handled) { }
public void LegendMouseDown(int handle, int button, ClickLocation location, ref bool handled) { }
/// <summary> /// End a drag operation with a drop on an accessible object. The caller should make sure that the /// accessible object is visible before making this call. /// </summary> /// <param name="accessibleObject">A child accessible object to drop on</param> /// <param name="location">The location in the accessible object to drop on</param> /// <param name="xOffset">A horizontal offset (in pixels) from the specified drop location.</param> /// <param name="yOffset">A vertical offset (in pixels) from the specified drop location.</param> public void DropOnAccessibleObject(AccessibleObject accessibleObject, ClickLocation location, int xOffset, int yOffset) { Rectangle rect = accessibleObject.Bounds; PointF pt; switch (location) { case ClickLocation.UpperLeft: pt = new PointF((float)rect.Left + xOffset, (float)rect.Top + yOffset); break; case ClickLocation.Center: default: pt = new PointF(((float)rect.Left + rect.Right) / 2 + xOffset, ((float)rect.Top + rect.Bottom) / 2 + yOffset); break; } Rectangle screenBounds = Screen.GetBounds(myClientView); MoveMouseClose(screenBounds, pt); int dx = (int)(pt.X / screenBounds.Width * 65535f); int dy = (int)(pt.Y / screenBounds.Height * 65535f); SendKeys.Flush(); mouse_event(MouseEventFlags.Move | MouseEventFlags.Absolute, dx, dy, 0, 0); SendKeys.Flush(); mouse_event(MouseEventFlags.LeftUp | MouseEventFlags.Absolute, dx, dy, 0, 0); SendKeys.Flush(); }
/// <summary> /// Start a drag operation on an accessible object. The caller should make sure that the /// accessible object is visible before making this call. /// </summary> /// <param name="accessibleObject">A child accessible object to drag</param> /// <param name="location">The location in the accessible object to drag from</param> /// <param name="xOffset">A horizontal offset (in pixels) from the specified drag location.</param> /// <param name="yOffset">A vertical offset (in pixels) from the specified drag location.</param> public void DragAccessibleObject(AccessibleObject accessibleObject, ClickLocation location, int xOffset, int yOffset) { Rectangle rect = accessibleObject.Bounds; PointF pt; switch (location) { case ClickLocation.UpperLeft: pt = new PointF((float)rect.Left + xOffset, (float)rect.Top + yOffset); break; case ClickLocation.Center: default: pt = new PointF(((float)rect.Left + rect.Right) / 2 + xOffset, ((float)rect.Top + rect.Bottom) / 2 + yOffset); break; } Rectangle screenBounds = Screen.GetBounds(myClientView); MoveMouseClose(screenBounds, pt); int dx = (int)(pt.X / screenBounds.Width * 65535f); int dy = (int)(pt.Y / screenBounds.Height * 65535f); Size dragSize = SystemInformation.DragSize; float dxDrag = (dragSize.Width / screenBounds.Width * 65535f); float dyDrag = (dragSize.Height / screenBounds.Height * 65535f); SendKeys.Flush(); mouse_event(MouseEventFlags.Move | MouseEventFlags.Absolute, dx, dy, 0, 0); SendKeys.Flush(); mouse_event(MouseEventFlags.LeftDown | MouseEventFlags.Absolute, dx, dy, 0, 0); // Move .5 the drag size, the full drag size, and 1.5 the drag size to make sure we got it mouse_event(MouseEventFlags.Move | MouseEventFlags.Absolute, dx + (int)(dxDrag * .5), dy + (int)(dyDrag * .5), 0, 0); SendKeys.Flush(); mouse_event(MouseEventFlags.Move | MouseEventFlags.Absolute, dx + (int)dxDrag, dy + (int)dyDrag, 0, 0); SendKeys.Flush(); mouse_event(MouseEventFlags.Move | MouseEventFlags.Absolute, dx + (int)(dxDrag * 1.5), dy + (int)(dyDrag * 1.5), 0, 0); SendKeys.Flush(); }
/// <summary> /// 在legend上的MouseUp事件调用的方法,宿主程序调用 /// </summary> /// <param name="handle">鼠标所点击的层或组的handle</param> /// <param name="button">MouseUP的鼠标按钮. 可以用Button枚举决定是哪个按钮被按下</param> /// <param name="location">点击的位置,要么是在层(layer)上要么是在一个组(group)上.</param> /// <param name="handled">若设为true,则表示除这个插件外的插件都不能接收这个消息.</param> public virtual void LegendMouseUp(int handle, int button, ClickLocation location, ref bool handled) { }
public void OnClickLocationClicked(object pSender, EventArgs pEventArgs) { ClickLocation?.Invoke(this, pEventArgs); }