add:新设置

This commit is contained in:
2025-08-31 15:35:28 +08:00
parent 21932056f3
commit edb206ffa5
14 changed files with 4618 additions and 6 deletions
+3 -6
View File
@@ -24,12 +24,8 @@
<BootstrapperEnabled>false</BootstrapperEnabled>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<UseWPF>true</UseWPF>
<Configurations>Debug;Release;x86 Debug</Configurations>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>embedded</DebugType>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Prefer32Bit>True</Prefer32Bit>
<Configurations>Release;x86 Debug;Debug</Configurations>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='x86 Debug|AnyCPU'">
<DebugType>embedded</DebugType>
@@ -128,6 +124,7 @@
<Reference Include="System.Windows.Forms" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Management" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml" />
<Reference Include="UIAutomationClient" />
+15
View File
@@ -531,6 +531,21 @@
</ui:SimpleStackPanel>
</ui:SimpleStackPanel>
</Border>
<GroupBox Name="GroupBoxNewSettings">
<GroupBox.Header>
<TextBlock Margin="0,12,0,0" Text="新设置窗口" FontWeight="Bold" Foreground="#fafafa"
FontSize="26" />
</GroupBox.Header>
<ui:SimpleStackPanel Spacing="6" Margin="0,10,0,0">
<TextBlock TextWrapping="Wrap" Margin="0,0,0,10" Foreground="#fafafa">
打开新的设置窗口,提供更丰富的设置选项和更好的用户体验。
</TextBlock>
<Button x:Name="BtnOpenNewSettings" Content="打开新设置窗口"
HorizontalAlignment="Left" Click="BtnOpenNewSettings_Click"
Padding="15,5" Margin="0,10,0,0"/>
</ui:SimpleStackPanel>
</GroupBox>
<GroupBox Name="GroupBoxPlugins">
<GroupBox.Header>
<TextBlock Margin="0,12,0,0" Text="插件管理" FontWeight="Bold" Foreground="#fafafa"
+16
View File
@@ -1592,6 +1592,22 @@ namespace Ink_Canvas
}
#endregion ???
#region
// 添加打开新设置窗口按钮点击事件
private void BtnOpenNewSettings_Click(object sender, RoutedEventArgs e)
{
if (isOpeningOrHidingSettingsPane) return;
HideSubPanels();
{
var settingsWindow = new SettingsWindow();
settingsWindow.Owner = this;
settingsWindow.ShowDialog();
}
}
#endregion
// 在MainWindow类中添加:
private void ApplyCurrentEraserShape()
{
@@ -0,0 +1,191 @@
<UserControl x:Class="Ink_Canvas.Windows.SettingsViews.AboutPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews"
mc:Ignorable="d"
d:DesignHeight="950" d:DesignWidth="640">
<UserControl.Resources>
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<EventSetter Event="PreviewMouseDown" Handler="ScrollbarThumb_MouseDown"/>
<EventSetter Event="PreviewMouseUp" Handler="ScrollbarThumb_MouseUp"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Border Name="ScrollbarThumbEx"
SnapsToDevicePixels="True"
Background="#c3c3c3"
Opacity="0.5"
CornerRadius="1.5"
Height="{TemplateBinding Height}"
Width="3" HorizontalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ScrollBar}">
<EventSetter Event="Scroll" Handler="ScrollBar_Scroll"/>
<Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
<Setter Property="Width" Value="8"/>
<Setter Property="Margin" Value="-6 3 0 0" />
<Setter Property="MinWidth" Value="{Binding Height, RelativeSource={RelativeSource Self}}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollBar}">
<Grid x:Name="ScrollbarGrid" SnapsToDevicePixels="true">
<Border Width="3" CornerRadius="1.5" Background="#e0e0e0" Opacity="0" IsHitTestVisible="False" Margin="0 4 -2 4" x:Name="ScrollBarBorderTrackBackground"/>
<Border Padding="0 4" Background="Transparent" MouseEnter="ScrollBarTrack_MouseEnter"
MouseLeave="ScrollBarTrack_MouseLeave">
<Track x:Name="PART_Track"
IsDirectionReversed="true"
IsEnabled="True"
Width="6"
Margin="0,0,0,0"
HorizontalAlignment="Right">
<Track.DecreaseRepeatButton>
<RepeatButton Opacity="0" Command="{x:Static ScrollBar.PageUpCommand}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Opacity="0" Command="{x:Static ScrollBar.PageDownCommand}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb }" />
</Track.Thumb>
</Track>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<ScrollViewer ScrollChanged="ScrollViewerEx_ScrollChanged" IsManipulationEnabled="True" Name="AboutScrollViewerEx" IsDeferredScrollingEnabled="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" IsTabStop="False" TabIndex="-1" Margin="0,0,2,2">
<StackPanel Margin="0,12,0,24" HorizontalAlignment="Center" Width="524">
<Border BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<Image Name="CopyrightBannerImage"/>
</Border>
<Border Margin="0,25,0,0" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<StackPanel Orientation="Vertical">
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#9a9996" FontSize="12" Margin="0,0,0,3" Text="用户版权信息" HorizontalAlignment="Left"/>
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="2024 孙笑川一中 高2026级114班" HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
</StackPanel>
</Border>
<Border Margin="0,25,0,0" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<StackPanel Orientation="Vertical">
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="软件版本" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,18,0">
<TextBlock Foreground="#878787" FontSize="14.5" Text="InkCanvasForClass v2024.8.30" VerticalAlignment="Center" />
<Image Margin="12,0,0,0" Width="18" Height="18" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<DrawingGroup.Transform>
<TranslateTransform X="6.1023980379104614E-05" Y="0" />
</DrawingGroup.Transform>
<GeometryDrawing Brush="#FFFF7800" Geometry="F1 M16,16z M0,0z M8.00493,0C7.74518,0,7.49541,0.0999063,7.2956,0.289728L5.5872,1.99813 2.99963,1.99813C2.45014,1.99813,2.00056,2.44771,2.00056,2.99719L2.00056,5.58476 0.292165,7.29316C-0.0974697,7.6828,-0.0974697,8.31221,0.292165,8.70184L2.00056,10.4102 2.00056,12.9978C2.00056,13.5473,2.45014,13.9969,2.99963,13.9969L5.5872,13.9969 7.2956,15.7053C7.68523,16.0949,8.31464,16.0949,8.70428,15.7053L10.4127,13.9969 13.0003,13.9969C13.5497,13.9969,13.9993,13.5473,13.9993,12.9978L13.9993,10.4102 15.7077,8.70184C16.0973,8.31221,16.0973,7.6828,15.7077,7.29316L13.9993,5.58476 13.9993,2.99719C13.9993,2.44771,13.5497,1.99813,13.0003,1.99813L10.4127,1.99813 8.70428,0.289728C8.50447,0.0899157,8.2547,0,7.99494,0L8.00493,0z M8.00493,4.99532C8.26469,4.99532,8.51446,5.09522,8.71427,5.28505L10.7124,7.28317C10.9022,7.47299,11.0021,7.72276,11.0021,7.99251L11.0021,8.99157 9.004,8.99157 9.004,10.9897 7.00587,10.9897 7.00587,8.99157 5.00774,8.99157 5.00774,7.99251C5.00774,7.73275,5.10765,7.47299,5.29747,7.28317L7.2956,5.28505C7.49541,5.08523,7.74518,4.99532,8.00493,4.99532z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</StackPanel>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="系统版本" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<TextBlock Name="AboutSystemVersion" Foreground="#878787" FontSize="14.5" Text="Windows 10 专业版 19045.3758" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,18,0"/>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="触摸设备" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<TextBlock Name="AboutTouchTabletText" Foreground="#878787" FontSize="14.5" Text="无触摸支持" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,18,0"/>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="包体构建版本" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<TextBlock Name="AboutBuildTime" Foreground="#878787" FontSize="14.5" Text="2024.8.22" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,18,0"/>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="版权信息" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<TextBlock Foreground="#878787" FontSize="14.5" Text="© Copyright 2024 Dubi906w 所有" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,18,0"/>
</Grid>
</StackPanel>
</Border>
<Border Margin="0,25,0,0" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<StackPanel Orientation="Vertical">
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="ICC 官方网站" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,18,0">
<TextBlock Foreground="#1d4ed8" TextDecorations="Underline" FontSize="14.5" Text="icc.bliemhax.com" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<Image Margin="12,0,0,0" Width="16" Height="16" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<GeometryDrawing Brush="#FF222222" Geometry="F1 M16,16z M0,0z M3,2C1.338,2,0,3.338,0,5L0,13C0,14.662,1.338,16,3,16L11,16C12.662,16,14,14.662,14,13L14,9C13.9998,8.4477 13.5522,8 13,8 12.4478,8 12.0002,8.4477 12,9L12,13C12,13.554,11.554,14,11,14L3,14C2.446,14,2,13.554,2,13L2,5C2,4.446,2.446,4,3,4L7,4C7.5523,4 8,3.5523 8,3 8,2.4477 7.5523,2 7,2L3,2z M10,0C9.4477,0 9,0.4477 9,1 9,1.5523 9.4477,2 10,2L12.584,2 7.29303,7.29102C6.90133,7.68172 6.90133,8.31627 7.29303,8.70697 7.68353,9.09737 8.31659,9.09737 8.70709,8.70697L14,3.41412 14,6C14,6.5523 14.4477,7 15,7 15.5523,7 16,6.5523 16,6L16,1C15.9996,0.913 15.988,0.826187 15.965,0.742188 15.942,0.657187 15.909,0.576 15.865,0.5 15.822,0.424 15.768,0.35483 15.7068,0.29303 15.6918,0.28103 15.6758,0.268996 15.6598,0.257996 15.6048,0.207996 15.5433,0.164989 15.4782,0.129089 15.4412,0.110089 15.4022,0.0940781 15.363,0.0800781 15.312,0.0590781 15.2601,0.0431279 15.2067,0.0311279 15.1667,0.0211279 15.1267,0.0171226 15.0856,0.0131226 15.0566,0.00312256 15.0286,0.00309863 14.9996,0.00109863L10,0z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</StackPanel>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="Github 仓库" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,18,0">
<TextBlock Foreground="#1d4ed8" TextDecorations="Underline" FontSize="14.5" Text="github.com/InkCanvas/InkCanvasForClass" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<Image Margin="12,0,0,0" Width="16" Height="16" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<GeometryDrawing Brush="#FF222222" Geometry="F1 M16,16z M0,0z M3,2C1.338,2,0,3.338,0,5L0,13C0,14.662,1.338,16,3,16L11,16C12.662,16,14,14.662,14,13L14,9C13.9998,8.4477 13.5522,8 13,8 12.4478,8 12.0002,8.4477 12,9L12,13C12,13.554,11.554,14,11,14L3,14C2.446,14,2,13.554,2,13L2,5C2,4.446,2.446,4,3,4L7,4C7.5523,4 8,3.5523 8,3 8,2.4477 7.5523,2 7,2L3,2z M10,0C9.4477,0 9,0.4477 9,1 9,1.5523 9.4477,2 10,2L12.584,2 7.29303,7.29102C6.90133,7.68172 6.90133,8.31627 7.29303,8.70697 7.68353,9.09737 8.31659,9.09737 8.70709,8.70697L14,3.41412 14,6C14,6.5523 14.4477,7 15,7 15.5523,7 16,6.5523 16,6L16,1C15.9996,0.913 15.988,0.826187 15.965,0.742188 15.942,0.657187 15.909,0.576 15.865,0.5 15.822,0.424 15.768,0.35483 15.7068,0.29303 15.6918,0.28103 15.6758,0.268996 15.6598,0.257996 15.6048,0.207996 15.5433,0.164989 15.4782,0.129089 15.4412,0.110089 15.4022,0.0940781 15.363,0.0800781 15.312,0.0590781 15.2601,0.0431279 15.2067,0.0311279 15.1667,0.0211279 15.1267,0.0171226 15.0856,0.0131226 15.0566,0.00312256 15.0286,0.00309863 14.9996,0.00109863L10,0z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</StackPanel>
</Grid>
<Border Height="1" Background="#ebebeb"/>
<Grid Height="54">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="贡献者名单" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="18,0,0,0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,18,0">
<TextBlock Foreground="#1d4ed8" TextDecorations="Underline" FontSize="14.5" Text="icc.bliemhax.com/contributors" VerticalAlignment="Center" HorizontalAlignment="Right"/>
<Image Margin="12,0,0,0" Width="16" Height="16" VerticalAlignment="Center">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
<GeometryDrawing Brush="#FF222222" Geometry="F1 M16,16z M0,0z M3,2C1.338,2,0,3.338,0,5L0,13C0,14.662,1.338,16,3,16L11,16C12.662,16,14,14.662,14,13L14,9C13.9998,8.4477 13.5522,8 13,8 12.4478,8 12.0002,8.4477 12,9L12,13C12,13.554,11.554,14,11,14L3,14C2.446,14,2,13.554,2,13L2,5C2,4.446,2.446,4,3,4L7,4C7.5523,4 8,3.5523 8,3 8,2.4477 7.5523,2 7,2L3,2z M10,0C9.4477,0 9,0.4477 9,1 9,1.5523 9.4477,2 10,2L12.584,2 7.29303,7.29102C6.90133,7.68172 6.90133,8.31627 7.29303,8.70697 7.68353,9.09737 8.31659,9.09737 8.70709,8.70697L14,3.41412 14,6C14,6.5523 14.4477,7 15,7 15.5523,7 16,6.5523 16,6L16,1C15.9996,0.913 15.988,0.826187 15.965,0.742188 15.942,0.657187 15.909,0.576 15.865,0.5 15.822,0.424 15.768,0.35483 15.7068,0.29303 15.6918,0.28103 15.6758,0.268996 15.6598,0.257996 15.6048,0.207996 15.5433,0.164989 15.4782,0.129089 15.4412,0.110089 15.4022,0.0940781 15.363,0.0800781 15.312,0.0590781 15.2601,0.0431279 15.2067,0.0311279 15.1667,0.0211279 15.1267,0.0171226 15.0856,0.0131226 15.0566,0.00312256 15.0286,0.00309863 14.9996,0.00109863L10,0z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
</StackPanel>
</Grid>
</StackPanel>
</Border>
<StackPanel Orientation="Vertical" Margin="0,16,0,0">
<TextBlock Foreground="#2e3436" FontWeight="Bold" FontSize="12" Text="© Copyright 2024 Dubi906w(Doubx690i/kriastans) 所有" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,15,0"/>
<TextBlock Foreground="#878787" Width="356" FlowDirection="RightToLeft" TextWrapping="Wrap" FontSize="12" Text="ICC 的部分元素设计参考来源于:© iNKORE! 名下产品 Inkways,已经过授权使用,最终解释权归 Yoojun Zhou 所有" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,6,15,0"/>
<TextBlock Foreground="#878787" FontWeight="Bold" Width="276" FlowDirection="RightToLeft" TextWrapping="Wrap" FontSize="12" Text="ICC 使用了 iNKORE! 开发的 UI 组件库:iNKORE.UI.WPF.Modern" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,6,15,0"/>
</StackPanel>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
@@ -0,0 +1,243 @@
using OSVersionExtension;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using iNKORE.UI.WPF.Helpers;
using static Ink_Canvas.Windows.SettingsWindow;
namespace Ink_Canvas.Windows.SettingsViews {
/// <summary>
/// AboutPanel.xaml 的交互逻辑
/// </summary>
public partial class AboutPanel : UserControl {
public AboutPanel() {
InitializeComponent();
// 关于页面图片横幅
if (File.Exists(App.RootPath + "icc-about-illustrations.png")) {
try {
CopyrightBannerImage.Visibility = Visibility.Visible;
CopyrightBannerImage.Source =
new BitmapImage(new Uri($"file://{App.RootPath + "icc-about-illustrations.png"}"));
}
catch { }
} else {
CopyrightBannerImage.Visibility = Visibility.Collapsed;
}
// 关于页面构建时间
var buildTime = FileBuildTimeHelper.GetBuildDateTime(System.Reflection.Assembly.GetExecutingAssembly());
if (buildTime != null) {
var bt = ((DateTimeOffset)buildTime).LocalDateTime;
var m = bt.Month.ToString().PadLeft(2, '0');
var d = bt.Day.ToString().PadLeft(2, '0');
var h = bt.Hour.ToString().PadLeft(2, '0');
var min = bt.Minute.ToString().PadLeft(2, '0');
var s = bt.Second.ToString().PadLeft(2, '0');
AboutBuildTime.Text =
$"build-{bt.Year}-{m}-{d}-{h}:{min}:{s}";
}
// 关于页面系统版本
AboutSystemVersion.Text = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}";
// 关于页面触摸设备
var _t_touch = new Thread(() => {
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
var support = TouchTabletDetectHelper.IsTouchEnabled();
Dispatcher.BeginInvoke(() =>
AboutTouchTabletText.Text = $"{touchcount}个设备,{(support ? "" : "")}");
});
_t_touch.Start();
}
public static class TouchTabletDetectHelper {
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int GetSystemMetrics(int nIndex);
public static bool IsTouchEnabled()
{
const int MAXTOUCHES_INDEX = 95;
int maxTouches = GetSystemMetrics(MAXTOUCHES_INDEX);
return maxTouches > 0;
}
public class USBDeviceInfo
{
public USBDeviceInfo(string deviceID, string pnpDeviceID, string description)
{
this.DeviceID = deviceID;
this.PnpDeviceID = pnpDeviceID;
this.Description = description;
}
public string DeviceID { get; private set; }
public string PnpDeviceID { get; private set; }
public string Description { get; private set; }
}
public static List<USBDeviceInfo> GetTouchTabletDevices()
{
List<USBDeviceInfo> devices = new List<USBDeviceInfo>();
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
collection = searcher.Get();
foreach (var device in collection) {
var name = new StringBuilder((string)device.GetPropertyValue("Name")).ToString();
if (!name.Contains("Pentablet")) continue;
devices.Add(new USBDeviceInfo(
(string)device.GetPropertyValue("DeviceID"),
(string)device.GetPropertyValue("PNPDeviceID"),
(string)device.GetPropertyValue("Description")
));
}
collection.Dispose();
return devices;
}
}
public static class FileBuildTimeHelper {
public struct _IMAGE_FILE_HEADER
{
public ushort Machine;
public ushort NumberOfSections;
public uint TimeDateStamp;
public uint PointerToSymbolTable;
public uint NumberOfSymbols;
public ushort SizeOfOptionalHeader;
public ushort Characteristics;
};
public static DateTimeOffset? GetBuildDateTime(Assembly assembly)
{
var path = assembly.Location;
if (File.Exists(path))
{
var buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
using (var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
fileStream.Position = 0x3C;
fileStream.Read(buffer, 0, 4);
fileStream.Position = BitConverter.ToUInt32(buffer, 0); // COFF header offset
fileStream.Read(buffer, 0, 4); // "PE\0\0"
fileStream.Read(buffer, 0, buffer.Length);
}
var pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER));
return DateTimeOffset.FromUnixTimeSeconds(coffHeader.TimeDateStamp);
}
finally
{
pinnedBuffer.Free();
}
}
else
{
return null;
}
}
}
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
public event EventHandler<RoutedEventArgs> IsTopBarNeedNoShadowEffect;
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e) {
var scrollViewer = (ScrollViewer)sender;
if (scrollViewer.VerticalOffset >= 10) {
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
} else {
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
}
}
private void ScrollBar_Scroll(object sender, RoutedEventArgs e) {
var scrollbar = (ScrollBar)sender;
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
}
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e) {
var border = (Border)sender;
if (border.Child is Track track) {
track.Width = 16;
track.Margin = new Thickness(0, 0, -2, 0);
var scrollbar = track.FindAscendant<ScrollBar>();
if (scrollbar != null) scrollbar.Width = 16;
var grid = track.FindAscendant<Grid>();
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
backgroundBorder.Width = 8;
backgroundBorder.CornerRadius = new CornerRadius(4);
backgroundBorder.Opacity = 1;
}
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
if (thumb != null) {
var _thumb = thumb as Border;
_thumb.CornerRadius = new CornerRadius(4);
_thumb.Width = 8;
_thumb.Margin = new Thickness(-0.75, 0, 1, 0);
_thumb.Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
}
}
}
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e) {
var border = (Border)sender;
border.Background = new SolidColorBrush(Colors.Transparent);
border.CornerRadius = new CornerRadius(0);
if (border.Child is Track track) {
track.Width = 6;
track.Margin = new Thickness(0, 0, 0, 0);
var scrollbar = track.FindAscendant<ScrollBar>();
if (scrollbar != null) scrollbar.Width = 6;
var grid = track.FindAscendant<Grid>();
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
backgroundBorder.Width = 3;
backgroundBorder.CornerRadius = new CornerRadius(1.5);
backgroundBorder.Opacity = 0;
}
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
if (thumb != null) {
var _thumb = thumb as Border;
_thumb.CornerRadius = new CornerRadius(1.5);
_thumb.Width = 3;
_thumb.Margin = new Thickness(0);
_thumb.Background = new SolidColorBrush(Color.FromRgb(195, 195, 195));
}
}
}
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e) {
var thumb = (Thumb)sender;
var border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
}
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e) {
var thumb = (Thumb)sender;
var border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
}
}
}
@@ -0,0 +1,12 @@
<UserControl x:Class="Ink_Canvas.Windows.SettingsViews.AppearancePanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<local:SettingsBaseView x:Name="BaseView"/>
</Grid>
</UserControl>
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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.Navigation;
using System.Windows.Shapes;
namespace Ink_Canvas.Windows.SettingsViews {
public partial class AppearancePanel : UserControl {
public AppearancePanel() {
InitializeComponent();
BaseView.SettingsPanels.Add(new SettingsViewPanel() {
Title = "新版设置测试",
Items = new ObservableCollection<SettingsItem>(new SettingsItem[] {
new SettingsItem() {
Title = "默认ToggleSwitch",
Description = "这是测试文本,这是测试文本",
Type = SettingsItemType.SingleToggleSwtich,
IsSeparatorVisible = true
},
new SettingsItem() {
Title = "默认开启的ToggleSwitch",
Description = "这是测试文本,这是测试文本324234324",
Type = SettingsItemType.SingleToggleSwtich,
IsSeparatorVisible = true,
ToggleSwitchToggled = true,
},
new SettingsItem() {
Title = "默认关闭的ToggleSwitch",
Description = "这是测试文本,这是测试文本fsdsdffsd",
Type = SettingsItemType.SingleToggleSwtich,
IsSeparatorVisible = true,
ToggleSwitchToggled = false,
},
new SettingsItem() {
Title = "绿色的ToggleSwitch",
Description = "这是测试文本,这是测试文本fs大风刮过4sd",
Type = SettingsItemType.SingleToggleSwtich,
IsSeparatorVisible = true,
ToggleSwitchToggled = true,
ToggleSwitchBackground = new SolidColorBrush(Color.FromRgb(51, 209, 122)),
},
new SettingsItem() {
Title = "默认禁用的的ToggleSwitch",
Description = "这是测试文本",
Type = SettingsItemType.SingleToggleSwtich,
IsSeparatorVisible = true,
ToggleSwitchToggled = true,
ToggleSwitchEnabled = false,
ToggleSwitchBackground = new SolidColorBrush(Color.FromRgb(51, 209, 122)),
},
new SettingsItem() {
Title = "控制上面的ToggleSwitch是否启用",
Description = "12423432452312322335",
Type = SettingsItemType.SingleToggleSwtich,
IsSeparatorVisible = true,
ToggleSwitchToggled = false,
},
})
});
BaseView.SettingsPanels[0].Items[5].OnToggleSwitchToggled += (sender, args) => {
var item = (SettingsItem)sender;
BaseView.SettingsPanels[0].Items[4].ToggleSwitchEnabled = item.ToggleSwitchToggled;
};
}
}
}
@@ -0,0 +1,98 @@
<UserControl x:Class="Ink_Canvas.Windows.SettingsViews.FloatingBarDnDSettingsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews"
xmlns:dd="urn:gong-wpf-dragdrop"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="600">
<UserControl.Resources>
<DrawingImage x:Key="CursorIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#FF222222" Geometry="F1 M24,24z M0,0z M5.19409,16.3124C5.46422,18.0658 5.69121,19.539 5.8351,20.4621 5.9631,21.2477 6.80568,21.3359 7.22902,20.5643 7.93608,19.3044 9.20443,17.1009 10.0921,15.5636L14.9921,22.5615C15.1915,22.8462,15.5839,22.9154,15.8687,22.716L17.9309,21.272C18.2157,21.0727,18.2848,20.6802,18.0854,20.3955L13.5037,13.8522C15.6284,13.8519 18.6266,13.8518 20.2609,13.8524 21.1847,13.8201 21.258,12.9461 20.5777,12.4184 16.9666,9.91811 8.45126,4.12632 4.34164,1.42431 3.63839,0.928666 2.78717,1.12985 3.00557,2.27077 3.59731,5.94841 4.52718,11.9839 5.19409,16.3124z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="PenIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M20.4786,1.42438C19.9985,1.23743 19.4847,1.15194 18.9698,1.17319 18.4549,1.19444 17.9499,1.32197 17.4869,1.54789 17.0368,1.76752 16.6358,2.07554 16.3083,2.45361L3.85516,14.9067 9.08243,20.134 21.5311,7.68529C21.9113,7.36382 22.223,6.96912 22.447,6.52438 22.6786,6.06462 22.8113,5.56167 22.8365,5.04763 22.8616,4.5336 22.7787,4.02012 22.593,3.54002 22.4073,3.05994 22.1232,2.62403 21.759,2.25988 21.3949,1.89574 20.9587,1.61132 20.4786,1.42438z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M7.28056,21.1605L2.8286,16.7086 1.15912,22.83 7.28056,21.1605z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
<DrawingImage x:Key="EraserIcon">
<DrawingImage.Drawing>
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M15.6314,20.7262L22.7921,13.5655C24.3494,12.141,24.2819,9.81776,22.8105,8.34633L16.7793,2.31508C15.3547,0.757753,13.0315,0.825236,11.5601,2.29666L4.38099,9.47574 15.6314,20.7262z" />
<GeometryDrawing Brush="#222222" Geometry="F1 M24,24z M0,0z M14.2172,22.1404L2.96677,10.89 1.20761,12.6491C-0.34971,14.0737,-0.281711,16.3974,1.18971,17.8688L6.15089,22.83 13.5276,22.83 14.2172,22.1404z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</UserControl.Resources>
<Grid>
<StackPanel Orientation="Vertical">
<Border Name="ToolbarItemsControl" Height="46" Background="#ebebeb" Margin="0,0,6,0">
<Grid Margin="4,0">
<ItemsControl ikw:DragDrop.IsDragSource="True"
ikw:DragDrop.IsDropTarget="True"
ikw:DragDrop.DragMouseAnchorPoint="0.5,0.5"
ikw:DragDrop.DropHandler="{Binding}"
ItemsSource="{Binding BarItems}">
<ikw:DragDrop.DragAdornerTemplate>
<DataTemplate>
<Border HorizontalAlignment="Center" CornerRadius="6" Background="#fafafa" BorderBrush="#a3a3a3" BorderThickness="1" Width="38" Height="38">
<Image Source="{Binding IconSource}" Width="20" Height="20"></Image>
</Border>
</DataTemplate>
</ikw:DragDrop.DragAdornerTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Background="Transparent" Orientation="Horizontal" Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Border},AncestorLevel=1},Path=ActualWidth}"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border HorizontalAlignment="Center" CornerRadius="6" Margin="4,0,0,0" Background="#fafafa" BorderBrush="#a3a3a3" BorderThickness="1" Width="38" Height="38">
<Image Source="{Binding IconSource}" Width="20" Height="20"></Image>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Border>
<Border Name="ToolbarDrawerItemsControl" Height="46" Background="#ebebeb" Margin="0,0,6,0">
<Grid Margin="4,0">
<ItemsControl ikw:DragDrop.IsDragSource="True"
ikw:DragDrop.IsDropTarget="True"
ikw:DragDrop.DragMouseAnchorPoint="0,0"
ikw:DragDrop.DropHandler="{Binding}"
ItemsSource="{Binding BarDrawerItems}">
<ikw:DragDrop.DragAdornerTemplate>
<DataTemplate>
<Border HorizontalAlignment="Center" CornerRadius="6" Background="#fafafa" BorderBrush="#a3a3a3" BorderThickness="1" Width="38" Height="38">
<Image Source="{Binding IconSource}" Width="20" Height="20"></Image>
</Border>
</DataTemplate>
</ikw:DragDrop.DragAdornerTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Background="Transparent" Orientation="Horizontal" Width="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type Border},AncestorLevel=1},Path=ActualWidth}" HorizontalAlignment="Center"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border HorizontalAlignment="Center" CornerRadius="6" Margin="4,0,0,0" Background="#fafafa" BorderBrush="#a3a3a3" BorderThickness="1" Width="38" Height="38">
<Image Source="{Binding IconSource}" Width="20" Height="20"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Border>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,128 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
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.Navigation;
using System.Windows.Shapes;
using iNKORE.UI.WPF.DragDrop;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Menu;
namespace Ink_Canvas.Windows.SettingsViews {
public class FloatingBarItem {
public DrawingImage IconSource { get; set; }
}
public partial class FloatingBarDnDSettingsPanel : UserControl {
public class BarItemsDropTarget : IDropTarget {
public ObservableCollection<FloatingBarItem> BarItems { get; set; } =
new ObservableCollection<FloatingBarItem>();
void IDropTarget.DragOver(IDropInfo info) {
info.Effects = DragDropEffects.Move;
info.DropTargetAdorner = DropTargetAdorners.Insert;
}
void IDropTarget.Drop(IDropInfo info) {
if (info.Data is FloatingBarItem draggedItem) {
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
Trace.WriteLine(info.InsertIndex);
// 在同一个 ObservableCollection 中移动
if (targetCollection.Equals(sourceCollection)) {
if (info.InsertIndex == 0) {
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem),0);
} else if (info.InsertIndex == targetCollection.Count) {
targetCollection.Remove(info.Data as FloatingBarItem);
targetCollection.Add(info.Data as FloatingBarItem);
} else if ((info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 1 &&
info.InsertPosition == RelativeInsertPosition.AfterTargetItem) ||
(info.InsertIndex - targetCollection.IndexOf(info.Data as FloatingBarItem) == 0 &&
info.InsertPosition == RelativeInsertPosition.BeforeTargetItem)) { } else {
targetCollection.Move(targetCollection.IndexOf(info.Data as FloatingBarItem),info.InsertIndex - 1);
}
} else { // 跨 ObservableCollection 移动
sourceCollection.Remove(info.Data as FloatingBarItem);
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
}
}
}
void IDropTarget.DragEnter(IDropInfo info) {
}
void IDropTarget.DragLeave(IDropInfo info) {
}
}
public class BarDrawerItemsDropTarget : IDropTarget {
public ObservableCollection<FloatingBarItem> BarDrawerItems { get; set; } =
new ObservableCollection<FloatingBarItem>();
void IDropTarget.DragOver(IDropInfo info) {
info.Effects = DragDropEffects.Move;
info.DropTargetAdorner = DropTargetAdorners.Insert;
}
void IDropTarget.Drop(IDropInfo info) {
if (info.Data is FloatingBarItem draggedItem) {
var targetCollection = info.TargetCollection as ObservableCollection<FloatingBarItem>;
var sourceCollection = info.DragInfo.SourceCollection as ObservableCollection<FloatingBarItem>;
// 在同一个 ObservableCollection 中移动
if (targetCollection.Equals(sourceCollection)) {
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
} else { // 跨 ObservableCollection 移动
sourceCollection.Remove(info.Data as FloatingBarItem);
targetCollection.Insert(info.InsertIndex, info.Data as FloatingBarItem);
}
}
}
void IDropTarget.DragEnter(IDropInfo info) {
}
void IDropTarget.DragLeave(IDropInfo info) {
}
}
public BarItemsDropTarget barItems { get; set; } = new BarItemsDropTarget();
public BarDrawerItemsDropTarget barDrawerItems { get; set; } = new BarDrawerItemsDropTarget();
public FloatingBarDnDSettingsPanel() {
InitializeComponent();
ToolbarItemsControl.DataContext = barItems;
ToolbarDrawerItemsControl.DataContext = barDrawerItems;
barItems.BarItems.Add(new FloatingBarItem() {
IconSource = FindResource("EraserIcon") as DrawingImage,
});
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem() {
IconSource = FindResource("CursorIcon") as DrawingImage,
});
barDrawerItems.BarDrawerItems.Add(new FloatingBarItem() {
IconSource = FindResource("PenIcon") as DrawingImage,
});
}
}
}
@@ -0,0 +1,54 @@
<UserControl x:Class="Ink_Canvas.Windows.SettingsViews.SettingsBaseView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:controls="http://schemas.inkore.net/lib/ui/wpf/modern"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<ScrollViewer ScrollChanged="ScrollViewerEx_ScrollChanged" IsManipulationEnabled="True" Name="SettingsViewScrollViewer" IsDeferredScrollingEnabled="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" IsTabStop="False" TabIndex="-1" Margin="0,0,2,2">
<ItemsControl Name="SettingsViewBaseItemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Margin="0,12,0,24" HorizontalAlignment="Center" Width="524"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" Margin="0,0,0,25">
<TextBlock Visibility="{Binding _TitleVisibility}" Text="{Binding Title}" FontSize="15" FontWeight="Bold" Foreground="#2e3436"/>
<Border Margin="{Binding _PanelMargin}" Background="#fafafa" BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8">
<StackPanel Orientation="Vertical">
<ItemsControl ItemsSource="{Binding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<Grid Height="54">
<StackPanel Orientation="Vertical" Margin="18,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="{Binding Title}" HorizontalAlignment="Left"/>
<TextBlock Foreground="#9a9996" FontSize="11" Margin="0,3.5,0,0" Text="{Binding Description}" HorizontalAlignment="Left"/>
</StackPanel>
<controls:ToggleSwitch IsEnabled="{Binding ToggleSwitchEnabled}" IsOn="{Binding ToggleSwitchToggled, Mode=TwoWay}" Tag="{Binding}" Visibility="{Binding _ToggleSwitchVisibility}" Margin="0,0,15,0"/>
</Grid>
<Border Visibility="{Binding _SeparatorVisibility}" Height="1" Background="#ebebeb"/>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>
@@ -0,0 +1,184 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using iNKORE.UI.WPF.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
namespace Ink_Canvas.Windows.SettingsViews {
public class SettingsViewPanel {
public string Title { get; set; }
public Visibility _TitleVisibility => String.IsNullOrWhiteSpace(Title) ? Visibility.Collapsed : Visibility.Visible;
public Thickness _PanelMargin =>
String.IsNullOrWhiteSpace(Title) ? new Thickness(0) : new Thickness(0, 12, 0, 0);
public ObservableCollection<SettingsItem> Items { get; set; } = new ObservableCollection<SettingsItem>() { };
}
public enum SettingsItemType {
Plain, // 只显示Title和Description
SingleToggleSwtich,
ToggleSwitchWithArrowButton,
SelectionButtons,
}
public class SettingsItem : INotifyPropertyChanged {
public string Title { get; set; }
public string Description { get; set; }
public SettingsItemType Type { get; set; } = SettingsItemType.Plain;
public bool IsClickable { get; set; } = false;
public bool IsSeparatorVisible { get; set; } = true;
public Visibility _SeparatorVisibility => IsSeparatorVisible ? Visibility.Visible : Visibility.Collapsed;
public Visibility _ToggleSwitchVisibility =>
Type == SettingsItemType.SingleToggleSwtich || Type == SettingsItemType.ToggleSwitchWithArrowButton ? Visibility.Visible : Visibility.Collapsed;
private bool _toggleSwitchToggled;
public bool ToggleSwitchToggled {
get => _toggleSwitchToggled;
set {
if (_toggleSwitchToggled != value) {
_toggleSwitchToggled = value;
OnPropertyChanged(nameof(ToggleSwitchToggled)); // 通知绑定控件属性变化
OnToggleSwitchToggled?.Invoke(this, EventArgs.Empty); // 触发事件
}
}
}
public event EventHandler OnToggleSwitchToggled;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName) {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private SolidColorBrush _toggleSwitchBackground = new SolidColorBrush(Color.FromRgb(53, 132, 228));
public SolidColorBrush ToggleSwitchBackground {
get => _toggleSwitchBackground;
set {
if (_toggleSwitchBackground != value) {
_toggleSwitchBackground = value;
OnPropertyChanged(nameof(ToggleSwitchBackground)); // 通知绑定控件属性变化
}
}
}
private bool _toggleSwitchEnabled = true;
public bool ToggleSwitchEnabled {
get => _toggleSwitchEnabled;
set {
if (_toggleSwitchEnabled != value) {
_toggleSwitchEnabled = value;
OnPropertyChanged(nameof(ToggleSwitchEnabled)); // 通知绑定控件属性变化
}
}
}
}
public partial class SettingsBaseView : UserControl {
public SettingsBaseView() {
InitializeComponent();
SettingsViewBaseItemsControl.ItemsSource = SettingsPanels;
}
public ObservableCollection<SettingsViewPanel> SettingsPanels { get; set; } =
new ObservableCollection<SettingsViewPanel>() { };
public event EventHandler<RoutedEventArgs> IsTopBarNeedShadowEffect;
public event EventHandler<RoutedEventArgs> IsTopBarNeedNoShadowEffect;
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e) {
var scrollViewer = (ScrollViewer)sender;
if (scrollViewer.VerticalOffset >= 10) {
IsTopBarNeedShadowEffect?.Invoke(this, new RoutedEventArgs());
} else {
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
}
}
private void ScrollBar_Scroll(object sender, RoutedEventArgs e) {
var scrollbar = (ScrollBar)sender;
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
}
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e) {
var border = (Border)sender;
if (border.Child is Track track) {
track.Width = 16;
track.Margin = new Thickness(0, 0, -2, 0);
var scrollbar = track.FindAscendant<ScrollBar>();
if (scrollbar != null) scrollbar.Width = 16;
var grid = track.FindAscendant<Grid>();
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
backgroundBorder.Width = 8;
backgroundBorder.CornerRadius = new CornerRadius(4);
backgroundBorder.Opacity = 1;
}
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
if (thumb != null) {
var _thumb = thumb as Border;
_thumb.CornerRadius = new CornerRadius(4);
_thumb.Width = 8;
_thumb.Margin = new Thickness(-0.75, 0, 1, 0);
_thumb.Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
}
}
}
private void ToggleSwitch_OnToggled(object sender, RoutedEventArgs e) {
var toggleswitch = sender as ToggleSwitch;
var item = toggleswitch.Tag as SettingsItem;
item.ToggleSwitchToggled = toggleswitch.IsOn;
}
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e) {
var border = (Border)sender;
border.Background = new SolidColorBrush(Colors.Transparent);
border.CornerRadius = new CornerRadius(0);
if (border.Child is Track track) {
track.Width = 6;
track.Margin = new Thickness(0, 0, 0, 0);
var scrollbar = track.FindAscendant<ScrollBar>();
if (scrollbar != null) scrollbar.Width = 6;
var grid = track.FindAscendant<Grid>();
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
backgroundBorder.Width = 3;
backgroundBorder.CornerRadius = new CornerRadius(1.5);
backgroundBorder.Opacity = 0;
}
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
if (thumb != null) {
var _thumb = thumb as Border;
_thumb.CornerRadius = new CornerRadius(1.5);
_thumb.Width = 3;
_thumb.Margin = new Thickness(0);
_thumb.Background = new SolidColorBrush(Color.FromRgb(195, 195, 195));
}
}
}
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e) {
var thumb = (Thumb)sender;
var border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
}
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e) {
var thumb = (Thumb)sender;
var border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,325 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Management;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Ink_Canvas.Windows.SettingsViews;
using iNKORE.UI.WPF.Helpers;
using iNKORE.UI.WPF.Modern.Controls;
using OSVersionExtension;
namespace Ink_Canvas.Windows {
public partial class SettingsWindow : Window {
public SettingsWindow() {
InitializeComponent();
// 初始化侧边栏项目
SidebarItemsControl.ItemsSource = SidebarItems;
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "启动时行为",
Name = "StartupItem",
IconSource = FindResource("StartupIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "画板和墨迹",
Name = "CanvasAndInkItem",
IconSource = FindResource("CanvasAndInkIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "手势操作",
Name = "GesturesItem",
IconSource = FindResource("GesturesIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Separator
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "个性化和外观",
Name = "AppearanceItem",
IconSource = FindResource("AppearanceIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "墨迹转形状",
Name = "InkRecognitionItem",
IconSource = FindResource("InkRecognitionIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "几何与形状绘制",
Name = "ShapeDrawingItem",
IconSource = FindResource("ShapeDrawingIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "自动化行为",
Name = "AutomationItem",
IconSource = FindResource("AutomationIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Separator
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "PowerPoint 支持",
Name = "PowerPointItem",
IconSource = FindResource("PowerPointIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "插件和脚本",
Name = "ExtensionsItem",
IconSource = FindResource("ExtensionsIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Separator
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "存储空间",
Name = "StorageItem",
IconSource = FindResource("StorageIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "截图和屏幕捕捉",
Name = "SnapshotItem",
IconSource = FindResource("SnapshotIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "点名器设置",
Name = "LuckyRandomItem",
IconSource = FindResource("LuckyRandomIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "高级选项",
Name = "AdvancedItem",
IconSource = FindResource("AdvancedIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem() {
Type = SidebarItemType.Item,
Title = "关于 InkCanvasForClass",
Name = "AboutItem",
IconSource = FindResource("AboutIcon") as DrawingImage,
Selected = false,
});
_selectedSidebarItemName = "CanvasAndInkItem";
UpdateSidebarItemsSelection();
SettingsPanes = new Grid[] {
AboutPane,
ExtensionsPane,
CanvasAndInkPane,
GesturesPane,
StartupPane,
AppearancePane,
InkRecognitionPane,
AutomationPane,
PowerPointPane
};
SettingsPaneScrollViewers = new ScrollViewer[] {
SettingsAboutPanel.AboutScrollViewerEx,
CanvasAndInkScrollViewerEx,
GesturesScrollViewerEx,
StartupScrollViewerEx,
AppearanceScrollViewerEx,
InkRecognitionScrollViewerEx,
AutomationScrollViewerEx,
PowerPointScrollViewerEx
};
SettingsAboutPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
SettingsAboutPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
}
public Grid[] SettingsPanes = new Grid[] { };
public ScrollViewer[] SettingsPaneScrollViewers = new ScrollViewer[] { };
public enum SidebarItemType {
Item,
Separator
}
public class SidebarItem {
public SidebarItemType Type { get; set; }
public string Title { get; set; }
public string Name { get; set; }
public ImageSource IconSource { get; set; }
public bool Selected { get; set; }
public Visibility _spVisibility {
get => this.Type == SidebarItemType.Separator ? Visibility.Visible : Visibility.Collapsed;
}
public Visibility _siVisibility {
get => this.Type == SidebarItemType.Item ? Visibility.Visible : Visibility.Collapsed;
}
public SolidColorBrush _siBackground {
get => this.Selected
? new SolidColorBrush(Color.FromRgb(217, 217, 217))
: new SolidColorBrush(Colors.Transparent);
}
}
public string _selectedSidebarItemName = "";
public ObservableCollection<SidebarItem> SidebarItems = new ObservableCollection<SidebarItem>();
public void UpdateSidebarItemsSelection() {
foreach (var si in SidebarItems) {
si.Selected = si.Name == _selectedSidebarItemName;
if (si.Selected) SettingsWindowTitle.Text = si.Title;
}
CollectionViewSource.GetDefaultView(SidebarItems).Refresh();
AboutPane.Visibility = _selectedSidebarItemName == "AboutItem" ? Visibility.Visible : Visibility.Collapsed;
ExtensionsPane.Visibility = _selectedSidebarItemName == "ExtensionsItem" ? Visibility.Visible : Visibility.Collapsed;
CanvasAndInkPane.Visibility = _selectedSidebarItemName == "CanvasAndInkItem" ? Visibility.Visible : Visibility.Collapsed;
GesturesPane.Visibility = _selectedSidebarItemName == "GesturesItem" ? Visibility.Visible : Visibility.Collapsed;
StartupPane.Visibility = _selectedSidebarItemName == "StartupItem" ? Visibility.Visible : Visibility.Collapsed;
AppearancePane.Visibility = _selectedSidebarItemName == "AppearanceItem" ? Visibility.Visible : Visibility.Collapsed;
InkRecognitionPane.Visibility = _selectedSidebarItemName == "InkRecognitionItem" ? Visibility.Visible : Visibility.Collapsed;
AutomationPane.Visibility = _selectedSidebarItemName == "AutomationItem" ? Visibility.Visible : Visibility.Collapsed;
PowerPointPane.Visibility = _selectedSidebarItemName == "PowerPointItem" ? Visibility.Visible : Visibility.Collapsed;
foreach (var sv in SettingsPaneScrollViewers) {
sv.ScrollToTop();
}
}
private void ScrollViewerEx_ScrollChanged(object sender, ScrollChangedEventArgs e) {
var scrollViewer = (ScrollViewer)sender;
if (scrollViewer.VerticalOffset >= 10) {
DropShadowEffectTopBar.Opacity = 0.25;
} else {
DropShadowEffectTopBar.Opacity = 0;
}
}
private void ScrollBar_Scroll(object sender, RoutedEventArgs e) {
var scrollbar = (ScrollBar)sender;
var scrollviewer = scrollbar.FindAscendant<ScrollViewer>();
if (scrollviewer != null) scrollviewer.ScrollToVerticalOffset(scrollbar.Track.Value);
}
private void ScrollBarTrack_MouseEnter(object sender, MouseEventArgs e) {
var border = (Border)sender;
if (border.Child is Track track) {
track.Width = 16;
track.Margin = new Thickness(0, 0, -2, 0);
var scrollbar = track.FindAscendant<ScrollBar>();
if (scrollbar != null) scrollbar.Width = 16;
var grid = track.FindAscendant<Grid>();
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
backgroundBorder.Width = 8;
backgroundBorder.CornerRadius = new CornerRadius(4);
backgroundBorder.Opacity = 1;
}
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
if (thumb != null) {
var _thumb = thumb as Border;
_thumb.CornerRadius = new CornerRadius(4);
_thumb.Width = 8;
_thumb.Margin = new Thickness(-0.75, 0, 1, 0);
_thumb.Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
}
}
}
private void ScrollBarTrack_MouseLeave(object sender, MouseEventArgs e) {
var border = (Border)sender;
border.Background = new SolidColorBrush(Colors.Transparent);
border.CornerRadius = new CornerRadius(0);
if (border.Child is Track track) {
track.Width = 6;
track.Margin = new Thickness(0, 0, 0, 0);
var scrollbar = track.FindAscendant<ScrollBar>();
if (scrollbar != null) scrollbar.Width = 6;
var grid = track.FindAscendant<Grid>();
if (grid.FindDescendantByName("ScrollBarBorderTrackBackground") is Border backgroundBorder) {
backgroundBorder.Width = 3;
backgroundBorder.CornerRadius = new CornerRadius(1.5);
backgroundBorder.Opacity = 0;
}
var thumb = track.Thumb.Template.FindName("ScrollbarThumbEx", track.Thumb) ;
if (thumb != null) {
var _thumb = thumb as Border;
_thumb.CornerRadius = new CornerRadius(1.5);
_thumb.Width = 3;
_thumb.Margin = new Thickness(0);
_thumb.Background = new SolidColorBrush(Color.FromRgb(195, 195, 195));
}
}
}
private void ScrollbarThumb_MouseDown(object sender, MouseButtonEventArgs e) {
var thumb = (Thumb)sender;
var border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
((Border)border).Background = new SolidColorBrush(Color.FromRgb(95, 95, 95));
}
private void ScrollbarThumb_MouseUp(object sender, MouseButtonEventArgs e) {
var thumb = (Thumb)sender;
var border = thumb.Template.FindName("ScrollbarThumbEx",thumb);
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
}
private Border _sidebarItemMouseDownBorder = null;
private void SidebarItem_MouseDown(object sender, MouseButtonEventArgs e) {
if (_sidebarItemMouseDownBorder != null || _sidebarItemMouseDownBorder == sender) return;
_sidebarItemMouseDownBorder = (Border)sender;
var bd = sender as Border;
if (bd.FindDescendantByName("MouseFeedbackBorder") is Border feedbackBd) feedbackBd.Opacity = 0.12;
}
private void SidebarItem_MouseUp(object sender, MouseButtonEventArgs e) {
if (_sidebarItemMouseDownBorder == null || _sidebarItemMouseDownBorder != sender) return;
if (_sidebarItemMouseDownBorder.Tag is SidebarItem data) _selectedSidebarItemName = data.Name;
SidebarItem_MouseLeave(sender, null);
UpdateSidebarItemsSelection();
}
private void SidebarItem_MouseLeave(object sender, MouseEventArgs e) {
if (_sidebarItemMouseDownBorder == null || _sidebarItemMouseDownBorder != sender) return;
if (_sidebarItemMouseDownBorder.FindDescendantByName("MouseFeedbackBorder") is Border feedbackBd) feedbackBd.Opacity = 0;
_sidebarItemMouseDownBorder = null;
}
}
}