[update] merge了一些新撤回行为的commit,修复了白板模式下直接新增页面导致的TimeMachine不记录历史记录的Bug,类似https://github.com/WXRIW/Ink-Canvas/issues/137提到的问题;继续写了一点白板新UI的东西

This commit is contained in:
Dubi906w 2024-06-09 15:14:58 +08:00
parent 686e48b81b
commit 3d4dbe16b0
10 changed files with 486 additions and 188 deletions

View File

@ -1,5 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
namespace Ink_Canvas.Helpers
@ -43,16 +45,27 @@ namespace Ink_Canvas.Helpers
NotifyUndoRedoState();
}
public void CommitStrokeManipulationHistory(StrokeCollection manipulatedStrokes, Matrix matrix)
public void CommitStrokeManipulationHistory(Dictionary<Stroke, Tuple<StylusPointCollection, StylusPointCollection>> stylusPointDictionary)
{
if (_currentIndex + 1 < _currentStrokeHistory.Count)
{
_currentStrokeHistory.RemoveRange(_currentIndex + 1, (_currentStrokeHistory.Count - 1) - _currentIndex);
}
_currentStrokeHistory.Add(
new TimeMachineHistory(manipulatedStrokes,
TimeMachineHistoryType.Manipulation,
matrix));
new TimeMachineHistory(stylusPointDictionary,
TimeMachineHistoryType.Manipulation));
_currentIndex = _currentStrokeHistory.Count - 1;
NotifyUndoRedoState();
}
public void CommitStrokeDrawingAttributesHistory(Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>> drawingAttributes)
{
if (_currentIndex + 1 < _currentStrokeHistory.Count)
{
_currentStrokeHistory.RemoveRange(_currentIndex + 1, (_currentStrokeHistory.Count - 1) - _currentIndex);
}
_currentStrokeHistory.Add(
new TimeMachineHistory(drawingAttributes,
TimeMachineHistoryType.DrawingAttributes));
_currentIndex = _currentStrokeHistory.Count - 1;
NotifyUndoRedoState();
}
@ -120,10 +133,12 @@ namespace Ink_Canvas.Helpers
public class TimeMachineHistory
{
public TimeMachineHistoryType CommitType;
public bool StrokeHasBeenCleared;
public bool StrokeHasBeenCleared = false;
public StrokeCollection CurrentStroke;
public StrokeCollection ReplacedStroke;
public Matrix ManipulationHistory;
//这里说一下 Tuple的 Value1 是初始值 ; Value 2 是改变值
public Dictionary<Stroke, Tuple<StylusPointCollection, StylusPointCollection>> StylusPointDictionary;
public Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>> DrawingAttributes;
public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool strokeHasBeenCleared)
{
CommitType = commitType;
@ -131,11 +146,15 @@ namespace Ink_Canvas.Helpers
StrokeHasBeenCleared = strokeHasBeenCleared;
ReplacedStroke = null;
}
public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, Matrix matrix)
public TimeMachineHistory(Dictionary<Stroke, Tuple<StylusPointCollection, StylusPointCollection>> stylusPointDictionary, TimeMachineHistoryType commitType)
{
CommitType = commitType;
CurrentStroke = currentStroke;
ManipulationHistory = matrix;
StylusPointDictionary = stylusPointDictionary;
}
public TimeMachineHistory(Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>> drawingAttributes, TimeMachineHistoryType commitType)
{
CommitType = commitType;
DrawingAttributes = drawingAttributes;
}
public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType commitType, bool strokeHasBeenCleared, StrokeCollection replacedStroke)
{
@ -151,6 +170,7 @@ namespace Ink_Canvas.Helpers
UserInput,
ShapeRecognition,
Clear,
Manipulation
Manipulation,
DrawingAttributes
}
}

View File

@ -27,17 +27,17 @@
<Configurations>Debug;Release;x86 Debug</Configurations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>none</DebugType>
<DebugType>full</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|AnyCPU'">
<DebugType>none</DebugType>
<DebugType>full</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType>
<DebugType>full</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
</PropertyGroup>

View File

