private void StartSelectElements(BaseElement selectedElement, Point mousePoint) { // Vefiry if element is in selection if (!document.SelectedElements.Contains(selectedElement)) { //Clear selection and add new element to selection document.ClearSelection(); document.SelectElement(selectedElement); } changed = false; moveAction = new MoveAction(); OnElementMovingDelegate onElementMovingDelegate = new OnElementMovingDelegate(OnElementMoving); moveAction.Start(mousePoint, document, onElementMovingDelegate); // Get Controllers controllers = new IController[document.SelectedElements.Count]; for (int i = document.SelectedElements.Count - 1; i >= 0; i--) { if (document.SelectedElements[i] is IControllable) { // Get General Controller controllers[i] = ((IControllable)document.SelectedElements[i]).GetController(); } else { controllers[i] = null; } } resizeAction = new ResizeAction(); resizeAction.Select(document); }
public void Start(Point mousePoint, Document document, OnElementMovingDelegate onElementMovingDelegate) { _document = document; _onElementMovingDelegate = onElementMovingDelegate; // Get Controllers _moveCtrl = new IMoveController[document.SelectedElements.Count]; var moveLabelCtrl = new IMoveController[document.SelectedElements.Count]; for (var i = document.SelectedElements.Count - 1; i >= 0; i--) { _moveCtrl[i] = ControllerHelper.GetMoveController(document.SelectedElements[i]); if ((_moveCtrl[i] != null) && (_moveCtrl[i].CanMove)) { onElementMovingDelegate(new ElementEventArgs(document.SelectedElements[i])); _moveCtrl[i].Start(mousePoint); //ILabelElement - Move Label inside the element if ((document.SelectedElements[i] is ILabelElement) && (ControllerHelper.GetLabelController(document.SelectedElements[i]) == null)) { var label = ((ILabelElement)document.SelectedElements[i]).Label; moveLabelCtrl[i] = ControllerHelper.GetMoveController(label); if ((moveLabelCtrl[i] != null) && (moveLabelCtrl[i].CanMove)) { moveLabelCtrl[i].Start(mousePoint); } else { moveLabelCtrl[i] = null; } } } else { _moveCtrl[i] = null; } } _moveCtrl = (IMoveController[])DiagramUtil.ArrayHelper.Append(_moveCtrl, moveLabelCtrl); _moveCtrl = (IMoveController[])DiagramUtil.ArrayHelper.Shrink(_moveCtrl, null); // Can't move only links var isOnlyLink = true; foreach (var ctrl in _moveCtrl) { // Verify if (ctrl == null) { continue; } ctrl.OwnerElement.Invalidate(); if ((ctrl.OwnerElement is BaseLinkElement) || (ctrl.OwnerElement is LabelElement)) { continue; } isOnlyLink = false; break; } if (isOnlyLink) { //End Move the Links foreach (var ctrl in _moveCtrl) { if (ctrl != null) { ctrl.End(); } } _moveCtrl = new IMoveController[] { null }; } //Upper selecion point controller UpdateUpperSelectionPoint(); _upperSelPointDragOffset.X = _upperSelPoint.X - mousePoint.X; _upperSelPointDragOffset.Y = _upperSelPoint.Y - mousePoint.Y; IsMoving = true; }
public void Start(Point mousePoint, Document document, OnElementMovingDelegate onElementMovingDelegate) { this.document = document; this.onElementMovingDelegate = onElementMovingDelegate; // Get Controllers moveCtrl = new IMoveController[document.SelectedElements.Count]; IMoveController[] moveLabelCtrl = new IMoveController[document.SelectedElements.Count]; for (int i = document.SelectedElements.Count - 1; i >= 0; i--) { moveCtrl[i] = ControllerHelper.GetMoveController(document.SelectedElements[i]); if (moveCtrl[i] != null && moveCtrl[i].CanMove) { onElementMovingDelegate(new ElementEventArgs(document.SelectedElements[i])); moveCtrl[i].Start(mousePoint); //ILabelElement - Move Label inside the element if (document.SelectedElements[i] is ILabelElement && ControllerHelper.GetLabelController(document.SelectedElements[i]) == null) { LabelElement label = ((ILabelElement)document.SelectedElements[i]).Label; moveLabelCtrl[i] = ControllerHelper.GetMoveController(label); if (moveLabelCtrl[i] != null && moveLabelCtrl[i].CanMove) { moveLabelCtrl[i].Start(mousePoint); } else { moveLabelCtrl[i] = null; } } } else { moveCtrl[i] = null; } } moveCtrl = (IMoveController[])ArrayHelper.Append(moveCtrl, moveLabelCtrl); moveCtrl = (IMoveController[])ArrayHelper.Shrink(moveCtrl, null); // Can't move only links bool isOnlyLink = true; foreach (IMoveController ctrl in moveCtrl) { // Verify if (ctrl != null) { ctrl.OwnerElement.Invalidate(); if (!(ctrl.OwnerElement is BaseLinkElement) && !(ctrl.OwnerElement is LabelElement)) { isOnlyLink = false; break; } } } if (isOnlyLink) { //End Move the Links foreach (IMoveController ctrl in moveCtrl) { if (ctrl != null) { ctrl.End(); } } moveCtrl = new IMoveController[] { null }; } //Upper selecion point controller UpdateUpperSelectionPoint(); upperSelPointDragOffset.X = upperSelPoint.X - mousePoint.X; upperSelPointDragOffset.Y = upperSelPoint.Y - mousePoint.Y; isMoving = true; }
public void Start(Point mousePoint, Document document, OnElementMovingDelegate onElementMovingDelegate) { this.document = document; this.onElementMovingDelegate = onElementMovingDelegate; // Get Controllers moveCtrl = new IMoveController[document.SelectedElements.Count]; IMoveController[] moveLabelCtrl = new IMoveController[document.SelectedElements.Count]; for(int i = document.SelectedElements.Count - 1; i >= 0; i--) { moveCtrl[i] = ControllerHelper.GetMoveController(document.SelectedElements[i]); if ((moveCtrl[i] != null) && (moveCtrl[i].CanMove)) { onElementMovingDelegate(new ElementEventArgs(document.SelectedElements[i])); moveCtrl[i].Start(mousePoint); //ILabelElement - Move Label inside the element if ((document.SelectedElements[i] is ILabelElement) && (ControllerHelper.GetLabelController(document.SelectedElements[i]) == null)) { LabelElement label = ((ILabelElement) document.SelectedElements[i]).Label; moveLabelCtrl[i] = ControllerHelper.GetMoveController(label); if ((moveLabelCtrl[i] != null) && (moveLabelCtrl[i].CanMove)) moveLabelCtrl[i].Start(mousePoint); else moveLabelCtrl[i] = null; } } else moveCtrl[i] = null; } moveCtrl = (IMoveController[]) DiagramUtil.ArrayHelper.Append(moveCtrl, moveLabelCtrl); moveCtrl = (IMoveController[]) DiagramUtil.ArrayHelper.Shrink(moveCtrl, null); // Can't move only links bool isOnlyLink = true; foreach (IMoveController ctrl in moveCtrl) { // Verify if (ctrl != null) { ctrl.OwnerElement.Invalidate(); if (!(ctrl.OwnerElement is BaseLinkElement) && !(ctrl.OwnerElement is LabelElement)) { isOnlyLink = false; break; } } } if (isOnlyLink) { //End Move the Links foreach (IMoveController ctrl in moveCtrl) { if (ctrl !=null) ctrl.End(); } moveCtrl = new IMoveController[] {null}; } //Upper selecion point controller UpdateUpperSelectionPoint(); upperSelPointDragOffset.X = upperSelPoint.X - mousePoint.X; upperSelPointDragOffset.Y = upperSelPoint.Y - mousePoint.Y; isMoving = true; }