public async void AddColumn(bool addRight, int index = -1, IDominoShape colorReference = null) { var selected = GetSelectedDominoes(); try { if (selected.Count > 0 || index != -1) { int selDomino = selected.Count > 0 ? selected.First() : index; int color = (colorReference ?? dominoTransfer[selDomino]).Color; if (CurrentProject is IRowColumnAddableDeletable) { AddColumns addRows = new AddColumns((CurrentProject as IRowColumnAddableDeletable), selDomino, 1, color, addRight); ClearCanvas(); ExecuteOperation(addRows); RecreateCanvasViewModel(); SelectionTool.Select(addRows.added_indizes, true); UpdateUIElements(); DisplaySettingsTool.SliceImage(); } else { await Errorhandler.RaiseMessage(_("Adding columns is not supported in this project."), _("Add Row"), Errorhandler.MessageType.Warning); } } } catch (InvalidOperationException ex) { await Errorhandler.RaiseMessage(ex.Message, _("Error"), Errorhandler.MessageType.Error); } }
public void UndoInternal(bool IncludeSelectionOperation = false) { if (undoStack.Count == 0) { return; } PostFilter undoFilter; do { undoFilter = undoStack.Pop(); redoStack.Push(undoFilter); undoFilter.Undo(); } while ((!IncludeSelectionOperation && (undoFilter is SelectionOperation)) && (undoStack.Count != 0)); if (!(undoFilter is EditingActivatedOperation || undoFilter is SelectionOperation || undoFilter is SetColorOperation)) { ClearCanvas(false); RecreateCanvasViewModel(); UpdateUIElements(); DisplaySettingsTool.SliceImage(); if (undoStack.Count == 0) { UnsavedChanges = false; } } else { UpdateUIElements(); } SelectedTool.OnUndo(); }
public void RedoInternal(bool IncludeSelectionOperation = false) { if (redoStack.Count == 0) { return; } PostFilter redoFilter; do { redoFilter = redoStack.Pop(); undoStack.Push(redoFilter); redoFilter.Apply(); } while ((!IncludeSelectionOperation && redoFilter is SelectionOperation) && redoStack.Count != 0); if (!(redoFilter is EditingDeactivatedOperation || redoFilter is SelectionOperation || redoFilter is SetColorOperation)) { ClearCanvas(false); RecreateCanvasViewModel(); UpdateUIElements(); DisplaySettingsTool.SliceImage(); } else { UpdateUIElements(); } SelectedTool.OnRedo(); }
private void RemoveSelRows() { try { if (CurrentProject is IRowColumnAddableDeletable) { if (selectedDominoes.Count > 0) { DeleteRows deleteRows = new DeleteRows((CurrentProject as IRowColumnAddableDeletable), selectedDominoes.ToArray()); ClearCanvas(); ExecuteOperation(deleteRows); DisplaySettingsTool.ResetCanvas(); } } else { Errorhandler.RaiseMessage("Could not remove a row in this project.", "Remove Row", Errorhandler.MessageType.Warning); } } catch (InvalidOperationException ex) { Errorhandler.RaiseMessage(ex.Message, "Error", Errorhandler.MessageType.Error); } }
private void AddColumn(bool addRight) { try { if (selectedDominoes.Count > 0) { int selDomino = selectedDominoes.First(); if (CurrentProject is IRowColumnAddableDeletable) { AddColumns addRows = new AddColumns((CurrentProject as IRowColumnAddableDeletable), selDomino, 1, dominoTransfer[selDomino].color, addRight); ClearCanvas(); ExecuteOperation(addRows); DisplaySettingsTool.ResetCanvas(); SelectionTool.Select(addRows.added_indizes, true); UpdateUIElements(); } else { Errorhandler.RaiseMessage("Could not add a row in this project.", "Add Row", Errorhandler.MessageType.Warning); } } } catch (InvalidOperationException ex) { Errorhandler.RaiseMessage(ex.Message, "Error", Errorhandler.MessageType.Error); } }
private void Paste() { try { if (!(CurrentProject is ICopyPasteable)) { Errorhandler.RaiseMessage("Could not paste in this project.", "Paste", Errorhandler.MessageType.Warning); } if (selectedDominoes.Count == 0) { return; } int pasteindex = selectedDominoes.First(); RemoveFromSelectedDominoes(pasteindex); ClearFullSelection(true); PasteFilter paste = new PasteFilter(CurrentProject as ICopyPasteable, startindex, toCopy.ToArray(), pasteindex); paste.Apply(); undoStack.Push(paste); DisplaySettingsTool.ClearPastePositions(); UpdateUIElements(); } catch (InvalidOperationException ex) { Errorhandler.RaiseMessage(ex.Message, "Error", Errorhandler.MessageType.Error); } }
private void Copy() { if (!(CurrentProject is ICopyPasteable)) { Errorhandler.RaiseMessage("Could not copy in this project.", "Copy", Errorhandler.MessageType.Warning); } DisplaySettingsTool.ClearPastePositions(); if (selectedDominoes.Count < 0) { Errorhandler.RaiseMessage("Nothing to copy!", "No selection", Errorhandler.MessageType.Error); return; } toCopy = new List <int>(selectedDominoes); startindex = selectedDominoes.Min(); ClearFullSelection(true); try { int[] validPositions = ((ICopyPasteable)this.CurrentProject).GetValidPastePositions(startindex); DisplaySettingsTool.HighlightPastePositions(validPositions); } catch (InvalidOperationException ex) { Errorhandler.RaiseMessage(ex.Message, "Error", Errorhandler.MessageType.Error); } UpdateUIElements(); }
internal override void Close() { base.Close(); DisplaySettingsTool.DeleteImage(); ClearCanvas(); }
public void RemoveFromSelectedDominoes(int i) { if (DisplaySettingsTool.DeSelectDominoVisual(i)) { selectedDominoes.Remove(i); selectedColors[dominoTransfer[i].color]--; } }
public void AddToSelectedDominoes(int i) { if (DisplaySettingsTool.SelectDominoVisual(i)) { selectedDominoes.Add(i); selectedColors[dominoTransfer[i].color]++; } }
internal void ClearCanvas(bool ClearSelection = true) { DisplaySettingsTool.ClearPastePositions(); if (ClearSelection) { ClearFullSelection(true); } if (DisplaySettingsTool.DominoProject != null) { DisplaySettingsTool.RemoveStones(); } }
internal void ClearFullSelection(bool undoable = false) { if (undoable) { SelectionTool.Select(selectedDominoes, false); } else { foreach (int i in selectedDominoes.ToArray()) { RemoveFromSelectedDominoes(i); } while (undoStack.Count > 0 && undoStack.Peek() is SelectionOperation) { undoStack.Pop(); } } selectedColors = new int[CurrentProject.colors.Length]; DisplaySettingsTool.Redraw(); SelectionTool.CurrentSelectionDomain.ResetSelectionArea(); RefreshColorAmount(); }
public async void RemoveSelColumns(int index = -1) { var selected = GetSelectedDominoes(); try { if (CurrentProject is IRowColumnAddableDeletable) { int[] deletionIndices = null; if (index != -1) { deletionIndices = new int[] { index }; } if (selected.Count > 0) { deletionIndices = selected.ToArray(); } if (deletionIndices != null) { DeleteColumns deleteColumns = new DeleteColumns((CurrentProject as IRowColumnAddableDeletable), deletionIndices); ClearCanvas(); ExecuteOperation(deleteColumns); RecreateCanvasViewModel(); DisplaySettingsTool.SliceImage(); } } else { await Errorhandler.RaiseMessage(_("Removing columns is not supported in this project."), _("Remove Column"), Errorhandler.MessageType.Warning); } } catch (InvalidOperationException ex) { await Errorhandler.RaiseMessage(ex.Message, _("Error"), Errorhandler.MessageType.Error); } }
public bool IsSelected(int i) { return(DisplaySettingsTool.IsSelected(i)); }
public void UpdateUIElements() { RefreshColorAmount(); DisplaySettingsTool.Redraw(); RefreshSizeLabels(); }