@ -1481,60 +1481,91 @@
<!-- 左下角 -->
<Viewbox x:Name="ViewboxBlackboardLeftSide" Margin="3,0,0,0" Height="55" HorizontalAlignment="Left"
VerticalAlignment="Bottom">
<Viewbox.LayoutTransform>
<ScaleTransform x:Name="ViewboxBlackboardLeftSideScaleTransform" ScaleX="1" ScaleY="1" />
</Viewbox.LayoutTransform>
<Grid x:Name="BlackboardLeftSide" Visibility="Visible" Opacity="0.75" Margin="3,0,0,0" Height="55"
HorizontalAlignment="Left" VerticalAlignment="Bottom">
<ui:SimpleStackPanel Orientation="Horizontal">
<Border Width="60" Height="55" MouseDown="Border_MouseDown"
MouseUp="BtnWhiteBoardSwitchPrevious_Click" CornerRadius="5,0,0,5"
Background="LightGray" Opacity="0.85">
<Grid Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="6*" />
<RowDefinition Height="37*" />
</Grid.RowDefinitions>
<Image Source="/Resources/Icons-Fluent/ic_fluent_arrow_circle_left_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" VerticalAlignment="Top" Width="26"
Height="26" Margin="11,0,11,0" Grid.RowSpan="2" />
<TextBlock Text="上一页" Foreground="Black" VerticalAlignment="Top"
HorizontalAlignment="Center" FontSize="12" Margin="0,22,0,0" Grid.Row="1" />
</Grid>
<Grid Name="BlackboardLeftSide" Visibility="Visible" Margin="0,0,0,3" Height="50"
HorizontalAlignment="Center" VerticalAlignment="Bottom">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="5">
<Border CornerRadius="5,5,5,5" Background="#f4f4f5" Margin="0,0,0,0">
<ui:SimpleStackPanel Orientation="Horizontal">
<Border Width="60" Height="50"
BorderThickness="1,1,0,1" BorderBrush="#a1a1aa"
MouseUp="BtnWhiteBoardSwitchPrevious_Click" CornerRadius="5,0,0,5"
Background="#f4f4f5"
Opacity="0.95">
<Grid Margin="6,6,6,4">
<Image VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b"
Geometry="F1 M24,24z M0,0z M7.40091,10.456L14.5033,3.35357 12.3198,1.17001 1.48978,12 12.3198,22.83 14.5033,20.6465 7.40089,13.544 22.5102,13.544 22.5102,10.456 7.40091,10.456z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Text="上一页" Foreground="#18181b" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
<Border Width="75" Height="50"
BorderThickness="1,1,1,1" BorderBrush="#a1a1aa" Background="#f4f4f5"
Opacity="0.95">
<Grid Margin="6,6,6,4">
<TextBlock HorizontalAlignment="Center"
Text="{Binding ElementName=TextBlockWhiteBoardIndexInfo, Path=Text}"
Margin="0,-1,0,0" FontSize="17" FontWeight="Bold"
TextAlignment="Center" />
<TextBlock Text="页面" Foreground="#18181b" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
<Border Width="60" Height="50" MouseUp="BtnWhiteBoardSwitchNext_Click"
CornerRadius="0,5,5,0"
BorderThickness="0,1,1,1" BorderBrush="#a1a1aa"
Background="#f4f4f5" Opacity="0.95">
<Grid Margin="6,6,6,4">
<Image VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b"
Geometry="F1 M24,24z M0,0z M16.5991,10.456L9.49667,3.35357 11.6802,1.17001 22.5102,12 11.6802,22.83 9.49667,20.6465 16.5991,13.544 1.48978,13.544 1.48978,10.456 16.5991,10.456z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Text="下一页" Foreground="Black" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
</ui:SimpleStackPanel>
</Border>
<Border Width="58" Height="55" Background="LightGray" Opacity="0.85">
<Grid Margin="0,6">
<ui:SimpleStackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Margin="0,4,0,2"
Text="{Binding ElementName=TextBlockWhiteBoardIndexInfo, Path=Text}"
Foreground="Black" VerticalAlignment="Center"
HorizontalAlignment="Center" FontSize="15" />
<TextBlock Margin="0,3,0,0" Text="页码" Foreground="Black" VerticalAlignment="Center"
HorizontalAlignment="Center" FontSize="12" />
</ui:SimpleStackPanel>
</Grid>
</Border>
<Border Width="60" Height="55" MouseDown="Border_MouseDown"
MouseUp="BtnWhiteBoardSwitchNext_Click" CornerRadius="0,5,5,0" Background="LightGray"
Opacity="0.85">
<Grid Margin="6">
<Image x:Name="BoardLeftPannelNextPage"
Source="/Resources/Icons-Fluent/ic_fluent_add_circle_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" VerticalAlignment="Top" Width="26"
Height="26" />
<TextBlock x:Name="BoardLeftPannelNextPageTextBlock" Text="加页" Foreground="Black"
VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
<Border Margin="5,0,0,0" Width="55" Height="55" MouseDown="Border_MouseDown"
MouseUp="ImageBlackboard_MouseUp" CornerRadius="5" Background="LightGray"
Opacity="0.85">
<Grid Margin="6">
<Image Source="/Resources/Icons-png/minimize.png"
RenderOptions.BitmapScalingMode="HighQuality" VerticalAlignment="Top" Width="26"
Height="26" />
<TextBlock Text="退出" Foreground="Black" VerticalAlignment="Bottom"
<Border Width="60" Height="50"
BorderThickness="1" BorderBrush="#a1a1aa"
MouseUp="BtnWhiteBoardAdd_Click" CornerRadius="5" Background="#f4f4f5"
Opacity="0.95">
<Grid Margin="6,6,6,4">
<Image VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b"
Geometry="F1 M24,24z M0,0z M7.39778,13.723L10.7693,13.723 10.7693,10.3514 13.2307,10.3514 13.2307,13.723 16.6022,13.723 16.6022,16.1843 13.2307,16.1843 13.2307,19.5559 10.7693,19.5559 10.7693,16.1843 7.39778,16.1843 7.39778,13.723z" />
<GeometryDrawing Brush="#18181b"
Geometry="F0 M24,24z M0,0z M3.1391,1.17001L3.1391,22.83 20.8609,22.83 20.8609,6.66948 15.3614,1.17002 3.1391,1.17001z M12.9846,3.13911L5.10819,3.1391 5.10819,20.8609 18.8918,20.8609 18.8918,9.04638 12.9846,9.04638 12.9846,3.13911z M18.484,7.07729L14.9536,3.54692 14.9536,7.07729 18.484,7.07729z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Text="新页面" Foreground="#18181b" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
@ -2613,16 +2644,17 @@
</Grid>
</Border>
<Border>
<Grid RenderTransformOrigin="0,1" Margin="-133,-134,13,55" >
<Grid RenderTransformOrigin="0,1" Margin="-133,-134,13,55">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1.5" ScaleY="1.5"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
<ScaleTransform ScaleX="1.5" ScaleY="1.5" />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Grid.RenderTransform>
<Border Visibility="Visible" ClipToBounds="True" Name="BoardEraserSizePanel" CornerRadius="5" Background="#fafafa"
<Border Visibility="Visible" ClipToBounds="True" Name="BoardEraserSizePanel"
CornerRadius="5" Background="#fafafa"
Opacity="1"
BorderBrush="#2563eb" BorderThickness="1">
<ui:SimpleStackPanel Margin="0">
@ -2707,11 +2739,12 @@
<ui:SimpleStackPanel VerticalAlignment="Center"
Orientation="Horizontal"
HorizontalAlignment="Center" Margin="0,3">
<TextBlock x:Name="BoardRectangleEraserTabButtonText"
Foreground="#172554" FontWeight="Medium"
FontSize="9" TextAlignment="Center"
Text="黑板擦"
Margin="2,1,0,0" />
<TextBlock
x:Name="BoardRectangleEraserTabButtonText"
Foreground="#172554" FontWeight="Medium"
FontSize="9" TextAlignment="Center"
Text="黑板擦"
Margin="2,1,0,0" />
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</Canvas>
@ -3119,56 +3152,93 @@
<!-- 右下角 -->
<Viewbox x:Name="ViewboxBlackboardRightSide" Margin="3,0,0,0" Height="55" HorizontalAlignment="Right"
VerticalAlignment="Bottom">
<Viewbox.LayoutTransform>
<ScaleTransform x:Name="ViewboxBlackboardRightSideScaleTransform" ScaleX="1" ScaleY="1" />
</Viewbox.LayoutTransform>
<Grid x:Name="BlackboardRightSide" Visibility="Visible" Opacity="0.75" Margin="0,0,3,0" Height="55"
HorizontalAlignment="Right" VerticalAlignment="Bottom">
<ui:SimpleStackPanel Orientation="Horizontal">
<Border Margin="0,0,5,0" Width="55" Height="55" MouseDown="Border_MouseDown"
MouseUp="BtnWhiteBoardAdd_Click" CornerRadius="3" Background="LightGray" Opacity="0.85">
<Grid Margin="6">
<Image Source="/Resources/Icons-Fluent/ic_fluent_add_circle_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" VerticalAlignment="Top" Width="26"
Height="26" />
<TextBlock Text="加页" Foreground="Black" VerticalAlignment="Bottom"
<Grid Name="BlackboardRightSide" Visibility="Visible" Margin="0,0,0,3" Height="50"
HorizontalAlignment="Center" VerticalAlignment="Bottom">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="5">
<Border Width="60" Height="50"
BorderThickness="1" BorderBrush="#a1a1aa"
MouseUp="BtnWhiteBoardAdd_Click" CornerRadius="5" Background="#f4f4f5"
Opacity="0.95">
<Grid Margin="6,6,6,4">
<Image VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b"
Geometry="F1 M24,24z M0,0z M7.39778,13.723L10.7693,13.723 10.7693,10.3514 13.2307,10.3514 13.2307,13.723 16.6022,13.723 16.6022,16.1843 13.2307,16.1843 13.2307,19.5559 10.7693,19.5559 10.7693,16.1843 7.39778,16.1843 7.39778,13.723z" />
<GeometryDrawing Brush="#18181b"
Geometry="F0 M24,24z M0,0z M3.1391,1.17001L3.1391,22.83 20.8609,22.83 20.8609,6.66948 15.3614,1.17002 3.1391,1.17001z M12.9846,3.13911L5.10819,3.1391 5.10819,20.8609 18.8918,20.8609 18.8918,9.04638 12.9846,9.04638 12.9846,3.13911z M18.484,7.07729L14.9536,3.54692 14.9536,7.07729 18.484,7.07729z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Text="新页面" Foreground="#18181b" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
<Border Width="60" Height="55" MouseDown="Border_MouseDown"
MouseUp="BtnWhiteBoardSwitchPrevious_Click" CornerRadius="3,0,0,3"
Background="LightGray" Opacity="0.85">
<Grid Margin="6">
<Image Source="/Resources/Icons-Fluent/ic_fluent_arrow_circle_left_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" VerticalAlignment="Top" Width="26"
Height="26" />
<TextBlock Text="上一页" Foreground="Black" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
<Border Width="58" Height="55" Background="LightGray" Opacity="0.85">
<Grid Margin="0,6">
<ui:SimpleStackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
<TextBlock Margin="0,4,0,2"
Text="{Binding ElementName=TextBlockWhiteBoardIndexInfo, Path=Text}"
Foreground="Black" VerticalAlignment="Center"
HorizontalAlignment="Center" FontSize="15" />
<TextBlock Margin="0,3,0,0" Text="页码" Foreground="Black" VerticalAlignment="Center"
HorizontalAlignment="Center" FontSize="12" />
</ui:SimpleStackPanel>
</Grid>
</Border>
<Border Width="60" Height="55" MouseDown="Border_MouseDown"
MouseUp="BtnWhiteBoardSwitchNext_Click" CornerRadius="0,5,5,0" Background="LightGray"
Opacity="0.85">
<Grid Margin="6">
<Image x:Name="BoardRightPannelNextPage"
Source="/Resources/Icons-Fluent/ic_fluent_add_circle_24_regular.png"
RenderOptions.BitmapScalingMode="HighQuality" VerticalAlignment="Top" Width="26"
Height="26" />
<TextBlock x:Name="BoardRightPannelNextPageTextBlock" Text="加页" Foreground="Black"
VerticalAlignment="Bottom" HorizontalAlignment="Center" FontSize="12" />
</Grid>
<Border CornerRadius="5,5,5,5" Background="#f4f4f5" Margin="0,0,0,0">
<ui:SimpleStackPanel Orientation="Horizontal">
<Border Width="60" Height="50"
BorderThickness="1,1,0,1" BorderBrush="#a1a1aa"
MouseUp="BtnWhiteBoardSwitchPrevious_Click" CornerRadius="5,0,0,5"
Background="#f4f4f5"
Opacity="0.95">
<Grid Margin="6,6,6,4">
<Image VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b"
Geometry="F1 M24,24z M0,0z M7.40091,10.456L14.5033,3.35357 12.3198,1.17001 1.48978,12 12.3198,22.83 14.5033,20.6465 7.40089,13.544 22.5102,13.544 22.5102,10.456 7.40091,10.456z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Text="上一页" Foreground="#18181b" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
<Border Width="75" Height="50"
BorderThickness="1,1,1,1" BorderBrush="#a1a1aa" Background="#f4f4f5"
Opacity="0.95">
<Grid Margin="6,6,6,4">
<TextBlock HorizontalAlignment="Center"
Text="{Binding ElementName=TextBlockWhiteBoardIndexInfo, Path=Text}"
Margin="0,-1,0,0" FontSize="17" FontWeight="Bold"
TextAlignment="Center" />
<TextBlock Text="页面" Foreground="#18181b" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
<Border Width="60" Height="50" MouseUp="BtnWhiteBoardSwitchNext_Click"
CornerRadius="0,5,5,0"
BorderThickness="0,1,1,1" BorderBrush="#a1a1aa"
Background="#f4f4f5" Opacity="0.95">
<Grid Margin="6,6,6,4">
<Image VerticalAlignment="Top"
RenderOptions.BitmapScalingMode="HighQuality" Height="20" Width="20">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#18181b"
Geometry="F1 M24,24z M0,0z M16.5991,10.456L9.49667,3.35357 11.6802,1.17001 22.5102,12 11.6802,22.83 9.49667,20.6465 16.5991,13.544 1.48978,13.544 1.48978,10.456 16.5991,10.456z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock Text="下一页" Foreground="Black" VerticalAlignment="Bottom"
HorizontalAlignment="Center" FontSize="12" />
</Grid>
</Border>
</ui:SimpleStackPanel>
</Border>
</ui:SimpleStackPanel>
</Grid>
@ -3216,7 +3286,7 @@
</Button>
<Border Height="48" CornerRadius="2" Margin="3,0">
<TextBlock Name="TextBlockWhiteBoardIndexInfo"
Text="1 / 1"
Text="1/1"
Foreground="{Binding ElementName=BtnExit, Path=Foreground}"
VerticalAlignment="Center" HorizontalAlignment="Center" FontFamily="Microsoft YaHei UI"
FontSize="18" />

