feat(反馈): 添加反馈窗口替代直接打开链接

重构关于面板的反馈功能,将直接打开GitHub问题链接改为显示一个反馈窗口。用户可以在窗口中自定义包含哪些系统信息。
This commit is contained in:
doudou0720
2026-03-21 23:28:41 +08:00
parent f9f4e20c65
commit 956f3b12ac
3 changed files with 267 additions and 87 deletions
+64
View File
@@ -0,0 +1,64 @@
<Window x:Class="Ink_Canvas.FeedbackWindow"
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"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
mc:Ignorable="d" Topmost="True" WindowStartupLocation="CenterScreen" ui:WindowHelper.UseModernWindowStyle="True"
ResizeMode="NoResize" ui:ThemeManager.RequestedTheme="Light"
Title="反馈问题 - Ink Canvas For Class CE" Height="500" Width="600" FontFamily="Microsoft YaHei UI">
<Grid Margin="20">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
<StackPanel>
<TextBlock FontSize="18" FontWeight="Bold" Margin="0,0,0,15" Text="选择要包含的信息"/>
<Border BorderBrush="#e0e0e0" BorderThickness="1" CornerRadius="8" Margin="0,0,0,15" Padding="15">
<StackPanel>
<TextBlock FontSize="14" FontWeight="Bold" Margin="0,0,0,10" Text="软件信息"/>
<CheckBox x:Name="CheckBoxAppVersion" IsChecked="True" Margin="0,5,0,5" Content="软件版本" FontSize="13"/>
<CheckBox x:Name="CheckBoxUpdateChannel" IsChecked="True" Margin="0,5,0,5" Content="更新通道" FontSize="13"/>
<TextBlock x:Name="TextAppVersionInfo" Text="v1.7.18.4 (Release)" Margin="30,0,0,5" FontSize="12" Foreground="#666666" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<Border BorderBrush="#e0e0e0" BorderThickness="1" CornerRadius="8" Margin="0,0,0,15" Padding="15">
<StackPanel>
<TextBlock FontSize="14" FontWeight="Bold" Margin="0,0,0,10" Text="系统信息"/>
<CheckBox x:Name="CheckBoxOSVersion" IsChecked="True" Margin="0,5,0,5" Content="操作系统版本" FontSize="13"/>
<CheckBox x:Name="CheckBoxNetVersion" IsChecked="True" Margin="0,5,0,5" Content=".NET 版本" FontSize="13"/>
<CheckBox x:Name="CheckBoxTouchSupport" IsChecked="True" Margin="0,5,0,5" Content="触控支持" FontSize="13"/>
<TextBlock x:Name="TextSystemInfo" Text="Windows 10 专业版 19045.3758 | .NET 8.0.0 | 触控:支持(2个设备)" Margin="30,0,0,5" FontSize="12" Foreground="#666666" TextWrapping="Wrap"/>
</StackPanel>
</Border>
<Border BorderBrush="#e0e0e0" BorderThickness="1" CornerRadius="8" Margin="0,0,0,15" Padding="15">
<StackPanel>
<TextBlock FontSize="14" FontWeight="Bold" Margin="0,0,0,10" Text="设备信息"/>
<CheckBox x:Name="CheckBoxDeviceId" IsChecked="False" Margin="0,5,0,5" Content="设备 ID" FontSize="13"/>
<TextBlock x:Name="TextDeviceInfo" Text="设备ID: xxxxxxxxxxxxxx" Margin="30,0,0,5" FontSize="12" Foreground="#666666" TextWrapping="Wrap"/>
</StackPanel>
</Border>
</StackPanel>
</ScrollViewer>
<Grid Grid.Row="1" VerticalAlignment="Bottom">
<ikw:SimpleStackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" Spacing="10">
<Button Content="取消" Width="100" Height="35" FontFamily="Microsoft YaHei UI" FontSize="14" Click="ButtonCancel_Click" Foreground="#555555"/>
<Button Content="提交反馈" Width="120" Height="35" FontFamily="Microsoft YaHei UI" FontSize="14" FontWeight="Bold" Click="ButtonSubmit_Click" Foreground="White">
<Button.Resources>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundKey}" Color="#3b82f6"/>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPointerOverKey}" Color="#2563eb"/>
<SolidColorBrush x:Key="{x:Static ui:ThemeKeys.ButtonBackgroundPressedKey}" Color="#1d4ed8"/>
</Button.Resources>
</Button>
</ikw:SimpleStackPanel>
</Grid>
</Grid>
</Window>
+200
View File
@@ -0,0 +1,200 @@
using Ink_Canvas.Helpers;
using OSVersionExtension;
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows;
namespace Ink_Canvas
{
public partial class FeedbackWindow : Window
{
private string _appVersion = "";
private string _updateChannel = "";
private string _osVersion = "";
private string _netVersion = "";
private string _touchSupport = "";
private string _deviceId = "";
public FeedbackWindow()
{
InitializeComponent();
LoadInformation();
UpdatePreviewText();
}
private void LoadInformation()
{
try
{
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
_appVersion = $"v{assemblyVersion}";
}
catch (Exception ex)
{
_appVersion = "未知";
System.Diagnostics.Debug.WriteLine($"获取软件版本失败: {ex.Message}");
}
try
{
if (MainWindow.Settings?.Startup != null)
{
_updateChannel = MainWindow.Settings.Startup.UpdateChannel.ToString();
}
}
catch (Exception ex)
{
_updateChannel = "未知";
System.Diagnostics.Debug.WriteLine($"获取更新通道失败: {ex.Message}");
}
try
{
_osVersion = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}";
}
catch (Exception ex)
{
_osVersion = "未知";
System.Diagnostics.Debug.WriteLine($"获取系统版本失败: {ex.Message}");
}
try
{
_netVersion = RuntimeInformation.FrameworkDescription;
}
catch (Exception ex)
{
_netVersion = "未知";
System.Diagnostics.Debug.WriteLine($"获取.NET版本失败: {ex.Message}");
}
try
{
var support = Ink_Canvas.Windows.SettingsViews.AboutPanel.TouchTabletDetectHelper.IsTouchEnabled();
var touchcount = Ink_Canvas.Windows.SettingsViews.AboutPanel.TouchTabletDetectHelper.GetTouchTabletDevices().Count;
if (support)
{
if (touchcount > 0)
{
_touchSupport = $"支持({touchcount}个设备)";
}
else
{
_touchSupport = "支持";
}
}
else
{
_touchSupport = "不支持";
}
}
catch (Exception ex)
{
_touchSupport = "未知";
System.Diagnostics.Debug.WriteLine($"获取触控支持失败: {ex.Message}");
}
try
{
_deviceId = DeviceIdentifier.GetDeviceId();
}
catch (Exception ex)
{
_deviceId = "获取失败";
System.Diagnostics.Debug.WriteLine($"获取设备ID失败: {ex.Message}");
}
}
private void UpdatePreviewText()
{
TextAppVersionInfo.Text = $"{_appVersion} ({_updateChannel})";
TextSystemInfo.Text = $"{_osVersion} | {_netVersion} | 触控:{_touchSupport}";
TextDeviceInfo.Text = $"设备ID: {_deviceId}";
}
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void ButtonSubmit_Click(object sender, RoutedEventArgs e)
{
try
{
string versionInfo = "";
string systemInfo = "";
if (CheckBoxAppVersion.IsChecked == true || CheckBoxUpdateChannel.IsChecked == true)
{
if (CheckBoxAppVersion.IsChecked == true)
{
versionInfo += _appVersion;
}
if (CheckBoxUpdateChannel.IsChecked == true)
{
if (!string.IsNullOrEmpty(versionInfo))
{
versionInfo += " ";
}
versionInfo += $"({_updateChannel})";
}
}
if (CheckBoxOSVersion.IsChecked == true || CheckBoxNetVersion.IsChecked == true || CheckBoxTouchSupport.IsChecked == true)
{
if (CheckBoxOSVersion.IsChecked == true)
{
systemInfo += _osVersion;
}
if (CheckBoxNetVersion.IsChecked == true)
{
if (!string.IsNullOrEmpty(systemInfo))
{
systemInfo += " | ";
}
systemInfo += _netVersion;
}
if (CheckBoxTouchSupport.IsChecked == true)
{
if (!string.IsNullOrEmpty(systemInfo))
{
systemInfo += " | ";
}
systemInfo += $"触控:{_touchSupport}";
}
}
string url = "https://github.com/InkCanvasForClass/community/issues/new?template=01-bug_report.yml";
if (!string.IsNullOrEmpty(versionInfo))
{
url += $"&version={Uri.EscapeDataString(versionInfo)}";
}
if (!string.IsNullOrEmpty(systemInfo))
{
url += $"&os={Uri.EscapeDataString(systemInfo)}";
}
if (CheckBoxDeviceId.IsChecked == true)
{
url += $"&device={Uri.EscapeDataString(_deviceId)}";
}
Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
Close();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"打开反馈链接失败: {ex.Message}");
}
}
}
}
@@ -464,96 +464,12 @@ namespace Ink_Canvas.Windows.SettingsViews
{
try
{
string version = "";
string updateChannel = "";
string osInfo = "";
string netVersion = "";
string touchSupport = "";
try
{
var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;
version = $"v{assemblyVersion}";
}
catch (Exception ex)
{
version = "未知";
System.Diagnostics.Debug.WriteLine($"获取软件版本失败: {ex.Message}");
}
try
{
if (MainWindow.Settings?.Startup != null)
{
updateChannel = MainWindow.Settings.Startup.UpdateChannel.ToString();
}
}
catch (Exception ex)
{
updateChannel = "未知";
System.Diagnostics.Debug.WriteLine($"获取更新通道失败: {ex.Message}");
}
try
{
osInfo = $"{OSVersion.GetOperatingSystem()} {OSVersion.GetOSVersion().Version}";
}
catch (Exception ex)
{
osInfo = "未知";
System.Diagnostics.Debug.WriteLine($"获取系统版本失败: {ex.Message}");
}
try
{
netVersion = RuntimeInformation.FrameworkDescription;
}
catch (Exception ex)
{
netVersion = "未知";
System.Diagnostics.Debug.WriteLine($"获取.NET版本失败: {ex.Message}");
}
try
{
var support = TouchTabletDetectHelper.IsTouchEnabled();
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
if (support)
{
if (touchcount > 0)
{
touchSupport = $"支持({touchcount}个设备)";
}
else
{
touchSupport = "支持";
}
}
else
{
touchSupport = "不支持";
}
}
catch (Exception ex)
{
touchSupport = "未知";
System.Diagnostics.Debug.WriteLine($"获取触控支持失败: {ex.Message}");
}
string versionInfo = $"{version} ({updateChannel})";
string systemInfo = $"{osInfo} | {netVersion} | 触控:{touchSupport}";
string url = $"https://github.com/InkCanvasForClass/community/issues/new?template=01-bug_report.yml&version={Uri.EscapeDataString(versionInfo)}&os={Uri.EscapeDataString(systemInfo)}";
Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
var feedbackWindow = new FeedbackWindow();
feedbackWindow.ShowDialog();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"打开反馈链接失败: {ex.Message}");
System.Diagnostics.Debug.WriteLine($"打开反馈窗口失败: {ex.Message}");
}
}