Fix bug and add more settings

This commit is contained in:
XY Wang 2021-09-25 13:38:27 +08:00
parent b0e39547b5
commit 7852a87b2e
3 changed files with 99 additions and 16 deletions

View File

@ -31,11 +31,11 @@
<Grid Name="GridBackgroundCover" Visibility="Hidden" Background="#FFF2F2F2"/>
</Grid>
<Label Name="Label" Visibility="Collapsed" Content="0"/>
<InkCanvas Name="inkCanvas" Background="Transparent"
<InkCanvas Name="inkCanvas" Background="Transparent" Cursor="Pen" ForceCursor="False"
TouchUp="Main_Grid_TouchUp" TouchDown="Main_Grid_TouchDown"
ManipulationDelta="Main_Grid_ManipulationDelta"
ManipulationCompleted="Main_Grid_ManipulationCompleted"
IsManipulationEnabled="True">
IsManipulationEnabled="True" EditingModeChanged="inkCanvas_EditingModeChanged">
<!--<InkCanvas.DefaultDrawingAttributes>
<DrawingAttributes StylusTip="Ellipse" Height="8" Width="4" IgnorePressure="False" FitToCurve="True" >
<DrawingAttributes.StylusTipTransform>
@ -83,6 +83,7 @@
VerticalAlignment="Bottom" Margin="10,0,0,8"
FontSize="14"/>
</StackPanel>
<ui:ToggleSwitch Name="ToggleSwitchShowCursor" Header="显示画笔光标" IsOn="False" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchShowCursor_Toggled"/>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Header="启动">
@ -93,6 +94,7 @@
</GroupBox>
<GroupBox Header="外观">
<ui:SimpleStackPanel Spacing="12">
<ui:ToggleSwitch Name="ToggleSwitchTransparentButtonBackground" Header="按钮背景半透明" IsOn="True" FontFamily="Microsoft YaHei UI" OnContent="开" OffContent="关" Toggled="ToggleSwitchTransparentButtonBackground_Toggled"/>
<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"/>
@ -167,7 +169,7 @@
Click="BtnExit_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
<Button Name="BtnSettings" Content="设置" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnSettings_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnSettings_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<TextBlock Text="自动&#x000A;粗细" Visibility="Collapsed" Margin="0,10,0,0"
FontSize="14" HorizontalAlignment="Center"
Foreground="{Binding ElementName=BtnExit, Path=Foreground}"/>
@ -188,16 +190,16 @@
</StackPanel>
<Button Name="BtnThickness" Content="粗细" Visibility="Collapsed" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnThickness_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnThickness_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button Name="BtnErase" Content="橡皮" Visibility="Visible" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnErase_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnErase_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button Name="BtnSwitchTheme" Content="深色" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnSwitchTheme_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnSwitchTheme_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button Name="BtnSwitch" Content="背景" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnSwitch_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnSwitch_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<StackPanel Name="StackPanelColors" Margin="7,0,7,0">
<Button Name="BtnColorBlack" Content="" FontFamily="Microsoft YaHei UI" Background="Black"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelColors, Path=ActualWidth}"
@ -217,34 +219,34 @@
</StackPanel>
<Button Name="BtnClear" Content="清屏" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnClear_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnClear_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button x:Name="BtnHideInkCanvas" Content="隐藏&#x000A;画板" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnHideInkCanvas_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnHideInkCanvas_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button x:Name="BtnCheckPPT" Visibility="Collapsed" Content="检查" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnCheckPPT_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnCheckPPT_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button x:Name="BtnPPTSlideShow" Visibility="Collapsed" Content="从头&#x000A;放映" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnPPTSlideShow_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnPPTSlideShow_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button x:Name="BtnPPTSlideShowEnd" Visibility="Collapsed" Content="结束&#x000A;放映" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnPPTSlideShowEnd_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnPPTSlideShowEnd_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<StackPanel Name="StackPanelPPTControls" Visibility="Collapsed">
<Button x:Name="BtnPPTSlidesUp" Content="↑" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnPPTSlidesUp_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnPPTSlidesUp_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<Button x:Name="BtnPPTSlidesDown" Content="↓" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnPPTSlidesDown_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnPPTSlidesDown_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
</StackPanel>
<Button x:Name="BtnSwitchSide" Content="⇆" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnSwitchSide_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnSwitchSide_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
</StackPanel>
<Button x:Name="BtnHideControl" Content="⇅" FontFamily="Microsoft YaHei UI"
Margin="0,10,0,0" Width="{Binding ElementName=StackPanelMain, Path=ActualWidth}"
Click="BtnHideControl_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="#7F909090"/>
Click="BtnHideControl_Click" Foreground="{Binding ElementName=BtnExit, Path=Foreground}" Background="{Binding ElementName=BtnExit, Path=Background}"/>
<TextBlock Visibility="{Binding ElementName=GroupBoxMASEZVersion, Path=Visibility}" Text="二中专版" FontSize="11" FontWeight="Bold" HorizontalAlignment="Center" Margin="0,10,0,0" Foreground="{Binding ElementName=BtnExit, Path=Foreground}"/>
<Image Visibility="{Binding ElementName=GroupBoxMASEZVersion, Path=Visibility}" Source="logo2.png" Margin="0,-5,0,-15"/>

