Skip to content

Commit

Permalink
Merge pull request #130 from WXRIW/bug-fixes
Browse files Browse the repository at this point in the history
Bug fixes for a looooong time.
  • Loading branch information
Raspberry-Monster authored Jun 2, 2024
2 parents ae6ecba + 85eeee4 commit 653bf51
Show file tree
Hide file tree
Showing 22 changed files with 1,006 additions and 1,306 deletions.
20 changes: 17 additions & 3 deletions Ink Canvas/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,35 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Ink_Canvas"
StartupUri="MainWindow.xaml"
xmlns:ui="http://schemas.modernwpf.com/2019">
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern">
<Application.Resources>
<ResourceDictionary>
<Style TargetType="ScrollViewer">
<Style TargetType="ui:ScrollViewerEx">

<EventSetter Event="PreviewMouseWheel" Handler="ScrollViewer_PreviewMouseWheel"/>

</Style>

<Style TargetType="ui:FontIcon">
<Setter Property="FontSize" Value="20"/>
</Style>
<Style TargetType="ui:SymbolIcon">
<Setter Property="FontSize" Value="20"/>
</Style>


<ResourceDictionary.MergedDictionaries>

<ui:ThemeResources RequestedTheme="Light"/>
<ui:XamlControlsResources />


<ui:XamlControlsResources/>

<ResourceDictionary Source="Resources/SeewoImageDictionary.xaml"/>
<ResourceDictionary Source="Resources/DrawShapeImageDictionary.xaml"/>
<ResourceDictionary Source="Resources/IconImageDictionary.xaml"/>
<ResourceDictionary Source="Resources/Styles/Light.xaml"/>

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
4 changes: 3 additions & 1 deletion Ink Canvas/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using AutoUpdaterDotNET;
using Ink_Canvas.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
using System;
using System.Linq;
using System.Reflection;
using System.Windows;
using MessageBox = System.Windows.MessageBox;

