void MultiBoard_OnSendToBackClicked(BoardItem boardRefItem) { lock (multiBoard) { foreach (BoardItem item in boardRefItem.Board.SelectedItems) { if (item.Z > 0) { item.Board.UndoRedoMan.AddUndoBatch(new List <UndoRedoAction> { UndoRedoManager.ItemZChanged(item, item.Z, 0) }); item.Z = 0; } } boardRefItem.Board.BoardItems.Sort(); } multiBoard.Focus(); }
void MultiBoard_OnBringToFrontClicked(BoardItem boardRefItem) { lock (multiBoard) { foreach (BoardItem item in boardRefItem.Board.SelectedItems) { int oldZ = item.Z; if (item is BackgroundInstance) { IList list = ((BackgroundInstance)item).front ? multiBoard.SelectedBoard.BoardItems.FrontBackgrounds : multiBoard.SelectedBoard.BoardItems.BackBackgrounds; int highestZ = 0; foreach (BackgroundInstance bg in list) { if (bg.Z > highestZ) { highestZ = bg.Z; } } item.Z = highestZ + 1; } else { int highestZ = 0; foreach (LayeredItem layeredItem in multiBoard.SelectedBoard.BoardItems.TileObjs) { if (layeredItem.Z > highestZ) { highestZ = layeredItem.Z; } } item.Z = highestZ + 1; } if (item.Z != oldZ) { item.Board.UndoRedoMan.AddUndoBatch(new List <UndoRedoAction> { UndoRedoManager.ItemZChanged(item, oldZ, item.Z) }); } } } boardRefItem.Board.BoardItems.Sort(); }
private void parentBoard_ShortcutKeyPressed(Board selectedBoard, bool ctrl, bool shift, bool alt, Keys key) { List <UndoRedoAction> actions = new List <UndoRedoAction>(); if (key == Keys.ControlKey || key == Keys.ShiftKey || key == Keys.Menu /*ALT key*/) { return; } bool clearRedo = true; switch (key) { case Keys.Left: foreach (BoardItem item in selectedBoard.SelectedItems) { if (!item.BoundToSelectedItem(selectedBoard)) { item.X--; actions.Add(CreateItemUndoMoveAction(item, new Point(1, 0))); } } break; case Keys.Right: foreach (BoardItem item in selectedBoard.SelectedItems) { if (!item.BoundToSelectedItem(selectedBoard)) { item.X++; actions.Add(CreateItemUndoMoveAction(item, new Point(-1, 0))); } } break; case Keys.Up: foreach (BoardItem item in selectedBoard.SelectedItems) { if (!item.BoundToSelectedItem(selectedBoard)) { item.Y--; actions.Add(CreateItemUndoMoveAction(item, new Point(0, 1))); } } break; case Keys.Down: foreach (BoardItem item in selectedBoard.SelectedItems) { if (!item.BoundToSelectedItem(selectedBoard)) { item.Y++; actions.Add(CreateItemUndoMoveAction(item, new Point(0, -1))); } } break; case Keys.Delete: switch (selectedBoard.Mouse.State) { case MouseState.Selection: int selectedItemIndex = 0; while (selectedBoard.SelectedItems.Count > selectedItemIndex) { BoardItem item = selectedBoard.SelectedItems[selectedItemIndex]; if (item is ToolTipDot) { selectedItemIndex++; } else { item.RemoveItem(ref actions); } } break; case MouseState.RandomTiles: case MouseState.StaticObjectAdding: case MouseState.Chairs: case MouseState.Ropes: parentBoard.InvokeReturnToSelectionState(); break; case MouseState.Footholds: while (selectedBoard.Mouse.connectedLines.Count > 0 && selectedBoard.Mouse.connectedLines[0].FirstDot.connectedLines.Count > 0) { selectedBoard.Mouse.connectedLines[0].FirstDot.connectedLines[0].Remove(false, ref actions); } break; } break; case Keys.F: if (ctrl) { foreach (BoardItem item in selectedBoard.SelectedItems) { if (item is IFlippable) { ((IFlippable)item).Flip = !((IFlippable)item).Flip; actions.Add(UndoRedoManager.ItemFlipped((IFlippable)item)); } } } break; case Keys.Add: foreach (BoardItem item in selectedBoard.SelectedItems) { item.Z += UserSettings.zShift; actions.Add(UndoRedoManager.ItemZChanged(item, item.Z - UserSettings.zShift, item.Z)); } selectedBoard.BoardItems.Sort(); break; case Keys.Subtract: foreach (BoardItem item in selectedBoard.SelectedItems) { item.Z -= UserSettings.zShift; actions.Add(UndoRedoManager.ItemZChanged(item, item.Z + UserSettings.zShift, item.Z)); } selectedBoard.BoardItems.Sort(); break; case Keys.A: if (ctrl) { foreach (BoardItem item in selectedBoard.BoardItems) { if ((ApplicationSettings.editedTypes & item.Type) == item.Type) { item.Selected = true; } } } clearRedo = false; break; case Keys.Z: if (ctrl && selectedBoard.UndoRedoMan.UndoList.Count > 0) { selectedBoard.UndoRedoMan.Undo(); } clearRedo = false; break; case Keys.Y: if (ctrl && selectedBoard.UndoRedoMan.RedoList.Count > 0) { selectedBoard.UndoRedoMan.Redo(); } clearRedo = false; break; case Keys.Escape: if (selectedBoard.Mouse.State == MouseState.Selection) { ClearBoundItems(selectedBoard); ClearSelectedItems(selectedBoard); clearRedo = false; } else if (selectedBoard.Mouse.State == MouseState.Footholds) { selectedBoard.Mouse.Clear(); } else { parentBoard.InvokeReturnToSelectionState(); } break; default: clearRedo = false; break; } if (actions.Count > 0) { selectedBoard.UndoRedoMan.AddUndoBatch(actions); } if (clearRedo) { selectedBoard.UndoRedoMan.RedoList.Clear(); } }