Add lots of things and fix lots of bugs

This commit is contained in:
XY Wang 2021-09-27 01:20:14 +08:00
parent fd669c7a4a
commit fd30e21c3a
6 changed files with 273 additions and 32 deletions

View File

@ -0,0 +1,25 @@
<Window x:Class="Ink_Canvas.ChangeLogWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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"
mc:Ignorable="d" ui:WindowHelper.UseModernWindowStyle="True" Loaded="Window_Loaded" Closed="Window_Closed"
Title="" Height="350" Width="600">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<Label Content="已升级到最新版本!" FontFamily="Microsoft YaHei UI" FontSize="26" Margin="20,0"/>
<StackPanel Grid.Row="1">
<TextBlock Name="TextBlockChangeLogTitle" Text="更新日志" FontSize="18" FontWeight="Bold" Margin="35,10,35,0"/>
<TextBlock Name="TextBlockChangeLog" Text="" FontSize="14" Margin="55,5"/>
<TextBlock Name="TextBlockSuggestionTitle" Text="建议" FontSize="18" FontWeight="Bold" Margin="35,10,35,0"/>
<TextBlock Name="TextBlockSuggestion" Text="" FontSize="14" Margin="55,5"/>
</StackPanel>
<Button Content="确定" Grid.Row="2" HorizontalAlignment="Right" Margin="10" Width="100" FontFamily="Microsoft YaHei UI" Click="Button_Click"/>
</Grid>
</Window>

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Ink_Canvas
{
/// <summary>
/// Interaction logic for ChangeLogWindow.xaml
/// </summary>
public partial class ChangeLogWindow : Window
{
public ChangeLogWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//Version 2.1.0-beta
TextBlockChangeLog.Text = "" +
"1. 修复使用画板时无法使用翻页笔的问题\n" +
"2. 支持修改画笔粗细,支持显示画笔指针\n" +
"3. 支持双指缩放和拖动手势\n" +
"4. 添加“选择墨迹”功能,选中后可以对墨迹进行拖动,拉伸等操作\n" +
"5. 添加画图功能(直线、箭头、矩形、椭圆)";
TextBlockSuggestion.Text = "打开设置,点击“重置”中的“重置设置为推荐设置”,以提升教学体验!";
}
private void Window_Closed(object sender, EventArgs e)
{
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}

View File

@ -84,10 +84,17 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="ChangeLogWindow.xaml.cs">
<DependentUpon>ChangeLogWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
<Page Include="ChangeLogWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

View File

@ -61,7 +61,7 @@
ManipulationBoundaryFeedback="SCManipulationBoundaryFeedback">
<StackPanel Margin="20,20,20,20">
<TextBlock FontSize="14" Margin="0,0,0,0"
Text="*设置将自动保存,再次点击“设置”按钮关闭此页面。"/>
Text="*设置将自动保存,再次点击“设置”按钮即可关闭此页面。"/>
<TextBlock FontSize="14" Margin="0,0,0,12"
Text="*部分设置可能需要重新打开后生效。"/>
<GroupBox Header="行为">
@ -110,11 +110,31 @@
<ui:ToggleSwitch Name="ToggleSwitchShowButtonExit" Header="显示“退出”按钮" IsOn="True" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowButtonExit_Toggled"/>
<Button Content="立即退出" Width="120" FontFamily="Microsoft YaHei UI" Click="BtnExit_Click" Margin="0,0,0,10"/>
<ui:ToggleSwitch Name="ToggleSwitchShowButtonEraser" Header="显示“橡皮”按钮" IsOn="True" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowButtonEraser_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchShowButtonHideControl" Header="显示“⇅ (显示或隐藏控制按钮)”按钮" IsOn="True" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowButtonHideControl_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchShowButtonLRSwitch" Header="显示“⇆ (左右切换)”按钮" IsOn="True" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowButtonLRSwitch_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchShowButtonHideControl" Header="显示“⇅ (显示或隐藏控制按钮)”按钮" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowButtonHideControl_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchShowButtonLRSwitch" Header="显示“⇆ (左右切换)”按钮" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowButtonLRSwitch_Toggled"/>
<ui:ToggleSwitch Name="ToggleSwitchShowButtonModeFinger" Header="显示“手指模式”切换按钮" IsOn="True" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowButtonModeFinger_Toggled"/>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Header="重置">
<ui:SimpleStackPanel Spacing="12">
<StackPanel>
<TextBlock FontSize="14" Margin="0,0,0,12"
Text="重置设置为推荐设置"/>
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="12">
<Button Content="重置" Width="100" FontFamily="Microsoft YaHei UI" Click="BtnResetToSuggestion_Click" Margin="0,0,0,0"/>
<ui:SymbolIcon Name="SymbolIconResetSuggestionComplete" Symbol="Accept" Visibility="Collapsed"/>
</ui:SimpleStackPanel>
</StackPanel>
<StackPanel>
<TextBlock FontSize="14" Margin="0,0,0,12"
Text="重置设置为默认设置"/>
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="12">
<Button Content="重置" Width="100" FontFamily="Microsoft YaHei UI" Click="BtnResetToDefault_Click" Margin="0,0,0,10"/>
<ui:SymbolIcon Name="SymbolIconResetDefaultComplete" Symbol="Accept" Visibility="Collapsed"/>
</ui:SimpleStackPanel>
</StackPanel>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Header="关于">
<ui:SimpleStackPanel Spacing="12">
<ui:SimpleStackPanel Orientation="Horizontal" Spacing="4">
@ -286,9 +306,12 @@
<Button Name="BtnSelect" Content="选择&#x000A;墨迹" Visibility="Visible" FontFamily="Microsoft YaHei UI"
Margin="0,25,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnSelect_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button Name="BtnClearAndHideCanvas" Content="清屏&#x000A;&amp;&#x000A;隐藏" Visibility="Collapsed" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}" Block.TextAlignment="Center"
Click="BtnSelect_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<StackPanel Visibility="{Binding ElementName=StackPanelPPTControls, Path=Visibility}">
<Button Content="↑" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Margin="0,25,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnPPTSlidesUp_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button Content="↓" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"

View File

@ -162,7 +162,7 @@ namespace Ink_Canvas
Application.Current.Dispatcher.Invoke(() =>
{
Close();
Application.Current.Shutdown();
});
}
}
@ -175,7 +175,34 @@ namespace Ink_Canvas
catch { }
})).Start();
loadPenCanvas();
//加载设置
LoadSettings();
Version version = Assembly.GetExecutingAssembly().GetName().Version;
TextBlockVersion.Text = version.ToString();
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
string lastVersion = "";
try
{
lastVersion = File.ReadAllText("versions.ini");
}
catch { }
if (!lastVersion.Contains(version.ToString()))
{
new ChangeLogWindow().ShowDialog();
lastVersion += "\n" + version.ToString();
File.WriteAllText("versions.ini", lastVersion.Trim());
}
isLoaded = true;
}
private void LoadSettings(bool isStartup = true)
{
if (File.Exists(settingsFileName))
{
try
@ -191,41 +218,88 @@ namespace Ink_Canvas
ToggleSwitchModeFinger.IsOn = true;
ToggleSwitchAutoEnterModeFinger.IsOn = true;
}
else
{
ToggleSwitchAutoEnterModeFinger.IsOn = false;
}
if (Settings.Startup.IsAutoHideCanvas)
{
if (isStartup)
{
BtnHideInkCanvas_Click(BtnHideInkCanvas, null);
}
ToggleSwitchAutoHideCanvas.IsOn = true;
}
else
{
ToggleSwitchAutoHideCanvas.IsOn = false;
}
if (!Settings.Appearance.IsShowEraserButton)
if (Settings.Appearance.IsShowEraserButton)
{
BtnErase.Visibility = Visibility.Visible;
ToggleSwitchShowButtonEraser.IsOn = true;
}
else
{
BtnErase.Visibility = Visibility.Collapsed;
ToggleSwitchShowButtonEraser.IsOn = false;
}
if (!Settings.Appearance.IsShowExitButton)
if (Settings.Appearance.IsShowExitButton)
{
BtnExit.Visibility = Visibility.Visible;
ToggleSwitchShowButtonExit.IsOn = true;
}
else
{
BtnExit.Visibility = Visibility.Collapsed;
ToggleSwitchShowButtonExit.IsOn = false;
}
if (!Settings.Appearance.IsShowHideControlButton)
if (Settings.Appearance.IsShowHideControlButton)
{
BtnHideControl.Visibility = Visibility.Visible;
ToggleSwitchShowButtonHideControl.IsOn = true;
}
else
{
BtnHideControl.Visibility = Visibility.Collapsed;
ToggleSwitchShowButtonHideControl.IsOn = false;
}
if (!Settings.Appearance.IsShowLRSwitchButton)
if (Settings.Appearance.IsShowLRSwitchButton)
{
BtnSwitchSide.Visibility = Visibility.Visible;
ToggleSwitchShowButtonLRSwitch.IsOn = true;
}
else
{
BtnSwitchSide.Visibility = Visibility.Collapsed;
ToggleSwitchShowButtonLRSwitch.IsOn = false;
}
if (!Settings.Appearance.IsShowModeFingerToggleSwitch)
if (Settings.Appearance.IsShowModeFingerToggleSwitch)
{
StackPanelModeFinger.Visibility = Visibility.Visible;
ToggleSwitchShowButtonModeFinger.IsOn = true;
}
else
{
StackPanelModeFinger.Visibility = Visibility.Collapsed;
ToggleSwitchShowButtonModeFinger.IsOn = false;
}
if (!Settings.Appearance.IsTransparentButtonBackground)
if (Settings.Appearance.IsTransparentButtonBackground)
{
BtnExit.Background = new SolidColorBrush(StringToColor("#7F909090"));
}
else
{
if (BtnSwitchTheme.Content.ToString() == "深色")
{
//Light
BtnExit.Background = new SolidColorBrush(StringToColor("#FFCCCCCC"));
}
else
{
//Dark
BtnExit.Background = new SolidColorBrush(StringToColor("#FF555555"));
}
}
if (Settings.Behavior.PowerPointSupport)
{
@ -236,28 +310,43 @@ namespace Ink_Canvas
else
{
ToggleSwitchSupportPowerPoint.IsOn = false;
timerCheckPPT.Stop();
}
if (!Settings.Behavior.IsShowCanvasAtNewSlideShow)
if (Settings.Behavior.IsShowCanvasAtNewSlideShow)
{
ToggleSwitchShowCanvasAtNewSlideShow.IsOn = true;
}
else
{
ToggleSwitchShowCanvasAtNewSlideShow.IsOn = false;
}
if (Settings.Gesture == null)
{
Settings.Gesture = new Gesture();
}
if (Settings.Gesture.IsEnableTwoFingerRotation)
{
ToggleSwitchEnableTwoFingerRotation.IsOn = true;
}
else
{
ToggleSwitchEnableTwoFingerRotation.IsOn = false;
}
if (Settings.Gesture.IsEnableTwoFingerGestureInPresentationMode)
{
ToggleSwitchEnableTwoFingerGestureInPresentationMode.IsOn = true;
}
else
{
ToggleSwitchEnableTwoFingerGestureInPresentationMode.IsOn = false;
}
if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\InkCanvas" + ".lnk"))
{
ToggleSwitchRunAtStartup.IsOn = true;
}
loadPenCanvas();
if (Settings.Canvas != null)
{
drawingAttributes.Height = Settings.Canvas.InkWidth;
@ -270,20 +359,18 @@ namespace Ink_Canvas
ToggleSwitchShowCursor.IsOn = true;
inkCanvas.ForceCursor = true;
}
else
{
ToggleSwitchShowCursor.IsOn = false;
inkCanvas.ForceCursor = false;
}
}
else
{
Settings.Canvas = new Canvas();
}
Version version = Assembly.GetExecutingAssembly().GetName().Version;
TextBlockVersion.Text = version.ToString();
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light;
isLoaded = true;
}
string settingsFileName = "settings.json";
bool isLoaded = false;
@ -374,7 +461,7 @@ namespace Ink_Canvas
#region Buttons - Color
int inkColor = 0;
int inkColor = 1;
private void ColorSwitchCheck()
{
@ -665,14 +752,14 @@ namespace Ink_Canvas
private void BtnSwitchSide_Click(object sender, RoutedEventArgs e)
{
if (StackPanelMain.HorizontalAlignment == HorizontalAlignment.Right)
if (ViewBoxStackPanelMain.HorizontalAlignment == HorizontalAlignment.Right)
{
StackPanelMain.HorizontalAlignment = HorizontalAlignment.Left;
ViewBoxStackPanelMain.HorizontalAlignment = HorizontalAlignment.Left;
StackPanelShapes.HorizontalAlignment = HorizontalAlignment.Right;
}
else
{
StackPanelMain.HorizontalAlignment = HorizontalAlignment.Right;
ViewBoxStackPanelMain.HorizontalAlignment = HorizontalAlignment.Right;
StackPanelShapes.HorizontalAlignment = HorizontalAlignment.Left;
}
}
@ -1525,6 +1612,56 @@ namespace Ink_Canvas
SaveSettingsToFile();
}
private void BtnResetToSuggestion_Click(object sender, RoutedEventArgs e)
{
try
{
isLoaded = false;
Settings = new Settings();
Settings.Appearance.IsShowEraserButton = false;
Settings.Appearance.IsShowExitButton = false;
Settings.Startup.IsAutoHideCanvas = true;
SaveSettingsToFile();
LoadSettings(false);
isLoaded = true;
if (ToggleSwitchRunAtStartup.IsOn == false)
{
ToggleSwitchRunAtStartup.IsOn = true;
}
}
catch { }
SymbolIconResetSuggestionComplete.Visibility = Visibility.Visible;
new Thread(new ThreadStart(() => {
Thread.Sleep(5000);
Application.Current.Dispatcher.Invoke(() =>
{
SymbolIconResetSuggestionComplete.Visibility = Visibility.Collapsed;
});
})).Start();
}
private void BtnResetToDefault_Click(object sender, RoutedEventArgs e)
{
try
{
isLoaded = false;
File.Delete("settings.json");
Settings = new Settings();
LoadSettings(false);
isLoaded = true;
}
catch { }
SymbolIconResetDefaultComplete.Visibility = Visibility.Visible;
new Thread(new ThreadStart(() => {
Thread.Sleep(5000);
Application.Current.Dispatcher.Invoke(() =>
{
SymbolIconResetDefaultComplete.Visibility = Visibility.Collapsed;
});
})).Start();
}
}
enum HotkeyModifiers

View File

@ -62,9 +62,9 @@ namespace Ink_Canvas
[JsonProperty("isShowEraserButton")]
public bool IsShowEraserButton { get; set; } = true;
[JsonProperty("isShowHideControlButton")]
public bool IsShowHideControlButton { get; set; } = true;
public bool IsShowHideControlButton { get; set; } = false;
[JsonProperty("isShowLRSwitchButton")]
public bool IsShowLRSwitchButton { get; set; } = true;
public bool IsShowLRSwitchButton { get; set; } = false;
[JsonProperty("isShowModeFingerToggleSwitch")]
public bool IsShowModeFingerToggleSwitch { get; set; } = true;
}