/// <summary> /// Provides the selection criteria according to the mouse event arg /// </summary> /// <param name="mouseEventArgs"></param> /// <returns></returns> public static Context.SelectionCriteria SelectionCriteriaBasedOnMouseEvent(MouseEventArgs mouseEventArgs) { Context.SelectionCriteria retVal = Context.SelectionCriteria.None; if (mouseEventArgs != null) { if (mouseEventArgs.Button == MouseButtons.Left) { retVal = retVal | Context.SelectionCriteria.LeftClick; } if (mouseEventArgs.Button == MouseButtons.Right) { retVal = retVal | Context.SelectionCriteria.RightClick; } if (mouseEventArgs.Clicks > 1) { retVal = retVal | Context.SelectionCriteria.DoubleClick; } if (Control.ModifierKeys == Keys.Control) { retVal = retVal | Context.SelectionCriteria.Ctrl; } if (Control.ModifierKeys == Keys.Alt) { retVal = retVal | Context.SelectionCriteria.Alt; } } return(retVal); }
/// <summary> /// Handles a mouse double click event on a graphical element /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> public virtual void HandleDoubleClick(object sender, MouseEventArgs mouseEventArgs) { IModelElement model = Model as IModelElement; if (model != null) { Context.SelectionCriteria criteria = GuiUtils.SelectionCriteriaBasedOnMouseEvent(mouseEventArgs); EfsSystem.Instance.Context.SelectElement(model, Panel, criteria); } }
/// <summary> /// Handles a mouse click event on a graphical element /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> public override void HandleClick(object sender, MouseEventArgs mouseEventArgs) { IModelElement model = TypedModel.RuleCondition; if (model != null) { Context.SelectionCriteria criteria = GuiUtils.SelectionCriteriaBasedOnMouseEvent(mouseEventArgs); EfsSystem.Instance.Context.SelectElement(model, Panel, criteria); } }
private void EditionTextBox_MouseClick(object sender, MouseEventArgs mouseEventArgs) { if (ModifierKeys == Keys.Control) { INamable instance = GetInstance(mouseEventArgs.Location); if (instance != null) { IModelElement modelElement = instance as IModelElement; if (modelElement != null) { Context.SelectionCriteria criteria = GuiUtils.SelectionCriteriaBasedOnMouseEvent(mouseEventArgs); if ((criteria & Context.SelectionCriteria.Ctrl) != 0) { EfsSystem.Instance.Context.SelectElement(modelElement, this, Context.SelectionCriteria.DoubleClick); } } } } }
/// <summary> /// Selects an historical data element /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void historyDataGridView_DoubleClick(object sender, EventArgs e) { ModelElement selected = null; if (historyDataGridView.SelectedCells.Count == 1) { int i = historyDataGridView.SelectedCells[0].OwningRow.Index; List <HistoryObject> historyObjects = (List <HistoryObject>)historyDataGridView.DataSource; selected = historyObjects[i].Reference; } if (selected != null) { MouseEventArgs mouseEventArgs = e as MouseEventArgs; if (mouseEventArgs != null) { EfsSystem.Instance.Context.ClearHistoryUntilElement(selected); Context.SelectionCriteria criteria = GuiUtils.SelectionCriteriaBasedOnMouseEvent(mouseEventArgs); EfsSystem.Instance.Context.SelectElement(selected, this, criteria); } } }
/// <summary> /// Selects the model element which corresponds to the explain tree node /// If the current node does not refer to a model element, selects the one from its parent node /// </summary> /// <param name="node"></param> /// <param name="mouseEventArgs"></param> private void SelectModelElement(ExplainTreeNode node, MouseEventArgs mouseEventArgs) { while (node != null) { ModelElement model = node.Explanation.LeftPart as ModelElement; if (model == null) { model = node.Explanation.Element; } if (model != null) { Context.SelectionCriteria criteria = GuiUtils.SelectionCriteriaBasedOnMouseEvent(mouseEventArgs); EfsSystem.Instance.Context.SelectElement(model, this, criteria); node = null; } else { node = node.Parent as ExplainTreeNode; } } }
/// <summary> /// Handles the move event, which, in case of an arrow is selected to be modified, /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> private void HandleMouseMove(object sender, MouseEventArgs mouseEventArgs) { GraphicElement element = ElementForLocation(mouseEventArgs.Location, null); if (element != null) { element.HandleMouseMove(sender, mouseEventArgs); } if (_changingArrow != null && _chaningArrowAction != ChangeAction.None) { BoxControl <TEnclosing, TBoxModel, TArrowModel> box = BoxForLocation(mouseEventArgs.Location, null); if (box != null) { switch (_chaningArrowAction) { case ChangeAction.InitialBox: if (_changingArrow.TypedModel.Source != box.Model) { _changingArrow.SetInitialBox(box.TypedModel); } break; case ChangeAction.TargetBox: if (_changingArrow.TypedModel.Target != box.Model) { if (_changingArrow.TypedModel.Source != null) { _changingArrow.SetTargetBox(box.TypedModel); } } break; } } } if (_movingBox != null) { Point mouseMoveLocation = mouseEventArgs.Location; int deltaX = mouseMoveLocation.X - _moveStartLocation.X; int deltaY = mouseMoveLocation.Y - _moveStartLocation.Y; if (Math.Abs(deltaX) > 5 || Math.Abs(deltaY) > 5) { IModelElement model = _movingBox.TypedModel; if (model != null && !_movingBoxHasMoved) { Context.SelectionCriteria criteria = GuiUtils.SelectionCriteriaBasedOnMouseEvent(mouseEventArgs); EfsSystem.Instance.Context.SelectElement(model, this, criteria); _movingBoxHasMoved = true; } Util.DontNotify(() => { int newX = _positionBeforeMove.X + deltaX; int newY = _positionBeforeMove.Y + deltaY; SetBoxPosition(_movingBox, newX, newY); UpdatePositions(); }); } } }