View File

@ -309,6 +309,10 @@ namespace Ink_Canvas
StackPanelModeFinger.Visibility = Visibility.Collapsed;
ToggleSwitchShowButtonModeFinger.IsOn = false;
}
if (!Settings.Appearance.IsTransparentButtonBackground)
{
BtnExit.Background = new SolidColorBrush(StringToColor("#FFCCCCCC"));
}
if (Settings.Behavior.PowerPointSupport)
{
@ -338,11 +342,24 @@ namespace Ink_Canvas
drawingAttributes.Width = Settings.Canvas.InkWidth;
InkWidthSlider.Value = Settings.Canvas.InkWidth * 2;
if (Settings.Canvas.IsShowCursor)
{
ToggleSwitchShowCursor.IsOn = true;
inkCanvas.ForceCursor = true;
}
}
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";
@ -555,6 +572,7 @@ namespace Ink_Canvas
{
if (e.Manipulators.Count() == 0)
{
if (forceEraser) return;
inkCanvas.EditingMode = InkCanvasEditingMode.Ink;
}
}
@ -616,6 +634,10 @@ namespace Ink_Canvas
inkCanvas.DefaultDrawingAttributes.Color = Colors.Black;
}
}
if (!Settings.Appearance.IsTransparentButtonBackground)
{
ToggleSwitchTransparentButtonBackground_Toggled(ToggleSwitchTransparentButtonBackground, null);
}
}
@ -1222,6 +1244,61 @@ namespace Ink_Canvas
IPEndPoint ipEndPoint = new IPEndPoint(hostEntry.AddressList[0], 0);
return ipEndPoint.Address.ToString();
}
private void inkCanvas_EditingModeChanged(object sender, RoutedEventArgs e)
{
if (Settings.Canvas.IsShowCursor)
{
if(((InkCanvas)sender).EditingMode == InkCanvasEditingMode.Ink)
{
((InkCanvas)sender).ForceCursor = true;
}
else
{
((InkCanvas)sender).ForceCursor = false;
}
}
else
{
((InkCanvas)sender).ForceCursor = false;
}
}
private void ToggleSwitchTransparentButtonBackground_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Appearance.IsTransparentButtonBackground = ToggleSwitchTransparentButtonBackground.IsOn;
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"));
}
}
SaveSettingsToFile();
}
private void ToggleSwitchShowCursor_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
Settings.Canvas.IsShowCursor = ToggleSwitchShowCursor.IsOn;
inkCanvas_EditingModeChanged(inkCanvas, null);
SaveSettingsToFile();
}
}
enum HotkeyModifiers

View File

@ -31,6 +31,8 @@ namespace Ink_Canvas
{
[JsonProperty("inkWidth")]
public double InkWidth { get; set; } = 2.5;
[JsonProperty("isShowCursor")]
public bool IsShowCursor { get; set; } = false;
}
public class Startup
@ -43,6 +45,8 @@ namespace Ink_Canvas
public class Appearance
{
[JsonProperty("isTransparentButtonBackground")]
public bool IsTransparentButtonBackground { get; set; } = true;
[JsonProperty("isShowExitButton")]
public bool IsShowExitButton { get; set; } = true;
[JsonProperty("isShowEraserButton")]