add:新设置

This commit is contained in:
2026-01-10 23:06:27 +08:00
parent 62b85a4bbd
commit fc89dce7c2
4 changed files with 95 additions and 65 deletions
@@ -119,10 +119,36 @@ namespace Ink_Canvas.Windows.SettingsViews
var _t_touch = new Thread(() => var _t_touch = new Thread(() =>
{ {
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count; try
var support = TouchTabletDetectHelper.IsTouchEnabled(); {
Dispatcher.BeginInvoke(() => var support = TouchTabletDetectHelper.IsTouchEnabled();
AboutTouchTabletText.Text = $"{touchcount}个设备,{(support ? "" : "")}"); var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
Dispatcher.BeginInvoke(() =>
{
if (support)
{
if (touchcount > 0)
{
AboutTouchTabletText.Text = $"{touchcount}个设备,支持触摸设备";
}
else
{
AboutTouchTabletText.Text = "支持触摸设备";
}
}
else
{
AboutTouchTabletText.Text = "无触摸支持";
}
});
}
catch (Exception ex)
{
Dispatcher.BeginInvoke(() =>
AboutTouchTabletText.Text = "检测失败");
System.Diagnostics.Debug.WriteLine($"检测触摸设备失败: {ex.Message}");
}
}); });
_t_touch.Start(); _t_touch.Start();
@@ -180,22 +206,51 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
List<USBDeviceInfo> devices = new List<USBDeviceInfo>(); List<USBDeviceInfo> devices = new List<USBDeviceInfo>();
ManagementObjectCollection collection; try
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(); ManagementObjectCollection collection;
if (!name.Contains("Pentablet")) continue; using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
devices.Add(new USBDeviceInfo( collection = searcher.Get();
(string)device.GetPropertyValue("DeviceID"),
(string)device.GetPropertyValue("PNPDeviceID"), foreach (var device in collection)
(string)device.GetPropertyValue("Description") {
)); try
{
var name = device.GetPropertyValue("Name")?.ToString() ?? "";
var description = device.GetPropertyValue("Description")?.ToString() ?? "";
if (string.IsNullOrEmpty(name)) continue;
var nameLower = name.ToLower();
var descLower = description.ToLower();
if (nameLower.Contains("pentablet") ||
nameLower.Contains("tablet") ||
nameLower.Contains("touch") ||
nameLower.Contains("digitizer") ||
descLower.Contains("touch") ||
descLower.Contains("digitizer"))
{
devices.Add(new USBDeviceInfo(
device.GetPropertyValue("DeviceID")?.ToString() ?? "",
device.GetPropertyValue("PNPDeviceID")?.ToString() ?? "",
description
));
}
}
catch
{
continue;
}
}
collection.Dispose();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"获取触摸设备列表失败: {ex.Message}");
} }
collection.Dispose();
return devices; return devices;
} }
} }
@@ -71,15 +71,12 @@ namespace Ink_Canvas.Windows.SettingsViews
// 随机点名 // 随机点名
new SettingItem { Title = "随机点名", Category = "随机点名", ItemName = "LuckyRandomItem", Type = SettingItemType.Category }, new SettingItem { Title = "随机点名", Category = "随机点名", ItemName = "LuckyRandomItem", Type = SettingItemType.Category },
// 存储空间 // 高级选项
new SettingItem { Title = "存储空间", Category = "存储空间", ItemName = "StorageItem", Type = SettingItemType.Category }, new SettingItem { Title = "高级选项", Category = "高级选项", ItemName = "AdvancedItem", Type = SettingItemType.Category },
// 截图和屏幕捕捉 // 截图和屏幕捕捉
new SettingItem { Title = "截图和屏幕捕捉", Category = "截图和屏幕捕捉", ItemName = "SnapshotItem", Type = SettingItemType.Category }, new SettingItem { Title = "截图和屏幕捕捉", Category = "截图和屏幕捕捉", ItemName = "SnapshotItem", Type = SettingItemType.Category },
// 高级选项
new SettingItem { Title = "高级选项", Category = "高级选项", ItemName = "AdvancedItem", Type = SettingItemType.Category },
// 关于 // 关于
new SettingItem { Title = "关于 InkCanvasForClass", Category = "关于", ItemName = "AboutItem", Type = SettingItemType.Category }, new SettingItem { Title = "关于 InkCanvasForClass", Category = "关于", ItemName = "AboutItem", Type = SettingItemType.Category },
}; };
@@ -796,9 +796,9 @@
<settingsViews:LuckyRandomPanel x:Name="LuckyRandomPanel"/> <settingsViews:LuckyRandomPanel x:Name="LuckyRandomPanel"/>
</Grid> </Grid>
<!--存储面板--> <!--高级面板-->
<Grid Margin="250,48,0,0" Visibility="Collapsed" Name="StoragePane"> <Grid Margin="250,48,0,0" Visibility="Collapsed" Name="AdvancedPane">
<settingsViews:StoragePanel x:Name="StoragePanel"/> <settingsViews:AdvancedPanel x:Name="AdvancedPanel"/>
</Grid> </Grid>
<!--截图面板--> <!--截图面板-->
@@ -806,11 +806,6 @@
<settingsViews:SnapshotPanel x:Name="SnapshotPanel"/> <settingsViews:SnapshotPanel x:Name="SnapshotPanel"/>
</Grid> </Grid>
<!--高级面板-->
<Grid Margin="250,48,0,0" Visibility="Collapsed" Name="AdvancedPane">
<settingsViews:AdvancedPanel x:Name="AdvancedPanel"/>
</Grid>
<!--SearchPanel--> <!--SearchPanel-->
<Grid Margin="0,0,0,0" Visibility="Collapsed" Name="SearchPane" ZIndex="1000"> <Grid Margin="0,0,0,0" Visibility="Collapsed" Name="SearchPane" ZIndex="1000">
<settingsViews:SearchPanel x:Name="SearchPanelControl"/> <settingsViews:SearchPanel x:Name="SearchPanelControl"/>
@@ -135,9 +135,9 @@ namespace Ink_Canvas.Windows
SidebarItems.Add(new SidebarItem() SidebarItems.Add(new SidebarItem()
{ {
Type = SidebarItemType.Item, Type = SidebarItemType.Item,
Title = "存储空间", Title = "高级选项",
Name = "StorageItem", Name = "AdvancedItem",
IconSource = FindResource("StorageIcon") as DrawingImage, IconSource = FindResource("AdvancedIcon") as DrawingImage,
Selected = false, Selected = false,
}); });
SidebarItems.Add(new SidebarItem() SidebarItems.Add(new SidebarItem()
@@ -153,14 +153,6 @@ namespace Ink_Canvas.Windows
Type = SidebarItemType.Separator Type = SidebarItemType.Separator
}); });
SidebarItems.Add(new SidebarItem() SidebarItems.Add(new SidebarItem()
{
Type = SidebarItemType.Item,
Title = "高级选项",
Name = "AdvancedItem",
IconSource = FindResource("AdvancedIcon") as DrawingImage,
Selected = false,
});
SidebarItems.Add(new SidebarItem()
{ {
Type = SidebarItemType.Item, Type = SidebarItemType.Item,
Title = "关于 InkCanvasForClass", Title = "关于 InkCanvasForClass",
@@ -180,9 +172,8 @@ namespace Ink_Canvas.Windows
AutomationPane, AutomationPane,
PowerPointPane, PowerPointPane,
LuckyRandomPane, LuckyRandomPane,
StoragePane, AdvancedPane,
SnapshotPane, SnapshotPane
AdvancedPane
}; };
SettingsPaneScrollViewers = new ScrollViewer[] { SettingsPaneScrollViewers = new ScrollViewer[] {
@@ -197,9 +188,8 @@ namespace Ink_Canvas.Windows
AutomationPanel.ScrollViewerEx, AutomationPanel.ScrollViewerEx,
PowerPointPanel.ScrollViewerEx, PowerPointPanel.ScrollViewerEx,
LuckyRandomPanel.ScrollViewerEx, LuckyRandomPanel.ScrollViewerEx,
StoragePanel.ScrollViewerEx, AdvancedPanel.ScrollViewerEx,
SnapshotPanel.ScrollViewerEx, SnapshotPanel.ScrollViewerEx
AdvancedPanel.ScrollViewerEx
}; };
SettingsPaneTitles = new string[] { SettingsPaneTitles = new string[] {
@@ -214,9 +204,8 @@ namespace Ink_Canvas.Windows
"自动化", "自动化",
"PowerPoint", "PowerPoint",
"幸运随机", "幸运随机",
"存储", "高级",
"截图", "截图"
"高级"
}; };
SettingsPaneNames = new string[] { SettingsPaneNames = new string[] {
@@ -231,9 +220,8 @@ namespace Ink_Canvas.Windows
"AutomationItem", "AutomationItem",
"PowerPointItem", "PowerPointItem",
"LuckyRandomItem", "LuckyRandomItem",
"StorageItem", "AdvancedItem",
"SnapshotItem", "SnapshotItem"
"AdvancedItem"
}; };
SettingsAboutPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25; SettingsAboutPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
@@ -267,12 +255,10 @@ namespace Ink_Canvas.Windows
CrashActionPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0; CrashActionPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
LuckyRandomPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25; LuckyRandomPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
LuckyRandomPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0; LuckyRandomPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
StoragePanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
StoragePanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
SnapshotPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
SnapshotPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
AdvancedPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25; AdvancedPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
AdvancedPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0; AdvancedPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
SnapshotPanel.IsTopBarNeedShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0.25;
SnapshotPanel.IsTopBarNeedNoShadowEffect += (o, s) => DropShadowEffectTopBar.Opacity = 0;
_selectedSidebarItemName = "StartupItem"; _selectedSidebarItemName = "StartupItem";
@@ -323,8 +309,8 @@ namespace Ink_Canvas.Windows
{ {
StartupPanel, CanvasAndInkPanel, GesturesPanel, InkRecognitionPanel, StartupPanel, CanvasAndInkPanel, GesturesPanel, InkRecognitionPanel,
ThemePanel, ShortcutsPanel, CrashActionPanel, PowerPointPanel, ThemePanel, ShortcutsPanel, CrashActionPanel, PowerPointPanel,
AutomationPanel, LuckyRandomPanel, StoragePanel, SnapshotPanel, AutomationPanel, LuckyRandomPanel, AdvancedPanel, SnapshotPanel,
AdvancedPanel, SettingsAboutPanel, AppearancePanel, SearchPanelControl SettingsAboutPanel, AppearancePanel, SearchPanelControl
}; };
foreach (var panel in panels) foreach (var panel in panels)
@@ -766,9 +752,8 @@ namespace Ink_Canvas.Windows
PowerPointPanel, PowerPointPanel,
AutomationPanel, AutomationPanel,
LuckyRandomPanel, LuckyRandomPanel,
StoragePanel,
SnapshotPanel,
AdvancedPanel, AdvancedPanel,
SnapshotPanel,
SettingsAboutPanel, SettingsAboutPanel,
AppearancePanel AppearancePanel
}; };
@@ -960,9 +945,8 @@ namespace Ink_Canvas.Windows
{ "AutomationItem", AutomationPanel }, { "AutomationItem", AutomationPanel },
{ "PowerPointItem", PowerPointPanel }, { "PowerPointItem", PowerPointPanel },
{ "LuckyRandomItem", LuckyRandomPanel }, { "LuckyRandomItem", LuckyRandomPanel },
{ "StorageItem", StoragePanel },
{ "SnapshotItem", SnapshotPanel },
{ "AdvancedItem", AdvancedPanel }, { "AdvancedItem", AdvancedPanel },
{ "SnapshotItem", SnapshotPanel },
{ "AppearanceItem", AppearancePanel } { "AppearanceItem", AppearancePanel }
}; };
@@ -978,9 +962,8 @@ namespace Ink_Canvas.Windows
if (AutomationPane != null) AutomationPane.Visibility = _selectedSidebarItemName == "AutomationItem" ? Visibility.Visible : Visibility.Collapsed; if (AutomationPane != null) AutomationPane.Visibility = _selectedSidebarItemName == "AutomationItem" ? Visibility.Visible : Visibility.Collapsed;
if (PowerPointPane != null) PowerPointPane.Visibility = _selectedSidebarItemName == "PowerPointItem" ? Visibility.Visible : Visibility.Collapsed; if (PowerPointPane != null) PowerPointPane.Visibility = _selectedSidebarItemName == "PowerPointItem" ? Visibility.Visible : Visibility.Collapsed;
if (LuckyRandomPane != null) LuckyRandomPane.Visibility = _selectedSidebarItemName == "LuckyRandomItem" ? Visibility.Visible : Visibility.Collapsed; if (LuckyRandomPane != null) LuckyRandomPane.Visibility = _selectedSidebarItemName == "LuckyRandomItem" ? Visibility.Visible : Visibility.Collapsed;
if (StoragePane != null) StoragePane.Visibility = _selectedSidebarItemName == "StorageItem" ? Visibility.Visible : Visibility.Collapsed;
if (SnapshotPane != null) SnapshotPane.Visibility = _selectedSidebarItemName == "SnapshotItem" ? Visibility.Visible : Visibility.Collapsed;
if (AdvancedPane != null) AdvancedPane.Visibility = _selectedSidebarItemName == "AdvancedItem" ? Visibility.Visible : Visibility.Collapsed; if (AdvancedPane != null) AdvancedPane.Visibility = _selectedSidebarItemName == "AdvancedItem" ? Visibility.Visible : Visibility.Collapsed;
if (SnapshotPane != null) SnapshotPane.Visibility = _selectedSidebarItemName == "SnapshotItem" ? Visibility.Visible : Visibility.Collapsed;
// 为新显示的面板应用主题(延迟执行,确保面板已完全显示) // 为新显示的面板应用主题(延迟执行,确保面板已完全显示)
if (panelMappings.ContainsKey(_selectedSidebarItemName)) if (panelMappings.ContainsKey(_selectedSidebarItemName))