namespace Ink_Canvas
{
Expand Down Expand Up @@ -68,7 +70,7 @@ private void ScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.
else
try
{
System.Windows.Controls.ScrollViewer SenderScrollViewer = (System.Windows.Controls.ScrollViewer)sender;
ScrollViewerEx SenderScrollViewer = (ScrollViewerEx)sender;
SenderScrollViewer.ScrollToVerticalOffset(SenderScrollViewer.VerticalOffset - e.Delta * 10 * System.Windows.Forms.SystemInformation.MouseWheelScrollLines / (double)120);
e.Handled = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Ink Canvas/ChangeLogWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Ink_Canvas" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" ShowInTaskbar="False"
xmlns:ui="http://schemas.modernwpf.com/2019" FontFamily="Microsoft YaHei UI" Topmost="True"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" FontFamily="Microsoft YaHei UI" Topmost="True"
mc:Ignorable="d" ui:WindowHelper.UseModernWindowStyle="True" Loaded="Window_Loaded" Closed="Window_Closed"
Title="" Height="390" Width="600">
<Grid>
Expand Down
2 changes: 1 addition & 1 deletion Ink Canvas/CountdownTimerWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Ink_Canvas"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:processbars="clr-namespace:Ink_Canvas.ProcessBars"
ui:ThemeManager.RequestedTheme="Light" Topmost="True" Background="Transparent"
mc:Ignorable="d" WindowStyle="None" AllowsTransparency="True"
Expand Down
14 changes: 7 additions & 7 deletions Ink Canvas/CountdownTimerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void Timer_Elapsed(object sender, ElapsedEventArgs e)
TextBlockSecond.Text = "00";
timer.Stop();
isTimerRunning = false;
SymbolIconStart.Symbol = ModernWpf.Controls.Symbol.Play;
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
BtnStartCover.Visibility = Visibility.Visible;
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
BorderStopTime.Visibility = Visibility.Collapsed;
Expand Down Expand Up @@ -199,12 +199,12 @@ private void BtnFullscreen_MouseUp(object sender, MouseButtonEventArgs e)
if (WindowState == WindowState.Normal)
{
WindowState = WindowState.Maximized;
SymbolIconFullscreen.Symbol = ModernWpf.Controls.Symbol.BackToWindow;
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.BackToWindow;
}
else
{
WindowState = WindowState.Normal;
SymbolIconFullscreen.Symbol = ModernWpf.Controls.Symbol.FullScreen;
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.FullScreen;
}
}

Expand All @@ -230,7 +230,7 @@ private void BtnReset_MouseUp(object sender, MouseButtonEventArgs e)
BtnStartCover.Visibility = Visibility.Collapsed;
BorderStopTime.Visibility = Visibility.Collapsed;
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
SymbolIconStart.Symbol = ModernWpf.Controls.Symbol.Play;
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
isTimerRunning = false;
timer.Stop();
isPaused = false;
Expand Down Expand Up @@ -280,7 +280,7 @@ private void BtnStart_MouseUp(object sender, MouseButtonEventArgs e)
startTime += DateTime.Now - pauseTime;
ProcessBarTime.IsPaused = false;
TextBlockHour.Foreground = Brushes.Black;
SymbolIconStart.Symbol = ModernWpf.Controls.Symbol.Pause;
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pause;
isPaused = false;
timer.Start();
UpdateStopTime();
Expand All @@ -292,7 +292,7 @@ private void BtnStart_MouseUp(object sender, MouseButtonEventArgs e)
pauseTime = DateTime.Now;
ProcessBarTime.IsPaused = true;
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
SymbolIconStart.Symbol = ModernWpf.Controls.Symbol.Play;
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
BorderStopTime.Visibility = Visibility.Collapsed;
isPaused = true;
timer.Stop();
Expand All @@ -304,7 +304,7 @@ private void BtnStart_MouseUp(object sender, MouseButtonEventArgs e)
totalSeconds = ((hour * 60) + minute) * 60 + second;
ProcessBarTime.IsPaused = false;
TextBlockHour.Foreground = Brushes.Black;
SymbolIconStart.Symbol = ModernWpf.Controls.Symbol.Pause;
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pause;
BtnResetCover.Visibility = Visibility.Collapsed;

if (totalSeconds <= 10)
Expand Down
44 changes: 35 additions & 9 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;
using System.Collections.Generic;
using System.Windows.Ink;
using System.Windows.Input;

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

public void CommitStrokeRotateHistory(StrokeCollection strokeToBeReplaced, StrokeCollection generatedStroke)
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(generatedStroke,
TimeMachineHistoryType.Rotate,
false,
strokeToBeReplaced));
_currentStrokeHistory.Add(
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();
}

public void CommitStrokeEraseHistory(StrokeCollection stroke, StrokeCollection sourceStroke = null)
{
if (_currentIndex + 1 < _currentStrokeHistory.Count)
Expand Down Expand Up @@ -119,9 +131,12 @@ private void NotifyUndoRedoState()
public class TimeMachineHistory
{
public TimeMachineHistoryType CommitType;
public bool StrokeHasBeenCleared;
public bool StrokeHasBeenCleared = false;
public StrokeCollection CurrentStroke;
public StrokeCollection ReplacedStroke;
//这里说一下 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;
Expand All @@ -136,13 +151,24 @@ public TimeMachineHistory(StrokeCollection currentStroke, TimeMachineHistoryType
StrokeHasBeenCleared = strokeHasBeenCleared;
ReplacedStroke = replacedStroke;
}
public TimeMachineHistory(Dictionary<Stroke, Tuple<StylusPointCollection,StylusPointCollection>> stylusPointDictionary, TimeMachineHistoryType commitType)
{
CommitType=commitType;
StylusPointDictionary = stylusPointDictionary;
}
public TimeMachineHistory(Dictionary<Stroke, Tuple<DrawingAttributes,DrawingAttributes>> drawingAttributes, TimeMachineHistoryType commitType)
{
CommitType = commitType;
DrawingAttributes = drawingAttributes;
}
}

public enum TimeMachineHistoryType
{
UserInput,
ShapeRecognition,
Clear,
Rotate
Manipulation,
DrawingAttributes
}
}
Loading

0 comments on commit 653bf51

Please sign in to comment.