From c0b33140ab05377d0d47ba3aa147b2af158e299d Mon Sep 17 00:00:00 2001 From: Raspberry-Monster Date: Wed, 19 Apr 2023 22:34:49 +0800 Subject: [PATCH] =?UTF-8?q?[Typo/TimeMachine]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=8F=98=E9=87=8F=E5=91=BD=E5=90=8D=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=92=A4=E5=9B=9E=E6=93=A6=E9=99=A4=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/TimeMachine.cs | 28 ++++----- Ink Canvas/MainWindow.xaml | 3 +- Ink Canvas/MainWindow.xaml.cs | 94 ++++++++++++++++++------------- 3 files changed, 69 insertions(+), 56 deletions(-) diff --git a/Ink Canvas/Helpers/TimeMachine.cs b/Ink Canvas/Helpers/TimeMachine.cs index 22e004d..5bd726d 100644 --- a/Ink Canvas/Helpers/TimeMachine.cs +++ b/Ink Canvas/Helpers/TimeMachine.cs @@ -51,13 +51,7 @@ namespace Ink_Canvas.Helpers { _currentStrokeHistory.RemoveRange(_currentIndex +1 , (_currentStrokeHistory.Count - 1) - _currentIndex); } - var col = new StrokeCollection(); - foreach (var stroke1 in stroke) - { - col.Add(stroke1); - } - - _currentStrokeHistory.Add(new TimeMachineHistory(col, TimeMachineHistoryType.Clear, true)); + _currentStrokeHistory.Add(new TimeMachineHistory(stroke, TimeMachineHistoryType.Clear, true)); _currentIndex = _currentStrokeHistory.Count - 1; OnUndoStateChanged?.Invoke(true); OnRedoStateChanged?.Invoke(false); @@ -73,7 +67,7 @@ namespace Ink_Canvas.Helpers public TimeMachineHistory Undo() { var item = _currentStrokeHistory[_currentIndex]; - item.IsReversed = !item.IsReversed; + item.StrokeHasBeenCleared = !item.StrokeHasBeenCleared; _currentIndex--; OnUndoStateChanged?.Invoke(_currentIndex > -1); OnRedoStateChanged?.Invoke(_currentStrokeHistory.Count - _currentIndex - 1 > 0); @@ -83,7 +77,7 @@ namespace Ink_Canvas.Helpers public TimeMachineHistory Redo() { var item = _currentStrokeHistory[++_currentIndex]; - item.IsReversed = !item.IsReversed; + item.StrokeHasBeenCleared = !item.StrokeHasBeenCleared; OnUndoStateChanged?.Invoke(_currentIndex > -1); if (_currentIndex != -1) OnRedoStateChanged?.Invoke(_currentStrokeHistory.Count - _currentIndex - 1 > 0); return item; @@ -111,22 +105,22 @@ namespace Ink_Canvas.Helpers public class TimeMachineHistory { public TimeMachineHistoryType CommitType; - public bool IsReversed; + public bool StrokeHasBeenCleared; public StrokeCollection CurrentStroke; - public StrokeCollection ShapeRecognitionReplacedStroke; - public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool isReversed) + public StrokeCollection ReplacedStroke; + public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool strokeHasBeenCleared) { CommitType = commitType; CurrentStroke = currentStroke; - IsReversed = isReversed; - ShapeRecognitionReplacedStroke = null; + StrokeHasBeenCleared = strokeHasBeenCleared; + ReplacedStroke = null; } - public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool isReversed , StrokeCollection shapeRecognitionReplacedStroke) + public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool strokeHasBeenCleared , StrokeCollection replacedStroke) { CommitType = commitType; CurrentStroke = currentStroke; - IsReversed = isReversed; - ShapeRecognitionReplacedStroke = shapeRecognitionReplacedStroke; + StrokeHasBeenCleared = strokeHasBeenCleared; + ReplacedStroke = replacedStroke; } } diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index b227b22..16dc481 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -106,7 +106,8 @@ MouseUp="inkCanvas_MouseUp" ManipulationStarting="inkCanvas_ManipulationStarting" SelectionChanged="inkCanvas_SelectionChanged" - StrokeCollected="inkCanvas_StrokeCollected"> + StrokeCollected="inkCanvas_StrokeCollected" + StrokeErasing="InkCanvas_OnStrokeErasing">