protected override void OnMouseDown(MouseEventArgs e) { //注意:这里如果用MouseClick,则会出现重绘无效,即使加上立即重绘也不行,必须禁用鼠标右键,否则左竖线会不消失 if (e.Button == MouseButtons.Left) { base.OnMouseDown(e); this._maction = MouseActionEnum.Down; Graphics g = this.CreateGraphics(); if (this.Parent != null) { foreach (Control ctl in this.Parent.Controls) { if (ctl is ButtonEx && ((ButtonEx)ctl).GroupNum > 0 && ((ButtonEx)ctl).GroupNum == this.GroupNum && ((ButtonEx)ctl).Name != this.Name) { ((ButtonEx)ctl).BtnPressState = false; } } } this.BtnPressState = true; } }
bool IGameInterfaceComponent.HandleClick(int x, int y, MouseActionEnum mouse, out DRObjects.Enums.ActionType? actionType,out InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out DRObjects.MapCoordinate coord, out bool destroy) { //This component will 'absorb' the click, but do nothing whatsoever. actionType = null; args = null; coord = null; destroy = false; internalActionType = null; itm = null; return true; }
public bool HandleClick(int x, int y, MouseActionEnum mouseAction, out ActionType? actionType, out InternalActionEnum? internalActionType, out object[] args, out MapItem itm, out MapCoordinate coord, out bool destroy) { itm = null; internalActionType = null; //We only handle left clicks properly if (mouseAction.Equals(MouseActionEnum.LEFT_CLICK)) { //check whether x and y was within a context menu item foreach (ContextMenuItem item in this.contextMenuItems) { if (item.Rect.Contains(new Point(x, y))) { actionType = item.Action; args = item.Args; coord = this.coordinate; //destroy the component destroy = true; return true; } } args = null; actionType = null; coord = null; destroy = false; return false; } else { actionType = null; args = null; coord = null; //destroy it destroy = true; return false; } }
protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); this.Invalidate(false); this._maction = MouseActionEnum.Enter; }
protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave(e); this.Invalidate(false); this._maction = MouseActionEnum.Leave; }