protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (_bCurve) { if (_SelCtrlPointIndex != -1) { _SelCtrlPointIndex = -1; } return; } if (_selectedObj != null) { if (!_selectedObj.HitTest(e.Location, _automatGraphics)) { _selectedObj.IsSelected = false; ItemSelectInfo info = new ItemSelectInfo { deselected = _selectedObj, selected = null, location = e.Location }; ItemSelected(this, info); Invalidate(); _selectedObj = null; } } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (_bCurve) { if (_curveControlPoints[0] == _InvalidPoint) { _curveControlPoints[0] = e.Location; Invalidate(); } else if (_curveControlPoints[1] == _InvalidPoint) { //người dùng đã xong việc nhập điểm điều khiển _curveControlPoints[1] = e.Location; var curveConnector = _selectedObj as CurvedStateConnector; curveConnector.ControlPoints[0] = _curveControlPoints[0]; curveConnector.ControlPoints[1] = _curveControlPoints[1]; curveConnector.CalcArrow(); curveConnector.CalcLabelPosition(); Invalidate(); } else { _SelCtrlPointIndex = -1; if (HitHandle(_curveControlPoints[0], e.Location)) { _SelCtrlPointIndex = 0; } if (HitHandle(_curveControlPoints[1], e.Location)) { _SelCtrlPointIndex = 1; } if (_SelCtrlPointIndex != -1) { var selCtrlPt = _curveControlPoints[_SelCtrlPointIndex]; _distance_CtrlPoint_Mouse = new Size(selCtrlPt.X - e.Location.X, selCtrlPt.Y - e.Location.Y); } } return; } for (int i = _selectables.Length - 1; i >= 0; i--) { var _selectable = _selectables[i]; if (_selectable.HitTest(e.Location, _automatGraphics)) { _selectable.IsSelected = true; ItemSelectInfo info = new ItemSelectInfo { deselected = _selectedObj, selected = _selectable, location = e.Location }; ItemSelected(this, info); if (_selectable is CurvedStateConnector) { var curvedConnector = _selectable as CurvedStateConnector; _curveControlPoints[0] = curvedConnector.ControlPoints[0]; _curveControlPoints[1] = curvedConnector.ControlPoints[1]; } if (_selectedObj != null && _selectedObj != _selectable) { _selectedObj.IsSelected = false; } _selectedObj = _selectable; List <BaseMouseHandler> sourceChain = new List <BaseMouseHandler>(); var mouseHandler = _selectedObj as BaseMouseHandler; /*mouseHandler.TrackMouse(this, sourceChain, e);*/ mouseHandler.InitiateTrackMouse(this, sourceChain, e); Invalidate(); break; } } }