Skip to content

Commit

Permalink
[WIP] 修改撤回行为
Browse files Browse the repository at this point in the history
  • Loading branch information
Raspberry-Monster committed Mar 24, 2024
1 parent 6448bfe commit df9c509
Show file tree
Hide file tree
Showing 3 changed files with 209 additions and 587 deletions.
19 changes: 14 additions & 5 deletions Ink Canvas/Helpers/TimeMachine.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows.Ink;
using System.Windows.Media;

namespace Ink_Canvas.Helpers
{
Expand Down Expand Up @@ -42,16 +44,16 @@ public void CommitStrokeShapeHistory(StrokeCollection strokeToBeReplaced, Stroke
NotifyUndoRedoState();
}

public void CommitStrokeManipulationHistory(StrokeCollection strokeToBeReplaced, StrokeCollection generatedStroke)
public void CommitStrokeManipulationHistory(StrokeCollection manipulatedStrokes, Matrix matrix)
{
if (_currentIndex + 1 < _currentStrokeHistory.Count)
{
_currentStrokeHistory.RemoveRange(_currentIndex + 1, (_currentStrokeHistory.Count - 1) - _currentIndex);
}
_currentStrokeHistory.Add(new TimeMachineHistory(generatedStroke,
TimeMachineHistoryType.Manipulation,
false,
strokeToBeReplaced));
_currentStrokeHistory.Add(
new TimeMachineHistory(manipulatedStrokes,
TimeMachineHistoryType.Manipulation,
matrix));
_currentIndex = _currentStrokeHistory.Count - 1;
NotifyUndoRedoState();
}
Expand Down Expand Up @@ -122,6 +124,7 @@ public class TimeMachineHistory
public bool StrokeHasBeenCleared;
public StrokeCollection CurrentStroke;
public StrokeCollection ReplacedStroke;
public Matrix ManipulationHistory;
public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool strokeHasBeenCleared)
{
CommitType = commitType;
Expand All @@ -136,6 +139,12 @@ public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType
StrokeHasBeenCleared = strokeHasBeenCleared;
ReplacedStroke = replacedStroke;
}
public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, Matrix matrix)
{
CommitType=commitType;
CurrentStroke = currentStroke;
ManipulationHistory = matrix;
}
}

public enum TimeMachineHistoryType
Expand Down
1 change: 0 additions & 1 deletion Ink Canvas/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
ManipulationDelta="Main_Grid_ManipulationDelta"
ManipulationCompleted="Main_Grid_ManipulationCompleted"
ManipulationInertiaStarting="inkCanvas_ManipulationInertiaStarting"
ManipulationStarted="inkCanvas_ManipulationStarted"
IsManipulationEnabled="True"
EditingModeChanged="inkCanvas_EditingModeChanged"
PreviewTouchDown="inkCanvas_PreviewTouchDown"
Expand Down
Loading

0 comments on commit df9c509

Please sign in to comment.