View File

@ -38,12 +38,10 @@ namespace Ink_Canvas {
try {
if (TimeMachineHistories[CurrentWhiteboardIndex] == null) return; //防止白板打开后不居中
if (isBackupMain) {
_currentCommitType = CommitReason.CodeInput;
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[0]);
foreach (var item in TimeMachineHistories[0]) ApplyHistoryToCanvas(item);
}
else {
_currentCommitType = CommitReason.CodeInput;
timeMachine.ImportTimeMachineHistory(TimeMachineHistories[CurrentWhiteboardIndex]);
foreach (var item in TimeMachineHistories[CurrentWhiteboardIndex]) ApplyHistoryToCanvas(item);
}
@ -76,7 +74,6 @@ namespace Ink_Canvas {
SaveStrokes();
ClearStrokes(true);
CurrentWhiteboardIndex++;
@ -124,7 +121,7 @@ namespace Ink_Canvas {
private void UpdateIndexInfoDisplay() {
TextBlockWhiteBoardIndexInfo.Text =
$"{CurrentWhiteboardIndex} / {WhiteboardTotalCount}";
$"{CurrentWhiteboardIndex}/{WhiteboardTotalCount}";
if (CurrentWhiteboardIndex == WhiteboardTotalCount) {
var newImageSource = new BitmapImage();
@ -132,10 +129,10 @@ namespace Ink_Canvas {
newImageSource.UriSource = new Uri("/Resources/Icons-Fluent/ic_fluent_add_circle_24_regular.png",
UriKind.RelativeOrAbsolute);
newImageSource.EndInit();
BoardLeftPannelNextPage.Source = newImageSource;
BoardRightPannelNextPage.Source = newImageSource;
BoardRightPannelNextPageTextBlock.Text = "加页";
BoardLeftPannelNextPageTextBlock.Text = "加页";
//BoardLeftPannelNextPage.Source = newImageSource;
//BoardRightPannelNextPage.Source = newImageSource;
//BoardRightPannelNextPageTextBlock.Text = "加页";
//BoardLeftPannelNextPageTextBlock.Text = "加页";
}
else {
var newImageSource = new BitmapImage();
@ -144,10 +141,10 @@ namespace Ink_Canvas {
new Uri("/Resources/Icons-Fluent/ic_fluent_arrow_circle_right_24_regular.png",
UriKind.RelativeOrAbsolute);
newImageSource.EndInit();
BoardLeftPannelNextPage.Source = newImageSource;
BoardRightPannelNextPage.Source = newImageSource;
BoardRightPannelNextPageTextBlock.Text = "下一页";
BoardLeftPannelNextPageTextBlock.Text = "下一页";
//BoardLeftPannelNextPage.Source = newImageSource;
//BoardRightPannelNextPage.Source = newImageSource;
//BoardRightPannelNextPageTextBlock.Text = "下一页";
//BoardLeftPannelNextPageTextBlock.Text = "下一页";
}
BtnWhiteBoardSwitchPrevious.IsEnabled = CurrentWhiteboardIndex != 1;

View File

@ -40,6 +40,15 @@ namespace Ink_Canvas {
// ignored
}
}
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
else {
inkCanvas.IsManipulationEnabled = true;
drawingShapeMode = 0;

View File

@ -1,5 +1,6 @@
using iNKORE.UI.WPF.Modern.Controls;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
@ -70,6 +71,16 @@ namespace Ink_Canvas {
stroke.DrawingAttributes.Width = newWidth;
stroke.DrawingAttributes.Height = newHeight;
}
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
private void GridPenWidthRestore_MouseUp(object sender, MouseButtonEventArgs e) {
@ -98,7 +109,21 @@ namespace Ink_Canvas {
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
timeMachine.CommitStrokeManipulationHistory(targetStrokes, m);
if (DrawingAttributesHistory.Count > 0)
{
//var collecion = new StrokeCollection();
//foreach (var item in DrawingAttributesHistory)
//{
// collecion.Add(item.Key);
//}
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
//updateBorderStrokeSelectionControlLocation();
}
@ -120,7 +145,16 @@ namespace Ink_Canvas {
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
timeMachine.CommitStrokeManipulationHistory(targetStrokes, m);
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
private void ImageRotate45_MouseUp(object sender, MouseButtonEventArgs e) {
@ -140,7 +174,16 @@ namespace Ink_Canvas {
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
timeMachine.CommitStrokeManipulationHistory(targetStrokes, m);
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
private void ImageRotate90_MouseUp(object sender, MouseButtonEventArgs e) {
@ -160,7 +203,21 @@ namespace Ink_Canvas {
var targetStrokes = inkCanvas.GetSelectedStrokes();
foreach (var stroke in targetStrokes) stroke.Transform(m, false);
timeMachine.CommitStrokeManipulationHistory(targetStrokes, m);
if (DrawingAttributesHistory.Count > 0)
{
var collecion = new StrokeCollection();
foreach (var item in DrawingAttributesHistory)
{
collecion.Add(item.Key);
}
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
#endregion
@ -236,8 +293,26 @@ namespace Ink_Canvas {
e.Mode = ManipulationModes.All;
}
private void
GridInkCanvasSelectionCover_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { }
private void GridInkCanvasSelectionCover_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) {
if (StrokeManipulationHistory?.Count > 0)
{
timeMachine.CommitStrokeManipulationHistory(StrokeManipulationHistory);
foreach (var item in StrokeManipulationHistory)
{
StrokeInitialHistory[item.Key] = item.Value.Item2;
}
StrokeManipulationHistory = null;
}
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
}
private void GridInkCanvasSelectionCover_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) {
try {
@ -275,14 +350,6 @@ namespace Ink_Canvas {
catch { }
}
if (lastTempManiputlaionMatrix == null) {
lastTempManiputlaionMatrix = m;
lastTempStrokeCollection = strokes;
}
else {
lastTempManiputlaionMatrix?.Append(m);
}
updateBorderStrokeSelectionControlLocation();
}
}

View File

@ -204,23 +204,23 @@ namespace Ink_Canvas
if (Settings.Appearance.EnableViewboxBlackBoardScaleTransform) // 画板 UI 缩放 80%
{
ViewboxBlackboardLeftSideScaleTransform.ScaleX = 0.8;
ViewboxBlackboardLeftSideScaleTransform.ScaleY = 0.8;
//ViewboxBlackboardLeftSideScaleTransform.ScaleX = 0.8;
//ViewboxBlackboardLeftSideScaleTransform.ScaleY = 0.8;
ViewboxBlackboardCenterSideScaleTransform.ScaleX = 0.8;
ViewboxBlackboardCenterSideScaleTransform.ScaleY = 0.8;
ViewboxBlackboardRightSideScaleTransform.ScaleX = 0.8;
ViewboxBlackboardRightSideScaleTransform.ScaleY = 0.8;
//ViewboxBlackboardRightSideScaleTransform.ScaleX = 0.8;
//ViewboxBlackboardRightSideScaleTransform.ScaleY = 0.8;
ToggleSwitchEnableViewboxBlackBoardScaleTransform.IsOn = true;
}
else
{
ViewboxBlackboardLeftSideScaleTransform.ScaleX = 1;
ViewboxBlackboardLeftSideScaleTransform.ScaleY = 1;
//ViewboxBlackboardLeftSideScaleTransform.ScaleX = 1;
//ViewboxBlackboardLeftSideScaleTransform.ScaleY = 1;
ViewboxBlackboardCenterSideScaleTransform.ScaleX = 1;
ViewboxBlackboardCenterSideScaleTransform.ScaleY = 1;
ViewboxBlackboardRightSideScaleTransform.ScaleX = 1;
ViewboxBlackboardRightSideScaleTransform.ScaleY = 1;
//ViewboxBlackboardRightSideScaleTransform.ScaleX = 1;
//ViewboxBlackboardRightSideScaleTransform.ScaleY = 1;
ToggleSwitchEnableViewboxBlackBoardScaleTransform.IsOn = false;
}

View File

@ -1276,7 +1276,6 @@ namespace Ink_Canvas {
private Stroke lastTempStroke = null;
private StrokeCollection lastTempStrokeCollection = new StrokeCollection();
private Matrix? lastTempManiputlaionMatrix = null;
private bool isWaitUntilNextTouchDown = false;
@ -1564,15 +1563,28 @@ namespace Ink_Canvas {
if (collection != null) timeMachine.CommitStrokeUserInputHistory(collection);
}
if (lastTempManiputlaionMatrix != null) {
timeMachine.CommitStrokeManipulationHistory(lastTempStrokeCollection, lastTempManiputlaionMatrix.Value);
lastTempStrokeCollection = null;
lastTempManiputlaionMatrix = null;
}
lastTempStroke = null;
lastTempStrokeCollection = null;
lastTempManiputlaionMatrix = null;
if (StrokeManipulationHistory?.Count > 0)
{
timeMachine.CommitStrokeManipulationHistory(StrokeManipulationHistory);
foreach (var item in StrokeManipulationHistory)
{
StrokeInitialHistory[item.Key] = item.Value.Item2;
}
StrokeManipulationHistory = null;
}
if (DrawingAttributesHistory.Count > 0)
{
timeMachine.CommitStrokeDrawingAttributesHistory(DrawingAttributesHistory);
DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
foreach (var item in DrawingAttributesHistoryFlag)
{
item.Value.Clear();
}
}
ViewboxFloatingBar.IsHitTestVisible = true;

View File

@ -1,7 +1,12 @@
using Ink_Canvas.Helpers;
using System.Collections.Generic;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Diagnostics;
namespace Ink_Canvas {
public partial class MainWindow : Window {
@ -19,6 +24,19 @@ namespace Ink_Canvas {
private StrokeCollection ReplacedStroke;
private StrokeCollection AddedStroke;
private StrokeCollection CuboidStrokeCollection;
private Dictionary<Stroke, Tuple<StylusPointCollection, StylusPointCollection>> StrokeManipulationHistory;
private Dictionary<Stroke, StylusPointCollection> StrokeInitialHistory = new Dictionary<Stroke, StylusPointCollection>();
private Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>> DrawingAttributesHistory = new Dictionary<Stroke, Tuple<DrawingAttributes, DrawingAttributes>>();
private Dictionary<Guid, List<Stroke>> DrawingAttributesHistoryFlag = new Dictionary<Guid, List<Stroke>>()
{
{ DrawingAttributeIds.Color, new List<Stroke>() },
{ DrawingAttributeIds.DrawingFlags, new List<Stroke>() },
{ DrawingAttributeIds.IsHighlighter, new List<Stroke>() },
{ DrawingAttributeIds.StylusHeight, new List<Stroke>() },
{ DrawingAttributeIds.StylusTip, new List<Stroke>() },
{ DrawingAttributeIds.StylusTipTransform, new List<Stroke>() },
{ DrawingAttributeIds.StylusWidth, new List<Stroke>() }
};
private TimeMachine timeMachine = new TimeMachine();
private void ApplyHistoryToCanvas(TimeMachineHistory item) {
@ -56,10 +74,47 @@ namespace Ink_Canvas {
}
}
else if (item.CommitType == TimeMachineHistoryType.Manipulation) {
item.ManipulationHistory.Invert();
foreach (var strokes in item.CurrentStroke) strokes.Transform(item.ManipulationHistory, false);
if (!item.StrokeHasBeenCleared) {
foreach (var currentStroke in item.StylusPointDictionary) {
if (inkCanvas.Strokes.Contains(currentStroke.Key)) {
currentStroke.Key.StylusPoints = currentStroke.Value.Item2;
}
}
}
else
{
foreach (var currentStroke in item.StylusPointDictionary)
{
if (inkCanvas.Strokes.Contains(currentStroke.Key))
{
currentStroke.Key.StylusPoints = currentStroke.Value.Item1;
}
}
}
}
else if (item.CommitType == TimeMachineHistoryType.Clear) {
else if (item.CommitType == TimeMachineHistoryType.DrawingAttributes)
{
if (!item.StrokeHasBeenCleared)
{
foreach (var currentStroke in item.DrawingAttributes)
{
if (inkCanvas.Strokes.Contains(currentStroke.Key))
{
currentStroke.Key.DrawingAttributes = currentStroke.Value.Item2;
}
}
}
else
{
foreach (var currentStroke in item.DrawingAttributes)
{
if (inkCanvas.Strokes.Contains(currentStroke.Key))
{
currentStroke.Key.DrawingAttributes = currentStroke.Value.Item1;
}
}
}
} else if (item.CommitType == TimeMachineHistoryType.Clear) {
if (!item.StrokeHasBeenCleared) {
if (item.CurrentStroke != null)
foreach (var currentStroke in item.CurrentStroke)
@ -105,6 +160,21 @@ namespace Ink_Canvas {
HideSubPanels(); // 书写时自动隐藏二级菜单
}
foreach (var stroke in e?.Removed)
{
stroke.StylusPointsChanged -= Stroke_StylusPointsChanged;
stroke.StylusPointsReplaced -= Stroke_StylusPointsReplaced;
stroke.DrawingAttributesChanged -= Stroke_DrawingAttributesChanged;
StrokeInitialHistory.Remove(stroke);
}
foreach (var stroke in e?.Added)
{
stroke.StylusPointsChanged += Stroke_StylusPointsChanged;
stroke.StylusPointsReplaced += Stroke_StylusPointsReplaced;
stroke.DrawingAttributesChanged += Stroke_DrawingAttributesChanged;
StrokeInitialHistory[stroke] = stroke.StylusPoints.Clone();
}
if (_currentCommitType == CommitReason.CodeInput || _currentCommitType == CommitReason.ShapeDrawing) return;
if ((e.Added.Count != 0 || e.Removed.Count != 0) && IsEraseByPoint) {
@ -138,5 +208,75 @@ namespace Ink_Canvas {
}
}
}
private void Stroke_DrawingAttributesChanged(object sender, PropertyDataChangedEventArgs e)
{
var key = sender as Stroke;
var currentValue = key.DrawingAttributes.Clone();
DrawingAttributesHistory.TryGetValue(key, out var previousTuple);
var previousValue = previousTuple?.Item1 ?? currentValue.Clone();
var needUpdateValue = !DrawingAttributesHistoryFlag[e.PropertyGuid].Contains(key);
if (needUpdateValue)
{
DrawingAttributesHistoryFlag[e.PropertyGuid].Add(key);
Debug.Write(e.PreviousValue.ToString());
}
if (e.PropertyGuid == DrawingAttributeIds.Color && needUpdateValue)
{
previousValue.Color = (Color)e.PreviousValue;
}
if (e.PropertyGuid == DrawingAttributeIds.IsHighlighter && needUpdateValue)
{
previousValue.IsHighlighter = (bool)e.PreviousValue;
}
if (e.PropertyGuid == DrawingAttributeIds.StylusHeight && needUpdateValue)
{
previousValue.Height = (double)e.PreviousValue;
}
if (e.PropertyGuid == DrawingAttributeIds.StylusWidth && needUpdateValue)
{
previousValue.Width = (double)e.PreviousValue;
}
if (e.PropertyGuid == DrawingAttributeIds.StylusTip && needUpdateValue)
{
previousValue.StylusTip = (StylusTip)e.PreviousValue;
}
if (e.PropertyGuid == DrawingAttributeIds.StylusTipTransform && needUpdateValue)
{
previousValue.StylusTipTransform = (Matrix)e.PreviousValue;
}
if (e.PropertyGuid == DrawingAttributeIds.DrawingFlags && needUpdateValue)
{
previousValue.IgnorePressure = (bool)e.PreviousValue;
}
DrawingAttributesHistory[key] = new Tuple<DrawingAttributes, DrawingAttributes>(previousValue, currentValue);
}
private void Stroke_StylusPointsReplaced(object sender, StylusPointsReplacedEventArgs e)
{
StrokeInitialHistory[sender as Stroke] = e.NewStylusPoints.Clone();
}
private void Stroke_StylusPointsChanged(object sender, EventArgs e)
{
var selectedStrokes = inkCanvas.GetSelectedStrokes();
var count = selectedStrokes.Count;
if (count == 0) count = inkCanvas.Strokes.Count;
if (StrokeManipulationHistory == null)
{
StrokeManipulationHistory = new Dictionary<Stroke, Tuple<StylusPointCollection, StylusPointCollection>>();
}
StrokeManipulationHistory[sender as Stroke] =
new Tuple<StylusPointCollection, StylusPointCollection>(StrokeInitialHistory[sender as Stroke], (sender as Stroke).StylusPoints.Clone());
if ((StrokeManipulationHistory.Count == count || sender == null) && dec.Count == 0)
{
timeMachine.CommitStrokeManipulationHistory(StrokeManipulationHistory);
foreach (var item in StrokeManipulationHistory)
{
StrokeInitialHistory[item.Key] = item.Value.Item2;
}
StrokeManipulationHistory = null;
}
}
}
}

View File

@ -379,14 +379,6 @@ namespace Ink_Canvas {
}
catch { }
}
if (lastTempManiputlaionMatrix == null) {
lastTempManiputlaionMatrix = m;
lastTempStrokeCollection = strokes;
}
else {
lastTempManiputlaionMatrix?.Append(m);
}
}
else {
if (Settings.Gesture.IsEnableTwoFingerZoom) {
@ -416,15 +408,6 @@ namespace Ink_Canvas {
circle.Stroke.StylusPoints[circle.Stroke.StylusPoints.Count / 2].Y) / 2
);
}
;
if (lastTempManiputlaionMatrix == null) {
lastTempManiputlaionMatrix = m;
lastTempStrokeCollection = inkCanvas.Strokes;
}
else {
lastTempManiputlaionMatrix?.Append(m);
}
}
}
}