/// <summary> /// Undo action. /// </summary> virtual public void Undo() { if (History <ShapeCollection> .IsAtStart()) { return; } _shapes.Clear(); _shapes.AddRange(History <ShapeCollection> .Undo()); Invalidate(); }
public override bool OnMouseDown(MouseEventArgs e, KeyModifier eKeyMod, int iOldX, int iOldY) { // 1. 현재 마우스 포지션의 UI 를 가지고 온다 // 2. UI 가 있고, 커서가 경계에 겹칠 경우 - Select 해주고 마우스 커서 변경 , Move Mode 로 Position 변경 // 3. UI 가 있고, 커서가 경계 안에 있을 경우 - 사이즈 변경 if (e.Button == MouseButtons.Left) { UIShapeBase selectedShape = null; if (View.Cursor == Cursors.Arrow) // 화살표일 경우 선택 모드 { m_selectedShapeList.Clear(); selectedShape = this.GetUIShape(e.X, e.Y, false); } else if (View.Cursor == Cursors.Cross) { selectedShape = this.GetUIShape(e.X, e.Y, false); } else// 화살표가 아니면 선택된 아이템중에 선택 { selectedShape = this.GetUIShapeFromSelection(e.X, e.Y); } if (eKeyMod == KeyModifier.Shift) // Shift 누르면 복사 { m_bCopying = true; Dragmode = MOUSE_MODE.UI_COPY; } if (selectedShape != null) { if (m_selectedShapeList.Contains(selectedShape) == false) { m_selectedShapeList.Add(selectedShape); } } } // if (EditorManager.SelectedShapes.Contains(m_selectedShape) == false ) // { // EditorManager.SelectedShapes = new CSharpFramework.ShapeCollection(); // EditorManager.SelectedShapes.Add(m_selectedShape); // } if (m_selectedShapeList.Count >= 1) { if (View.Cursor == Cursors.SizeAll) { if (eKeyMod == KeyModifier.Shift && Dragmode == MOUSE_MODE.UI_COPY) // 시프트키 눌리고 , 셀렉티드 쉐입에 , Move Mode 이면 복사 { m_bCopying = true; foreach (UIShapeBase shape in m_selectedShapeList) { if (shape != null) { UIShapeBase copyShape = CreateNewShape(shape, m_baseDialog, shape.PosX, shape.PosY); m_UICopyShapeList.Add(copyShape); } } m_selectedShapeList.Clear(); m_selectedShapeList.AddRange(m_UICopyShapeList); m_UIShapeList.AddRange(m_UICopyShapeList); // // foreach (UIShapeBase shape in m_UICopyShapeList) // { // EditorManager.Actions.Add(new AddShapeAction(shape, m_baseDialog, shape.ParentLayer, true)); // } // // EditorManager.SelectedShapes.Clear(); // 기존 선택된 UI 들 지우고 // EditorManager.SelectedShapes.AddRange(m_UICopyShapeList); // 복사된거만 선택 m_bCopying = false; //UIShapeBase copyShape = CreateNewShape(m_selectedShape, m_baseDialog, m_selectedShape.PosX, m_selectedShape.PosY); //m_selectedShape = copyShape; //UIShapeBase copyShape = (UIShapeBase)m_selectedShape.Clone(); //m_UICopyShapeList.Add(copyShape); } else { Dragmode = MOUSE_MODE.UI_MOVE; } } else if (View.Cursor == Cursors.Arrow) { } else { Dragmode = MOUSE_MODE.UI_SIZE; } } if (Dragmode == MOUSE_MODE.UI_COPY) { ShapeCollection collection = new CSharpFramework.ShapeCollection(); collection.AddRange(m_UICopyShapeList); EditorManager.SelectedShapes = collection; } else { ShapeCollection collection = new CSharpFramework.ShapeCollection(); collection.AddRange(m_selectedShapeList); EditorManager.SelectedShapes = collection; } return(false); }
private void SortSelectedShapes(MoveShapesDirection moveDirection) { ShapeCollection selected = shapeTreeView.SelectedShapes; // return if any of the indices is already on the maximum. foreach (ShapeBase shape in selected) { if (moveDirection == MoveShapesDirection.Up) { if (shape.Parent.ChildCollection.FindIndex(i => i == shape) <= 0) return; } else if (shape.Parent.ChildCollection.FindIndex(i => i == shape) >= shape.Parent.ChildCollection.Count - 1) return; } // get all parents to share modified collections between their children. ShapeCollection parents = new ShapeCollection(); foreach (ShapeBase shape in selected) if (!parents.Contains(shape.Parent)) parents.Add(shape.Parent); EditorManager.Actions.StartGroup("Sort Shapes"); foreach (ShapeBase parent in parents) { // create copy of the original collection before sorting ShapeCollection copyOfChildren = new ShapeCollection(); copyOfChildren.AddRange(parent.ChildCollection); if (moveDirection == MoveShapesDirection.Up) { for (int i = 0; i < selected.Count; i++) { ShapeBase child = selected[i]; if (child.Parent == parent) { int index = copyOfChildren.FindIndex(c => c == child); copyOfChildren.Remove(child); copyOfChildren.Insert(index - 1, child); EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren)); } } } else for (int i = selected.Count - 1; i > -1; i--) { ShapeBase child = selected[i]; if (child.Parent == parent) { int index = copyOfChildren.FindIndex(c => c == child); copyOfChildren.Remove(child); copyOfChildren.Insert(index + 1, child); EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren)); } } } EditorManager.Actions.EndGroup(); // recover selection ArrayList newSelection = new ArrayList(); foreach (ShapeTreeNode node in shapeTreeView.Nodes) { if (selected.Contains(node.shape)) // root newSelection.Add(node); foreach (ShapeTreeNode subNode in shapeTreeView.GetChildNodes(node)) { if (selected.Contains(subNode.shape)) // all children newSelection.Add(subNode); } } shapeTreeView.SelectedNodes = newSelection; }
protected override bool ProcessDialogKey(Keys keyData) { if (Globe.Graphics.Bidimensional.Common.Select.LastSelectedShape == null) { return(base.ProcessDialogKey(keyData)); } ShapeCollection selectedShapes = new ShapeCollection(); Keys key = keyData & Keys.KeyCode; if (System.Windows.Forms.Control.ModifierKeys == Keys.Control) { selectedShapes.AddRange(Globe.Graphics.Bidimensional.Common.Select.GetSelectedShapes(_shapes)); } else { selectedShapes.Add(Globe.Graphics.Bidimensional.Common.Select.LastSelectedShape); } float offsetX = _gridManager.Resolution.Width; if (_gridManager.Resolution.Width == 0) { offsetX = 1; } float offsetY = _gridManager.Resolution.Height; if (_gridManager.Resolution.Height == 0) { offsetY = 1; } switch (key) { case Keys.Up: foreach (IShape shape in selectedShapes) { shape.Transformer.Translate(0, -offsetY); } Invalidate(); break; case Keys.Down: foreach (IShape shape in selectedShapes) { shape.Transformer.Translate(0, offsetY); } Invalidate(); break; case Keys.Left: foreach (IShape shape in selectedShapes) { shape.Transformer.Translate(-offsetX, 0); } Invalidate(); break; case Keys.Right: foreach (IShape shape in selectedShapes) { shape.Transformer.Translate(offsetX, 0); } Invalidate(); break; } return(base.ProcessDialogKey(keyData)); }