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 touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
var support = TouchTabletDetectHelper.IsTouchEnabled();
Dispatcher.BeginInvoke(() =>
AboutTouchTabletText.Text = $"{touchcount}个设备,{(support ? "" : "")}");
try
{
var support = TouchTabletDetectHelper.IsTouchEnabled();
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();
@@ -180,22 +206,51 @@ namespace Ink_Canvas.Windows.SettingsViews
{
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)
try
{
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")
));
ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
collection = searcher.Get();
foreach (var device in collection)
{
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;
}
}
@@ -71,15 +71,12 @@ namespace Ink_Canvas.Windows.SettingsViews
// 随机点名
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 = "AdvancedItem", Type = SettingItemType.Category },
// 关于
new SettingItem { Title = "关于 InkCanvasForClass", Category = "关于", ItemName = "AboutItem", Type = SettingItemType.Category },
};