示例#1
0
        /// <summary>
        /// Enabling undo/redo for changes to the strokes collection.
        /// </summary>
        void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
        {
            StrokeCollection added   = new StrokeCollection(e.Added);
            StrokeCollection removed = new StrokeCollection(e.Removed);

            CommandItem item = new StrokesAddedOrRemovedCI(_cmdStack, MyInkCanvas.EditingMode, added, removed, _editingOperationCount);

            _cmdStack.Enqueue(item);
        }
示例#2
0
        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);
        }