[Clean UP/TimeMachine][WIP] 支持撤回EraseByPoint(此版本切换页面无法保留记录)
This commit is contained in:
parent
c0b33140ab
commit
5ccf315efe
@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Ink;
|
using System.Windows.Ink;
|
||||||
|
|
||||||
namespace Ink_Canvas.Helpers
|
namespace Ink_Canvas.Helpers
|
||||||
@ -22,7 +21,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
||||||
{
|
{
|
||||||
_currentStrokeHistory.RemoveRange(_currentIndex +1 , (_currentStrokeHistory.Count - 1) - _currentIndex);
|
_currentStrokeHistory.RemoveRange(_currentIndex + 1, (_currentStrokeHistory.Count - 1) - _currentIndex);
|
||||||
}
|
}
|
||||||
_currentStrokeHistory.Add(new TimeMachineHistory(stroke, TimeMachineHistoryType.UserInput, false));
|
_currentStrokeHistory.Add(new TimeMachineHistory(stroke, TimeMachineHistoryType.UserInput, false));
|
||||||
_currentIndex = _currentStrokeHistory.Count - 1;
|
_currentIndex = _currentStrokeHistory.Count - 1;
|
||||||
@ -34,7 +33,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
||||||
{
|
{
|
||||||
_currentStrokeHistory.RemoveRange(_currentIndex +1 , (_currentStrokeHistory.Count - 1) - _currentIndex);
|
_currentStrokeHistory.RemoveRange(_currentIndex + 1, (_currentStrokeHistory.Count - 1) - _currentIndex);
|
||||||
}
|
}
|
||||||
_currentStrokeHistory.Add(new TimeMachineHistory(generatedStroke,
|
_currentStrokeHistory.Add(new TimeMachineHistory(generatedStroke,
|
||||||
TimeMachineHistoryType.ShapeRecognition,
|
TimeMachineHistoryType.ShapeRecognition,
|
||||||
@ -45,13 +44,13 @@ namespace Ink_Canvas.Helpers
|
|||||||
OnRedoStateChanged?.Invoke(false);
|
OnRedoStateChanged?.Invoke(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CommitStrokeEraseHistory(StrokeCollection stroke)
|
public void CommitStrokeEraseHistory(StrokeCollection stroke, StrokeCollection sourceStroke = null)
|
||||||
{
|
{
|
||||||
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
||||||
{
|
{
|
||||||
_currentStrokeHistory.RemoveRange(_currentIndex +1 , (_currentStrokeHistory.Count - 1) - _currentIndex);
|
_currentStrokeHistory.RemoveRange(_currentIndex + 1, (_currentStrokeHistory.Count - 1) - _currentIndex);
|
||||||
}
|
}
|
||||||
_currentStrokeHistory.Add(new TimeMachineHistory(stroke, TimeMachineHistoryType.Clear, true));
|
_currentStrokeHistory.Add(new TimeMachineHistory(stroke, TimeMachineHistoryType.Clear, true, sourceStroke));
|
||||||
_currentIndex = _currentStrokeHistory.Count - 1;
|
_currentIndex = _currentStrokeHistory.Count - 1;
|
||||||
OnUndoStateChanged?.Invoke(true);
|
OnUndoStateChanged?.Invoke(true);
|
||||||
OnRedoStateChanged?.Invoke(false);
|
OnRedoStateChanged?.Invoke(false);
|
||||||
@ -86,7 +85,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
{
|
{
|
||||||
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
if (_currentIndex + 1 < _currentStrokeHistory.Count)
|
||||||
{
|
{
|
||||||
_currentStrokeHistory.RemoveRange(_currentIndex +1 , (_currentStrokeHistory.Count - 1) - _currentIndex);
|
_currentStrokeHistory.RemoveRange(_currentIndex + 1, (_currentStrokeHistory.Count - 1) - _currentIndex);
|
||||||
}
|
}
|
||||||
return _currentStrokeHistory.ToArray();
|
return _currentStrokeHistory.ToArray();
|
||||||
}
|
}
|
||||||
@ -115,7 +114,7 @@ namespace Ink_Canvas.Helpers
|
|||||||
StrokeHasBeenCleared = strokeHasBeenCleared;
|
StrokeHasBeenCleared = strokeHasBeenCleared;
|
||||||
ReplacedStroke = null;
|
ReplacedStroke = null;
|
||||||
}
|
}
|
||||||
public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool strokeHasBeenCleared , StrokeCollection replacedStroke)
|
public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool strokeHasBeenCleared, StrokeCollection replacedStroke)
|
||||||
{
|
{
|
||||||
CommitType = commitType;
|
CommitType = commitType;
|
||||||
CurrentStroke = currentStroke;
|
CurrentStroke = currentStroke;
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
ManipulationStarting="inkCanvas_ManipulationStarting"
|
ManipulationStarting="inkCanvas_ManipulationStarting"
|
||||||
SelectionChanged="inkCanvas_SelectionChanged"
|
SelectionChanged="inkCanvas_SelectionChanged"
|
||||||
StrokeCollected="inkCanvas_StrokeCollected"
|
StrokeCollected="inkCanvas_StrokeCollected"
|
||||||
StrokeErasing="InkCanvas_OnStrokeErasing">
|
>
|
||||||
<!--<InkCanvas.DefaultDrawingAttributes>
|
<!--<InkCanvas.DefaultDrawingAttributes>
|
||||||
<DrawingAttributes StylusTip="Ellipse" Height="8" Width="4" IgnorePressure="False" FitToCurve="True" >
|
<DrawingAttributes StylusTip="Ellipse" Height="8" Width="4" IgnorePressure="False" FitToCurve="True" >
|
||||||
<DrawingAttributes.StylusTipTransform>
|
<DrawingAttributes.StylusTipTransform>
|
||||||
|
@ -14,7 +14,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -82,10 +81,9 @@ namespace Ink_Canvas
|
|||||||
InitTimers();
|
InitTimers();
|
||||||
timeMachine.OnRedoStateChanged += TimeMachine_OnRedoStateChanged;
|
timeMachine.OnRedoStateChanged += TimeMachine_OnRedoStateChanged;
|
||||||
timeMachine.OnUndoStateChanged += TimeMachine_OnUndoStateChanged;
|
timeMachine.OnUndoStateChanged += TimeMachine_OnUndoStateChanged;
|
||||||
|
inkCanvas.Strokes.StrokesChanged += StrokesOnStrokesChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Timer
|
#region Timer
|
||||||
@ -165,7 +163,6 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
//ApplicationGesture lastApplicationGesture = ApplicationGesture.AllGestures;
|
//ApplicationGesture lastApplicationGesture = ApplicationGesture.AllGestures;
|
||||||
DateTime lastGestureTime = DateTime.Now;
|
DateTime lastGestureTime = DateTime.Now;
|
||||||
private void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e)
|
private void InkCanvas_Gesture(object sender, InkCanvasGestureEventArgs e)
|
||||||
@ -302,7 +299,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private void KeyCapture(object sender, ExecutedRoutedEventArgs e)
|
private void KeyCapture(object sender, ExecutedRoutedEventArgs e)
|
||||||
{
|
{
|
||||||
BtnScreenshot_Click(sender,e);
|
BtnScreenshot_Click(sender, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void KeyDrawLine(object sender, ExecutedRoutedEventArgs e)
|
private void KeyDrawLine(object sender, ExecutedRoutedEventArgs e)
|
||||||
@ -319,7 +316,13 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
#region TimeMachine
|
#region TimeMachine
|
||||||
|
|
||||||
public TimeMachine timeMachine= new TimeMachine();
|
private bool IsCommitingByCode = false;
|
||||||
|
private bool IsEraseByShapeRecognition = false;
|
||||||
|
private bool IsClearingCanvas = false;
|
||||||
|
private bool IsEraseByPoint => inkCanvas.EditingMode == InkCanvasEditingMode.EraseByPoint;
|
||||||
|
private StrokeCollection ReplacedStroke;
|
||||||
|
private StrokeCollection AddedStroke;
|
||||||
|
private TimeMachine timeMachine = new TimeMachine();
|
||||||
private void TimeMachine_OnUndoStateChanged(bool status)
|
private void TimeMachine_OnUndoStateChanged(bool status)
|
||||||
{
|
{
|
||||||
var result = status ? Visibility.Visible : Visibility.Collapsed;
|
var result = status ? Visibility.Visible : Visibility.Collapsed;
|
||||||
@ -333,6 +336,50 @@ namespace Ink_Canvas
|
|||||||
BtnRedo.Visibility = result;
|
BtnRedo.Visibility = result;
|
||||||
BtnRedo.IsEnabled = status;
|
BtnRedo.IsEnabled = status;
|
||||||
}
|
}
|
||||||
|
private void StrokesOnStrokesChanged(object sender, StrokeCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (IsCommitingByCode) return;
|
||||||
|
if (e.Added.Count != 0 && e.Removed.Count != 0)
|
||||||
|
{
|
||||||
|
if (IsEraseByPoint)
|
||||||
|
{
|
||||||
|
if (AddedStroke == null) AddedStroke = new StrokeCollection();
|
||||||
|
if (ReplacedStroke == null) ReplacedStroke = new StrokeCollection();
|
||||||
|
AddedStroke.Add(e.Added);
|
||||||
|
ReplacedStroke.Add(e.Removed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (e.Added.Count != 0)
|
||||||
|
{
|
||||||
|
if (IsEraseByShapeRecognition)
|
||||||
|
{
|
||||||
|
timeMachine.CommitStrokeShapeHistory(ReplacedStroke, e.Added);
|
||||||
|
ReplacedStroke = null;
|
||||||
|
IsEraseByShapeRecognition = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timeMachine.CommitStrokeUserInputHistory(e.Added);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.Removed.Count != 0)
|
||||||
|
{
|
||||||
|
if (IsEraseByShapeRecognition)
|
||||||
|
{
|
||||||
|
ReplacedStroke = e.Removed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!IsEraseByPoint || IsClearingCanvas)
|
||||||
|
{
|
||||||
|
timeMachine.CommitStrokeEraseHistory(e.Removed);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -820,7 +867,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
BtnSwitchTheme.Content = "深色";
|
BtnSwitchTheme.Content = "深色";
|
||||||
}
|
}
|
||||||
BtnSwitchTheme_Click(null , null);
|
BtnSwitchTheme_Click(null, null);
|
||||||
if (Settings.Automation.IsAutoSaveScreenShotInPowerPoint)
|
if (Settings.Automation.IsAutoSaveScreenShotInPowerPoint)
|
||||||
{
|
{
|
||||||
ToggleSwitchAutoSaveScreenShotInPowerPoint.IsOn = true;
|
ToggleSwitchAutoSaveScreenShotInPowerPoint.IsOn = true;
|
||||||
@ -1802,11 +1849,6 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void InkCanvas_OnStrokeErasing(object sender, InkCanvasStrokeErasingEventArgs e)
|
|
||||||
{
|
|
||||||
_previousIsErasing = true;
|
|
||||||
_erasedStrokeCollection.Add(e.Stroke);
|
|
||||||
}
|
|
||||||
private void inkCanvas_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
|
private void inkCanvas_ManipulationStarting(object sender, ManipulationStartingEventArgs e)
|
||||||
{
|
{
|
||||||
e.Mode = ManipulationModes.All;
|
e.Mode = ManipulationModes.All;
|
||||||
@ -2830,7 +2872,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
BtnSwitchTheme.Content = "深色";
|
BtnSwitchTheme.Content = "深色";
|
||||||
}
|
}
|
||||||
BtnSwitchTheme_Click(sender , e);
|
BtnSwitchTheme_Click(sender, e);
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3054,6 +3096,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
private void BtnUndo_Click(object sender, RoutedEventArgs e)
|
private void BtnUndo_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
IsCommitingByCode = true;
|
||||||
var item = timeMachine.Undo();
|
var item = timeMachine.Undo();
|
||||||
if (item.CommitType == TimeMachineHistoryType.UserInput)
|
if (item.CommitType == TimeMachineHistoryType.UserInput)
|
||||||
{
|
{
|
||||||
@ -3104,29 +3147,51 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(item.CommitType == TimeMachineHistoryType.Clear)
|
else if (item.CommitType == TimeMachineHistoryType.Clear)
|
||||||
{
|
{
|
||||||
if (!item.StrokeHasBeenCleared)
|
if (!item.StrokeHasBeenCleared)
|
||||||
{
|
{
|
||||||
foreach (var strokes in item.CurrentStroke)
|
if (item.CurrentStroke != null)
|
||||||
{
|
{
|
||||||
if (!inkCanvas.Strokes.Contains(strokes))
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
inkCanvas.Strokes.Add(strokes);
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Add(currentStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Remove(replacedStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var strokes in item.CurrentStroke)
|
if (item.CurrentStroke != null)
|
||||||
{
|
{
|
||||||
if (inkCanvas.Strokes.Contains(strokes))
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
inkCanvas.Strokes.Remove(strokes);
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Remove(currentStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Add(replacedStroke);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IsCommitingByCode = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void BtnRedo_Click(object sender, RoutedEventArgs e)
|
private void BtnRedo_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
IsCommitingByCode = true;
|
||||||
var item = timeMachine.Redo();
|
var item = timeMachine.Redo();
|
||||||
if (item.CommitType == TimeMachineHistoryType.UserInput)
|
if (item.CommitType == TimeMachineHistoryType.UserInput)
|
||||||
{
|
{
|
||||||
@ -3177,26 +3242,47 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(item.CommitType == TimeMachineHistoryType.Clear)
|
else if (item.CommitType == TimeMachineHistoryType.Clear)
|
||||||
{
|
{
|
||||||
if (!item.StrokeHasBeenCleared)
|
if (!item.StrokeHasBeenCleared)
|
||||||
{
|
{
|
||||||
foreach (var strokes in item.CurrentStroke)
|
if (item.CurrentStroke != null)
|
||||||
{
|
{
|
||||||
if (!inkCanvas.Strokes.Contains(strokes))
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
inkCanvas.Strokes.Add(strokes);
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Add(currentStroke);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Remove(replacedStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var strokes in item.CurrentStroke)
|
if (item.CurrentStroke != null)
|
||||||
{
|
{
|
||||||
if (inkCanvas.Strokes.Contains(strokes))
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
inkCanvas.Strokes.Remove(strokes);
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Remove(currentStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Add(replacedStroke);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IsCommitingByCode = false;
|
||||||
|
}
|
||||||
|
|
||||||
private void Btn_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
|
private void Btn_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -4894,11 +4980,11 @@ namespace Ink_Canvas
|
|||||||
bool isMouseDown = false;
|
bool isMouseDown = false;
|
||||||
private void inkCanvas_MouseDown(object sender, MouseButtonEventArgs e)
|
private void inkCanvas_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
|
isMouseDown = true;
|
||||||
if (NeedUpdateIniP())
|
if (NeedUpdateIniP())
|
||||||
{
|
{
|
||||||
iniP = e.GetPosition(inkCanvas);
|
iniP = e.GetPosition(inkCanvas);
|
||||||
}
|
}
|
||||||
isMouseDown = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void inkCanvas_MouseMove(object sender, MouseEventArgs e)
|
private void inkCanvas_MouseMove(object sender, MouseEventArgs e)
|
||||||
@ -4909,8 +4995,6 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _previousIsErasing = false;
|
|
||||||
private StrokeCollection _erasedStrokeCollection = new StrokeCollection();
|
|
||||||
private void inkCanvas_MouseUp(object sender, MouseButtonEventArgs e)
|
private void inkCanvas_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (drawingShapeMode == 5)
|
if (drawingShapeMode == 5)
|
||||||
@ -4967,11 +5051,11 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
isMouseDown = false;
|
isMouseDown = false;
|
||||||
if (_previousIsErasing)
|
if (ReplacedStroke != null || AddedStroke != null)
|
||||||
{
|
{
|
||||||
timeMachine.CommitStrokeEraseHistory(_erasedStrokeCollection);
|
timeMachine.CommitStrokeEraseHistory(ReplacedStroke, AddedStroke);
|
||||||
_previousIsErasing = false;
|
AddedStroke = null;
|
||||||
_erasedStrokeCollection = new StrokeCollection();
|
ReplacedStroke = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5012,10 +5096,13 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClearStrokes(bool IsErasedByCode)
|
private void ClearStrokes(bool isErasedByCode)
|
||||||
{
|
{
|
||||||
if (!IsErasedByCode) timeMachine.CommitStrokeEraseHistory(inkCanvas.Strokes);
|
if (isErasedByCode) IsCommitingByCode = true;
|
||||||
|
IsClearingCanvas = true;
|
||||||
inkCanvas.Strokes.Clear();
|
inkCanvas.Strokes.Clear();
|
||||||
|
IsClearingCanvas = false;
|
||||||
|
if (isErasedByCode) IsCommitingByCode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreStrokes(bool isBackupMain = false)
|
private void RestoreStrokes(bool isBackupMain = false)
|
||||||
@ -5026,47 +5113,194 @@ namespace Ink_Canvas
|
|||||||
if (isBackupMain)
|
if (isBackupMain)
|
||||||
{
|
{
|
||||||
foreach (var item in TimeMachineHistories[0])
|
foreach (var item in TimeMachineHistories[0])
|
||||||
|
{
|
||||||
|
IsCommitingByCode = true;
|
||||||
|
if (item.CommitType == TimeMachineHistoryType.UserInput)
|
||||||
{
|
{
|
||||||
if (!item.StrokeHasBeenCleared)
|
if (!item.StrokeHasBeenCleared)
|
||||||
{
|
{
|
||||||
switch (item.CommitType)
|
foreach (var strokes in item.CurrentStroke)
|
||||||
{
|
{
|
||||||
case TimeMachineHistoryType.UserInput:
|
if (!inkCanvas.Strokes.Contains(strokes))
|
||||||
inkCanvas.Strokes.Add(item.CurrentStroke);
|
inkCanvas.Strokes.Add(strokes);
|
||||||
break;
|
}
|
||||||
case TimeMachineHistoryType.ShapeRecognition:
|
}
|
||||||
inkCanvas.Strokes.Remove(item.ReplacedStroke);
|
else
|
||||||
inkCanvas.Strokes.Add(item.CurrentStroke);
|
{
|
||||||
break;
|
foreach (var strokes in item.CurrentStroke)
|
||||||
case TimeMachineHistoryType.Clear:
|
{
|
||||||
inkCanvas.Strokes.Clear();
|
if (inkCanvas.Strokes.Contains(strokes))
|
||||||
break;
|
inkCanvas.Strokes.Remove(strokes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item.CommitType == TimeMachineHistoryType.ShapeRecognition)
|
||||||
|
{
|
||||||
|
if (item.StrokeHasBeenCleared)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (var strokes in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Remove(strokes);
|
||||||
|
}
|
||||||
|
foreach (var strokes in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Add(strokes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var strokes in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Add(strokes);
|
||||||
|
}
|
||||||
|
foreach (var strokes in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Remove(strokes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item.CommitType == TimeMachineHistoryType.Clear)
|
||||||
|
{
|
||||||
|
if (!item.StrokeHasBeenCleared)
|
||||||
|
{
|
||||||
|
if (item.CurrentStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Add(currentStroke);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Remove(replacedStroke);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (item.CurrentStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Remove(currentStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Add(replacedStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IsCommitingByCode = false;
|
||||||
|
}
|
||||||
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[0]);
|
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[0]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var item in TimeMachineHistories[CurrentWhiteboardIndex])
|
foreach (var item in TimeMachineHistories[CurrentWhiteboardIndex])
|
||||||
|
{
|
||||||
|
IsCommitingByCode = true;
|
||||||
|
if (item.CommitType == TimeMachineHistoryType.UserInput)
|
||||||
{
|
{
|
||||||
if (!item.StrokeHasBeenCleared)
|
if (!item.StrokeHasBeenCleared)
|
||||||
{
|
{
|
||||||
switch (item.CommitType)
|
foreach (var strokes in item.CurrentStroke)
|
||||||
{
|
{
|
||||||
case TimeMachineHistoryType.UserInput:
|
if (!inkCanvas.Strokes.Contains(strokes))
|
||||||
inkCanvas.Strokes.Add(item.CurrentStroke);
|
inkCanvas.Strokes.Add(strokes);
|
||||||
break;
|
|
||||||
case TimeMachineHistoryType.ShapeRecognition:
|
|
||||||
inkCanvas.Strokes.Remove(item.ReplacedStroke);
|
|
||||||
inkCanvas.Strokes.Add(item.CurrentStroke);
|
|
||||||
break;
|
|
||||||
case TimeMachineHistoryType.Clear:
|
|
||||||
inkCanvas.Strokes.Clear();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var strokes in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Remove(strokes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item.CommitType == TimeMachineHistoryType.ShapeRecognition)
|
||||||
|
{
|
||||||
|
if (item.StrokeHasBeenCleared)
|
||||||
|
{
|
||||||
|
|
||||||
|
foreach (var strokes in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Remove(strokes);
|
||||||
|
}
|
||||||
|
foreach (var strokes in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Add(strokes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (var strokes in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Add(strokes);
|
||||||
|
}
|
||||||
|
foreach (var strokes in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(strokes))
|
||||||
|
inkCanvas.Strokes.Remove(strokes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (item.CommitType == TimeMachineHistoryType.Clear)
|
||||||
|
{
|
||||||
|
if (!item.StrokeHasBeenCleared)
|
||||||
|
{
|
||||||
|
if (item.CurrentStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Add(currentStroke);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Remove(replacedStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (item.CurrentStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var currentStroke in item.CurrentStroke)
|
||||||
|
{
|
||||||
|
if (inkCanvas.Strokes.Contains(currentStroke)) inkCanvas.Strokes.Remove(currentStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (item.ReplacedStroke != null)
|
||||||
|
{
|
||||||
|
foreach (var replacedStroke in item.ReplacedStroke)
|
||||||
|
{
|
||||||
|
if (!inkCanvas.Strokes.Contains(replacedStroke)) inkCanvas.Strokes.Add(replacedStroke);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
IsCommitingByCode = false;
|
||||||
}
|
}
|
||||||
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[CurrentWhiteboardIndex]);
|
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[CurrentWhiteboardIndex]);
|
||||||
}
|
}
|
||||||
@ -5203,7 +5437,6 @@ namespace Ink_Canvas
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
inkCanvas.Opacity = 1;
|
inkCanvas.Opacity = 1;
|
||||||
timeMachine.CommitStrokeUserInputHistory(new StrokeCollection{e.Stroke});
|
|
||||||
if (Settings.InkToShape.IsInkToShapeEnabled)
|
if (Settings.InkToShape.IsInkToShapeEnabled)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -5284,7 +5517,6 @@ namespace Ink_Canvas
|
|||||||
};
|
};
|
||||||
circles.Add(new Circle(result.Centroid, shape.Width / 2.0, stroke));
|
circles.Add(new Circle(result.Centroid, shape.Width / 2.0, stroke));
|
||||||
SetNewBackupOfStroke();
|
SetNewBackupOfStroke();
|
||||||
timeMachine.CommitStrokeShapeHistory(result.InkDrawingNode.Strokes,new StrokeCollection{stroke});
|
|
||||||
inkCanvas.Strokes.Add(stroke);
|
inkCanvas.Strokes.Add(stroke);
|
||||||
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
||||||
newStrokes = new StrokeCollection();
|
newStrokes = new StrokeCollection();
|
||||||
@ -5378,7 +5610,6 @@ namespace Ink_Canvas
|
|||||||
};
|
};
|
||||||
inkCanvas.Strokes.Add(_stroke.Clone());
|
inkCanvas.Strokes.Add(_stroke.Clone());
|
||||||
inkCanvas.Strokes.Add(_generateDashedLineEllipseStrokeCollection);
|
inkCanvas.Strokes.Add(_generateDashedLineEllipseStrokeCollection);
|
||||||
timeMachine.CommitStrokeShapeHistory(result.InkDrawingNode.Strokes,resultStrokes);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5426,7 +5657,6 @@ namespace Ink_Canvas
|
|||||||
SetNewBackupOfStroke();
|
SetNewBackupOfStroke();
|
||||||
inkCanvas.Strokes.Add(stroke);
|
inkCanvas.Strokes.Add(stroke);
|
||||||
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
||||||
timeMachine.CommitStrokeShapeHistory(result.InkDrawingNode.Strokes,new StrokeCollection{stroke});
|
|
||||||
newStrokes = new StrokeCollection();
|
newStrokes = new StrokeCollection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5495,7 +5725,6 @@ namespace Ink_Canvas
|
|||||||
SetNewBackupOfStroke();
|
SetNewBackupOfStroke();
|
||||||
inkCanvas.Strokes.Add(stroke);
|
inkCanvas.Strokes.Add(stroke);
|
||||||
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
inkCanvas.Strokes.Remove(result.InkDrawingNode.Strokes);
|
||||||
timeMachine.CommitStrokeShapeHistory(result.InkDrawingNode.Strokes,new StrokeCollection{stroke});
|
|
||||||
newStrokes = new StrokeCollection();
|
newStrokes = new StrokeCollection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6117,7 +6346,6 @@ namespace Ink_Canvas
|
|||||||
if (sender != lastBorderMouseDownObject) return;
|
if (sender != lastBorderMouseDownObject) return;
|
||||||
if (inkCanvas.GetSelectedStrokes().Count > 0)
|
if (inkCanvas.GetSelectedStrokes().Count > 0)
|
||||||
{
|
{
|
||||||
timeMachine.CommitStrokeEraseHistory(inkCanvas.Strokes);
|
|
||||||
inkCanvas.Strokes.Remove(inkCanvas.GetSelectedStrokes());
|
inkCanvas.Strokes.Remove(inkCanvas.GetSelectedStrokes());
|
||||||
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user