public UndoRedoStruct(BeforeModificationEventArgs e, UndoRedoAction Action) { Position = e.Position; Length = e.Text.Length; Text = e.Text; UndoRedoAction = Action; }
public override bool CanAppend(UndoRedoAction action) { EditPropertyAction castAction = action as EditPropertyAction; if (castAction == null) { return(false); } if (castAction.targetProperty != this.targetProperty) { return(false); } if (!castAction.targetObj.SequenceEqual(this.targetObj)) { return(false); } // If we're using an indexer, make sure both actions do and use the same indices if (castAction.targetIndices != null || this.targetIndices != null) { if (castAction.targetIndices == null || this.targetIndices == null) { return(false); } if (!castAction.targetIndices.SequenceEqual(this.targetIndices)) { return(false); } } return(true); }
public UndoRedoItem(object o, object oUndoRedoHandler, UndoRedoAction ura, object oData) { this.o = o; this.oUndoRedoHandler = oUndoRedoHandler; this.ura = ura; this.oData = oData; }
/// <summary> /// Execute a new action and add/merge it in the Undo stack /// </summary> /// <param name="action"></param> public void ExecAction(UndoRedoAction action) { if (action.Cancel) { return; } // Execute the redo action action.Redo(); // Retrieve the last action in the list, and check if we can merge actions if (m_undoActions.Count > 0 && m_undoActions.Peek().CanMerge(action)) { m_undoActions.Peek().Merge(action); } else { m_undoActions.Push(action); } if (CanRedo) { m_redoActions.Clear(); } OnUndoRedo?.Invoke(this, UndoManager.Action.Exec); }
public static void FillDropDownItem(ToolStripDropDownItem a_item, IEnumerable <UndoRedoAction> a_list, Func <UndoRedoAction, string> a_description, Action <UndoRedoAction> a_action) { ToolStripDropDownItem ddi = a_item as ToolStripDropDownItem; ddi.DropDown.Items.Clear(); foreach (UndoRedoAction action in a_list) { string text = a_description(action); if (text == null) { text = string.Empty; } ToolStripItem tti = ddi.DropDown.Items.Add(text); tti.Tag = action; tti.Click += (s, e) => { ToolStripDropDownItem item = s as ToolStripDropDownItem; UndoRedoAction item_action = item.Tag as UndoRedoAction; a_action(item_action); }; } }
private async Task Render(IPipelineBlock block, ImageContainer container = ImageContainer.Destination, UndoRedoAction action = UndoRedoAction.Undo) { View.SetCursor(CursorType.Wait); if ( !_pipeline .Register(block .Add <Bitmap>( (bmp) => RenderBlock(bmp, container, action) ) ) ) { throw new InvalidOperationException(Errors.Pipeline); } await _pipeline.AwaitResult().ConfigureAwait(true); if (container == ImageContainer.Source) { _cache.Reset(); } if (!_pipeline.Any()) { View.SetCursor(CursorType.Default); } }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); EditTilesetAutoTileItemAction castAction = action as EditTilesetAutoTileItemAction; if (performAction) { castAction.backupTileInput = this.backupTileInput; castAction.Do(); } // Copy the new actions tile input over to this one and adjust the masking this.tileInput.Count = Math.Max(this.tileInput.Count, castAction.tileInput.Count); this.tileInputMask.Count = this.tileInput.Count; for (int i = 0; i < castAction.tileInput.Count; i++) { if (!castAction.tileInputMask[i]) { continue; } this.tileInput[i] = castAction.tileInput[i]; this.tileInputMask[i] = true; } // Adjust the backup length to fit the new tile input length this.backupTileInput.Count = this.autoTile.TileInput.Count; }
private void Action_Executed(object sender, EventArgs e) { var ic = (InvertibleCommand)sender; // get the inverted command that represents the undo command UndoRedoAction undoAction = ic.undoRedoAction.GetInvertedUndoRedoAction(); Add(undoAction); }
public override bool CanAppend(UndoRedoAction action) { EditResourceAssetDataAction castAction = action as EditResourceAssetDataAction; if (castAction == null) return false; if (castAction.targetKey != this.targetKey) return false; if (!castAction.targetObj.SequenceEqual(this.targetObj)) return false; return true; }
public override bool CanAppend(UndoRedoAction action) { EditFieldAction castAction = action as EditFieldAction; if (castAction == null) return false; if (castAction.targetField != this.targetField) return false; if (!castAction.targetObj.SequenceEqual(this.targetObj)) return false; return true; }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); UndoRedoMacroAction castAction = action as UndoRedoMacroAction; for (int i = 0; i < this.macro.Length; i++) { this.macro[i].Append(castAction.macro[i], performAction); } }
/// <summary> /// Returns a command that inverts the action of this command. /// </summary> public InvertibleCommand GetInvertedCommand() { UndoRedoAction invertedUndoRedoAction = undoRedoAction.GetInvertedUndoRedoAction(); if (canExecute == null) { return(new InvertibleCommand(invertedUndoRedoAction)); } return(new InvertibleCommand(invertedUndoRedoAction, canInvertedExecute, canExecute)); }
public override bool CanAppend(UndoRedoAction action) { EditPropertyAction castAction = action as EditPropertyAction; if (castAction == null) return false; if (castAction.targetProperty != this.targetProperty) return false; if (!castAction.targetObj.SequenceEqual(this.targetObj)) return false; return true; }
public void ApplyDoUndo(Action _do, Action _undo, string _desc = "") { if (overrideName != null) { _desc = overrideName; } var action = new UndoRedoAction(_do, _undo, _desc); AddUndoRedoAction(action); }
private void RenderBlock(Bitmap bmp, ImageContainer to, UndoRedoAction action) { lock (_cache) { View.AddToUndoRedo(to, new Bitmap(View.GetImageCopy(to)), action); View.SetImageCopy(to, new Bitmap(bmp)); View.SetImage(to, new Bitmap(bmp)); View.SetImageCenter(to, bmp.Size); View.Refresh(to); View.ResetTrackBarValue(to); } }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); MoveCamViewObjAction moveAction = action as MoveCamViewObjAction; if (performAction) { moveAction.backupPos = this.backupPos; moveAction.Do(); } this.moveBy += moveAction.moveBy; }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); EditResourceAssetDataAction castAction = action as EditResourceAssetDataAction; if (performAction) { castAction.backupValue = this.backupValue; castAction.Do(); } this.targetValue = castAction.targetValue ?? this.targetValue; }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); EditFieldAction castAction = action as EditFieldAction; if (performAction) { castAction.backupValue = this.backupValue; castAction.Do(); } this.targetValue = castAction.targetValue ?? this.targetValue; }
public override int GetHashCode() { var hashCode = 742094758; hashCode = hashCode * -1521134295 + base.GetHashCode(); hashCode = hashCode * -1521134295 + UndoRedoAction.GetHashCode(); hashCode = hashCode * -1521134295 + Position.GetHashCode(); hashCode = hashCode * -1521134295 + Length.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Text); return(hashCode); }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); SetAtlasRectAction atlasAction = action as SetAtlasRectAction; if (performAction) { atlasAction.originalRect = this.originalRect; atlasAction.Do(); } this.rect = atlasAction.rect; }
public override bool CanAppend(UndoRedoAction action) { UndoRedoMacroAction castAction = action as UndoRedoMacroAction; if (castAction == null) return false; if (castAction.macro.Length != this.macro.Length) return false; for (int i = 0; i < this.macro.Length; i++) { if (!this.macro[i].CanAppend(castAction.macro[i])) return false; } return true; }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); ScaleCamViewObjAction moveAction = action as ScaleCamViewObjAction; if (performAction) { moveAction.backupPos = this.backupPos; moveAction.backupScale = this.backupScale; moveAction.Do(); } this.scaleBy *= moveAction.scaleBy; }
public override void Append(UndoRedoAction action, bool performAction) { base.Append(action, performAction); RotateCamViewObjAction moveAction = action as RotateCamViewObjAction; if (performAction) { moveAction.backupPos = this.backupPos; moveAction.backupAngle = this.backupAngle; moveAction.Do(); } this.turnBy += moveAction.turnBy; }
public override bool CanAppend(UndoRedoAction action) { EditTilesetTileInputAction castAction = action as EditTilesetTileInputAction; if (castAction == null) { return(false); } if (castAction.tileset != this.tileset) { return(false); } return(true); }
public override bool CanAppend(UndoRedoAction action) { CamViewObjAction castAction = action as CamViewObjAction; if (castAction == null) { return(false); } if (castAction.postPerform != this.postPerform) { return(false); } return(castAction.targetObj.SetEqual(this.targetObj)); }
public bool TryMergeWith(UndoRedoAction nextAction) { if (Position == nextAction.Position) { if (NewText.Length >= nextAction.OldText.Length) { if (!NewText.StartsWith(nextAction.OldText)) return false; NewText = nextAction.NewText + NewText.Substring(nextAction.OldText.Length); } else { if (!nextAction.OldText.StartsWith(NewText)) return false; OldText = OldText + nextAction.OldText.Substring(NewText.Length); NewText = nextAction.NewText; } return true; } int nextEnd = nextAction.Position + nextAction.OldText.Length; if (Position == nextEnd) { Position = nextAction.Position; OldText = nextAction.OldText + OldText; NewText = nextAction.NewText + NewText; return true; } int end = Position + NewText.Length; if (end == nextAction.Position) { OldText += nextAction.OldText; NewText += nextAction.NewText; return true; } if (end == nextEnd) { if (NewText.Length >= nextAction.OldText.Length) { if (!NewText.EndsWith(nextAction.OldText)) return false; NewText = NewText.Substring(0, NewText.Length - nextAction.OldText.Length) + nextAction.NewText; } else { if (!nextAction.OldText.EndsWith(NewText)) return false; Position = nextAction.Position; OldText = nextAction.OldText.Substring(0, nextAction.OldText.Length - NewText.Length) + OldText; NewText = nextAction.NewText; } return true; } return false; }
public override bool CanAppend(UndoRedoAction action) { EditTilesetAutoTileItemAction castAction = action as EditTilesetAutoTileItemAction; if (castAction == null) { return(false); } if (castAction.autoTile != this.autoTile) { return(false); } return(true); }
public override bool CanAppend(UndoRedoAction action) { SetAtlasAction atlasAction = action as SetAtlasAction; if (atlasAction == null) { return(false); } if (!atlasAction.pixmaps.SetEqual(this.pixmaps)) { return(false); } return(true); }
public override bool CanAppend(UndoRedoAction action) { EditPropertyAction castAction = action as EditPropertyAction; if (castAction == null) return false; if (castAction.targetProperty != this.targetProperty) return false; if (!castAction.targetObj.SequenceEqual(this.targetObj)) return false; // If we're using an indexer, make sure both actions do and use the same indices if (castAction.targetIndices != null || this.targetIndices != null) { if (castAction.targetIndices == null || this.targetIndices == null) return false; if (!castAction.targetIndices.SequenceEqual(this.targetIndices)) return false; } return true; }
public override bool CanAppend(UndoRedoAction action) { SetAtlasRectAction atlasAction = action as SetAtlasRectAction; if (atlasAction == null) { return(false); } if (atlasAction.pixmap != this.pixmap) { return(false); } if (atlasAction.atlasIndex != this.atlasIndex) { return(false); } return(true); }
public override bool CanAppend(UndoRedoAction action) { EditResourceAssetDataAction castAction = action as EditResourceAssetDataAction; if (castAction == null) { return(false); } if (castAction.targetKey != this.targetKey) { return(false); } if (!castAction.targetObj.SequenceEqual(this.targetObj)) { return(false); } return(true); }
public override bool CanAppend(UndoRedoAction action) { EditPropertyAction castAction = action as EditPropertyAction; if (castAction == null) { return(false); } if (castAction.targetProperty != this.targetProperty) { return(false); } if (!castAction.targetObj.SequenceEqual(this.targetObj)) { return(false); } return(true); }
public override bool CanAppend(UndoRedoAction action) { UndoRedoMacroAction castAction = action as UndoRedoMacroAction; if (castAction == null) { return(false); } if (castAction.macro.Length != this.macro.Length) { return(false); } for (int i = 0; i < this.macro.Length; i++) { if (!this.macro[i].CanAppend(castAction.macro[i])) { return(false); } } return(true); }
public override bool CanAppend(UndoRedoAction action) { if (this.type != EditTilemapActionType.DrawTile) { return(false); } EditTilemapAction editAction = action as EditTilemapAction; if (editAction == null) { return(false); } if (editAction.tilemap != this.tilemap) { return(false); } if (editAction.type != this.type) { return(false); } return(true); }
public override bool CanAppend(UndoRedoAction action) { return(action is ScaleCamViewObjAction && base.CanAppend(action)); }
private void AddAction(UndoRedoAction action) { if (pendingActions.Count > 0) { pendingActions.Peek().Add(action); return; } Debug.WriteLine(string.Format("Action: Pos: {0}, Old: {1}, New: {2}", action.Position, action.OldText.Length, action.NewText.Length)); if (currentActionNode == null) actions.Clear(); else while (currentActionNode.Next != null) actions.Remove(currentActionNode.Next); actions.AddLast(action); if (maxUndoLevels > 0 && actions.Count > maxUndoLevels) { if (unmodifiedNodeSet) if (unmodifiedNode == actions.First) unmodifiedNode = null; else if (unmodifiedNode == null) unmodifiedNodeSet = false; actions.RemoveFirst(); } currentActionNode = actions.Last; OnChanged(EventArgs.Empty); }
private InvertibleCommand(UndoRedoAction undoRedoAction, Func <bool> canExecute, Func <bool> canInvertedExecute) : base(undoRedoAction.Action, canExecute) { this.undoRedoAction = undoRedoAction; this.canExecute = canExecute ?? throw new ArgumentNullException(nameof(canExecute)); this.canInvertedExecute = canInvertedExecute ?? throw new ArgumentNullException(nameof(canInvertedExecute)); }