public override bool Merge(CommandItem newitem) { SelectionMovedOrResizedCI newitemx = newitem as SelectionMovedOrResizedCI; // Ensure items are of the same type. if (newitemx == null || newitemx._editingOperationCount != _editingOperationCount || !StrokeCollectionsAreEqual(newitemx._selection, _selection)) { return(false); } // Keep former oldrect, latter newrect. _newrect = newitemx._newrect; return(true); }
public override bool Merge(CommandItem newitem) { SelectionColorOrWidthCI newitemx = newitem as SelectionColorOrWidthCI; // Ensure items are of the same type. if (newitemx == null || newitemx._editingOperationCount != _editingOperationCount) { return(false); } _old_foreground = newitemx._old_foreground; _new_foreground = newitemx._new_foreground; _old_background = newitemx._old_background; _new_background = newitemx._new_background; _old_width = newitemx._old_width; _new_width = newitemx._new_width; return(true); }
public override bool Merge(CommandItem newitem) { StrokesAddedOrRemovedCI newitemx = newitem as StrokesAddedOrRemovedCI; if (newitemx == null || newitemx._editingMode != _editingMode || newitemx._editingOperationCount != _editingOperationCount) { return(false); } // We only implement merging for repeated point-erase operations. if (_editingMode != InkCanvasEditingMode.EraseByPoint) { return(false); } if (newitemx._editingMode != InkCanvasEditingMode.EraseByPoint) { return(false); } // Note: possible for point-erase to have hit intersection of >1 strokes! // For each newly hit stroke, merge results into this command item. foreach (Stroke doomed in newitemx._removed) { if (_added.Contains(doomed)) { _added.Remove(doomed); } else { _removed.Add(doomed); } } _added.Add(newitemx._added); return(true); }
/// <summary> /// Take the top item off the command stack. /// </summary> public void Redo() { if (!CanRedo) { return; } CommandItem item = _redoStack.Pop(); // Invoke the redo operation, with change-tracking temporarily suspended. _disableChangeTracking = true; try { item.Redo(); } finally { _disableChangeTracking = false; } //place this item on the undo stack _undoStack.Push(item); }
public override bool Merge(CommandItem newitem) { StrokesAddedOrRemovedCI newitemx = newitem as StrokesAddedOrRemovedCI; if (newitemx == null || newitemx._editingMode != _editingMode || newitemx._editingOperationCount != _editingOperationCount) { return false; } // We only implement merging for repeated point-erase operations. if (_editingMode != InkCanvasEditingMode.EraseByPoint) return false; if (newitemx._editingMode != InkCanvasEditingMode.EraseByPoint) return false; // Note: possible for point-erase to have hit intersection of >1 strokes! // For each newly hit stroke, merge results into this command item. foreach (Stroke doomed in newitemx._removed) { if (_added.Contains(doomed)) { _added.Remove(doomed); } else { _removed.Add(doomed); } } _added.Add(newitemx._added); return true; }
// Allows multiple subsequent commands of the same type to roll-up into one // logical undoable/redoable command -- return false if newitem is incompatable. public abstract bool Merge(CommandItem newitem);
public override bool Merge(CommandItem newitem) { SelectionMovedOrResizedCI newitemx = newitem as SelectionMovedOrResizedCI; // Ensure items are of the same type. if (newitemx == null || newitemx._editingOperationCount != _editingOperationCount || !StrokeCollectionsAreEqual(newitemx._selection, _selection)) { return false; } // Keep former oldrect, latter newrect. _newrect = newitemx._newrect; return true; }
public override bool Merge(CommandItem newitem) { SelectionColorOrWidthCI newitemx = newitem as SelectionColorOrWidthCI; // Ensure items are of the same type. if (newitemx == null || newitemx._editingOperationCount != _editingOperationCount) { return false; } _old_foreground = newitemx._old_foreground; _new_foreground = newitemx._new_foreground; _old_background = newitemx._old_background; _new_background = newitemx._new_background; _old_width = newitemx._old_width; _new_width = newitemx._new_width; return true; }
/// <summary> /// Add a command item to the stack. /// </summary> /// <param name="item"></param> public void Enqueue(CommandItem item) { if (item == null) { return; } // Ensure we don't enqueue new items if we're being changed programmatically. if (_disableChangeTracking) { return; } // Check to see if this new item can be merged with previous. bool merged = false; if (_undoStack.Count > 0) { CommandItem prev = _undoStack.Peek(); merged = prev.Merge(item); } // If not, append the new command item if (!merged) { _undoStack.Push(item); } //clear the redo stack if (_redoStack.Count > 0) { _redoStack.Clear(); } }