add:新设置
This commit is contained in:
@@ -71,7 +71,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
{
|
{
|
||||||
var copyright = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>();
|
var copyright = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>();
|
||||||
if (copyright != null && !string.IsNullOrEmpty(copyright.Copyright))
|
if (copyright != null && !string.IsNullOrEmpty(copyright.Copyright))
|
||||||
{
|
{
|
||||||
var copyrightText = copyright.Copyright;
|
var copyrightText = copyright.Copyright;
|
||||||
AboutCopyright.Text = copyrightText;
|
AboutCopyright.Text = copyrightText;
|
||||||
AboutBottomCopyright.Text = copyrightText.Replace("Copyright ©", "© Copyright") + " 所有";
|
AboutBottomCopyright.Text = copyrightText.Replace("Copyright ©", "© Copyright") + " 所有";
|
||||||
@@ -97,13 +97,13 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
var bt = File.GetCreationTime(filePath);
|
var bt = File.GetCreationTime(filePath);
|
||||||
var m = bt.Month.ToString().PadLeft(2, '0');
|
var m = bt.Month.ToString().PadLeft(2, '0');
|
||||||
var d = bt.Day.ToString().PadLeft(2, '0');
|
var d = bt.Day.ToString().PadLeft(2, '0');
|
||||||
var h = bt.Hour.ToString().PadLeft(2, '0');
|
var h = bt.Hour.ToString().PadLeft(2, '0');
|
||||||
var min = bt.Minute.ToString().PadLeft(2, '0');
|
var min = bt.Minute.ToString().PadLeft(2, '0');
|
||||||
var s = bt.Second.ToString().PadLeft(2, '0');
|
var s = bt.Second.ToString().PadLeft(2, '0');
|
||||||
AboutBuildTime.Text = $"{bt.Year}-{m}-{d} {h}:{min}:{s}";
|
AboutBuildTime.Text = $"{bt.Year}-{m}-{d} {h}:{min}:{s}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AboutBuildTime.Text = "获取失败";
|
AboutBuildTime.Text = "获取失败";
|
||||||
@@ -122,7 +122,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var support = TouchTabletDetectHelper.IsTouchEnabled();
|
var support = TouchTabletDetectHelper.IsTouchEnabled();
|
||||||
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
|
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
|
||||||
|
|
||||||
Dispatcher.BeginInvoke(() =>
|
Dispatcher.BeginInvoke(() =>
|
||||||
{
|
{
|
||||||
@@ -145,7 +145,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Dispatcher.BeginInvoke(() =>
|
Dispatcher.BeginInvoke(() =>
|
||||||
AboutTouchTabletText.Text = "检测失败");
|
AboutTouchTabletText.Text = "检测失败");
|
||||||
System.Diagnostics.Debug.WriteLine($"检测触摸设备失败: {ex.Message}");
|
System.Diagnostics.Debug.WriteLine($"检测触摸设备失败: {ex.Message}");
|
||||||
}
|
}
|
||||||
@@ -208,12 +208,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ManagementObjectCollection collection;
|
ManagementObjectCollection collection;
|
||||||
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
|
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
|
||||||
collection = searcher.Get();
|
collection = searcher.Get();
|
||||||
|
|
||||||
foreach (var device in collection)
|
foreach (var device in collection)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var name = device.GetPropertyValue("Name")?.ToString() ?? "";
|
var name = device.GetPropertyValue("Name")?.ToString() ?? "";
|
||||||
@@ -231,7 +231,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
descLower.Contains("touch") ||
|
descLower.Contains("touch") ||
|
||||||
descLower.Contains("digitizer"))
|
descLower.Contains("digitizer"))
|
||||||
{
|
{
|
||||||
devices.Add(new USBDeviceInfo(
|
devices.Add(new USBDeviceInfo(
|
||||||
device.GetPropertyValue("DeviceID")?.ToString() ?? "",
|
device.GetPropertyValue("DeviceID")?.ToString() ?? "",
|
||||||
device.GetPropertyValue("PNPDeviceID")?.ToString() ?? "",
|
device.GetPropertyValue("PNPDeviceID")?.ToString() ?? "",
|
||||||
description
|
description
|
||||||
@@ -242,9 +242,9 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
collection.Dispose();
|
collection.Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -271,10 +271,10 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
public static DateTimeOffset? GetBuildDateTime(Assembly assembly)
|
public static DateTimeOffset? GetBuildDateTime(Assembly assembly)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var path = assembly.Location;
|
var path = assembly.Location;
|
||||||
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,18 +298,18 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
fileStream.Read(fileHeader, 0, fileHeader.Length);
|
fileStream.Read(fileHeader, 0, fileHeader.Length);
|
||||||
|
|
||||||
var pinnedBuffer = GCHandle.Alloc(fileHeader, GCHandleType.Pinned);
|
var pinnedBuffer = GCHandle.Alloc(fileHeader, GCHandleType.Pinned);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER));
|
var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER));
|
||||||
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||||
var buildTime = epoch.AddSeconds(coffHeader.TimeDateStamp);
|
var buildTime = epoch.AddSeconds(coffHeader.TimeDateStamp);
|
||||||
return new DateTimeOffset(buildTime.ToLocalTime());
|
return new DateTimeOffset(buildTime.ToLocalTime());
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
pinnedBuffer.Free();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
pinnedBuffer.Free();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews"
|
xmlns:local="clr-namespace:Ink_Canvas.Windows.SettingsViews"
|
||||||
|
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="950" d:DesignWidth="640">
|
d:DesignHeight="950" d:DesignWidth="640">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
@@ -75,49 +76,42 @@
|
|||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<ScrollViewer ScrollChanged="ScrollViewerEx_ScrollChanged" IsManipulationEnabled="True" Name="UpdateCenterScrollViewerEx" IsDeferredScrollingEnabled="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" IsTabStop="False" TabIndex="-1" Margin="0,0,2,2">
|
<ScrollViewer ScrollChanged="ScrollViewerEx_ScrollChanged" IsManipulationEnabled="True" Name="UpdateCenterScrollViewerEx" 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">
|
<StackPanel Margin="60,24,60,24">
|
||||||
<TextBlock Foreground="#2e3436" FontSize="24" FontWeight="Bold" Text="更新中心" Margin="0,0,0,8"/>
|
<TextBlock Foreground="#2e3436" FontSize="28" FontWeight="Bold" Text="InkCanvasForClass 更新" Margin="0,0,0,24"/>
|
||||||
<TextBlock Foreground="#878787" FontSize="14" Text="检查并安装 InkCanvasForClass 的最新更新" TextWrapping="Wrap" Margin="0,0,0,24"/>
|
|
||||||
|
|
||||||
<Border BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8" Padding="20" Margin="0,0,0,20">
|
<Border BorderBrush="#e6e6e6" BorderThickness="1" CornerRadius="8" Padding="20" Background="#FAFAFA" Margin="0,0,0,20">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Grid Margin="0,0,0,16">
|
<TextBlock Name="UpdateStatusText" Foreground="#2e3436" FontSize="18" FontWeight="SemiBold" Text="正在检查更新..." TextWrapping="Wrap" Margin="0,0,0,8"/>
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
<TextBlock Name="LastCheckTimeText" Foreground="#878787" FontSize="14" Text="上次检查时间: 从未" TextWrapping="Wrap"/>
|
||||||
<TextBlock Foreground="#2e3436" FontSize="18" FontWeight="SemiBold" Text="当前版本" VerticalAlignment="Center"/>
|
</StackPanel>
|
||||||
</StackPanel>
|
</Border>
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
|
||||||
<TextBlock Name="CurrentVersionText" Foreground="#878787" FontSize="16" Text="正在获取..." VerticalAlignment="Center"/>
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Border Height="1" Background="#ebebeb" Margin="0,0,0,16"/>
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,24" VerticalAlignment="Center">
|
||||||
|
<TextBlock Name="CurrentVersionText" Foreground="#878787" FontSize="14" Text="当前版本: 正在获取..." TextWrapping="Wrap" VerticalAlignment="Center"/>
|
||||||
|
<ui:ProgressRing Name="LoadingSpinner" Width="16" Height="16" IsActive="False" Margin="12,0,0,0" VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<Grid Margin="0,0,0,16">
|
<StackPanel Orientation="Horizontal" Margin="0,0,0,24">
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
<Button Name="CheckUpdateButton" Content="检查更新" HorizontalAlignment="Left" Padding="20,10" FontSize="14" Cursor="Hand" Click="CheckUpdateButton_Click" Background="#F3F3F3" Foreground="#2e3436" BorderThickness="1" BorderBrush="#E1E1E1" Margin="0,0,12,0">
|
||||||
<TextBlock Foreground="#2e3436" FontSize="18" FontWeight="SemiBold" Text="更新状态" VerticalAlignment="Center"/>
|
<Button.Template>
|
||||||
</StackPanel>
|
<ControlTemplate TargetType="Button">
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||||
<TextBlock Name="UpdateStatusText" Foreground="#878787" FontSize="16" Text="正在检查更新..." VerticalAlignment="Center"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
<Image Name="UpdateStatusIcon" Margin="8,0,0,0" Width="20" Height="20" VerticalAlignment="Center" Visibility="Collapsed">
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
<Image.Source>
|
<Path Name="ChevronIcon" Data="M 0 0 L 4 4 L 0 8" Stroke="{TemplateBinding Foreground}" StrokeThickness="1.5" Margin="8,0,0,0" VerticalAlignment="Center" Visibility="Collapsed"/>
|
||||||
<DrawingImage>
|
</StackPanel>
|
||||||
<DrawingImage.Drawing>
|
</Border>
|
||||||
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
|
</ControlTemplate>
|
||||||
<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" />
|
</Button.Template>
|
||||||
</DrawingGroup>
|
</Button>
|
||||||
</DrawingImage.Drawing>
|
</StackPanel>
|
||||||
</DrawingImage>
|
|
||||||
</Image.Source>
|
|
||||||
</Image>
|
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Border Height="1" Background="#ebebeb" Margin="0,0,0,16"/>
|
<StackPanel Name="UpdateAvailablePanel" Visibility="Collapsed" Margin="0,0,0,24">
|
||||||
|
<Border BorderBrush="#e6e6e6" BorderThickness="1" CornerRadius="8" Padding="16" Background="#F9F9F9">
|
||||||
<StackPanel Name="UpdateAvailablePanel" Visibility="Collapsed">
|
<StackPanel>
|
||||||
<TextBlock Foreground="#2e3436" FontSize="16" FontWeight="SemiBold" Text="可用更新" Margin="0,0,0,8"/>
|
<TextBlock Foreground="#2e3436" FontSize="16" FontWeight="SemiBold" Text="可用更新" Margin="0,0,0,8"/>
|
||||||
<TextBlock Name="LatestVersionText" Foreground="#878787" FontSize="14" Text="" TextWrapping="Wrap" Margin="0,0,0,16"/>
|
<TextBlock Name="LatestVersionText" Foreground="#878787" FontSize="14" Text="" TextWrapping="Wrap" Margin="0,0,0,16"/>
|
||||||
<Button Name="UpdateNowButton" Content="立即更新" HorizontalAlignment="Left" Padding="16,8" FontSize="14" Cursor="Hand" Click="UpdateNowButton_Click" Background="#0078D4" Foreground="White" BorderThickness="0">
|
<Button Name="UpdateNowButton" Content="立即更新" HorizontalAlignment="Left" Padding="20,10" FontSize="14" Cursor="Hand" Click="UpdateNowButton_Click" Background="#0078D4" Foreground="White" BorderThickness="0">
|
||||||
<Button.Template>
|
<Button.Template>
|
||||||
<ControlTemplate TargetType="Button">
|
<ControlTemplate TargetType="Button">
|
||||||
<Border Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
<Border Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||||
@@ -127,47 +121,8 @@
|
|||||||
</Button.Template>
|
</Button.Template>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
<Button Name="CheckUpdateButton" Content="检查更新" HorizontalAlignment="Left" Padding="16,8" FontSize="14" Cursor="Hand" Click="CheckUpdateButton_Click" Background="#F3F3F3" Foreground="#2e3436" BorderThickness="1" BorderBrush="#E1E1E1" Margin="0,8,0,0">
|
</StackPanel>
|
||||||
<Button.Template>
|
|
||||||
<ControlTemplate TargetType="Button">
|
|
||||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
|
||||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
||||||
</Border>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Button.Template>
|
|
||||||
</Button>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<Border BorderBrush="#e6e6e6" BorderThickness="1.25,1.25,1.25,4" CornerRadius="8" Padding="20">
|
|
||||||
<StackPanel>
|
|
||||||
<TextBlock Foreground="#2e3436" FontSize="18" FontWeight="SemiBold" Text="更新设置" Margin="0,0,0,16"/>
|
|
||||||
|
|
||||||
<Grid Height="54">
|
|
||||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="自动检查更新" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
|
||||||
<Border Name="AutoUpdateToggle" Style="{StaticResource ToggleSwitchStyle}" Background="#e1e1e1" Tag="AutoUpdate" MouseLeftButtonDown="ToggleSwitch_Click" HorizontalAlignment="Right" VerticalAlignment="Center">
|
|
||||||
<Border Width="19" Height="19" Background="White" CornerRadius="10" HorizontalAlignment="Left" VerticalAlignment="Center">
|
|
||||||
<Border.Effect>
|
|
||||||
<DropShadowEffect BlurRadius="4" Direction="-45" Color="Black" Opacity="0.3" ShadowDepth="0"/>
|
|
||||||
</Border.Effect>
|
|
||||||
</Border>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
|
||||||
<TextBlock Foreground="#878787" FontSize="12" Text="启用后,应用将在启动时自动检查更新" TextWrapping="Wrap" Margin="0,4,0,16"/>
|
|
||||||
|
|
||||||
<Border Height="1" Background="#ebebeb" Margin="0,0,0,16"/>
|
|
||||||
|
|
||||||
<Grid Height="54">
|
|
||||||
<TextBlock Foreground="#2e3436" FontSize="14.5" Text="更新通道" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
|
||||||
<ComboBox Name="UpdateChannelComboBox" HorizontalAlignment="Right" VerticalAlignment="Center" Width="150" SelectionChanged="UpdateChannelComboBox_SelectionChanged">
|
|
||||||
<ComboBoxItem Content="稳定版" Tag="Release"/>
|
|
||||||
<ComboBoxItem Content="测试版" Tag="Beta"/>
|
|
||||||
</ComboBox>
|
|
||||||
</Grid>
|
|
||||||
<TextBlock Foreground="#878787" FontSize="12" Text="选择要接收的更新类型" TextWrapping="Wrap" Margin="0,4,0,0"/>
|
|
||||||
</StackPanel>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
using iNKORE.UI.WPF.Helpers;
|
using iNKORE.UI.WPF.Helpers;
|
||||||
using Ink_Canvas.Helpers;
|
using Ink_Canvas.Helpers;
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
namespace Ink_Canvas.Windows.SettingsViews
|
namespace Ink_Canvas.Windows.SettingsViews
|
||||||
{
|
{
|
||||||
@@ -27,6 +29,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
isLoaded = true;
|
isLoaded = true;
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
CheckUpdateStatus();
|
CheckUpdateStatus();
|
||||||
|
ApplyTheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,24 +38,10 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
var version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
CurrentVersionText.Text = $"InkCanvasForClass v{version}";
|
var platform = Environment.Is64BitOperatingSystem ? "windows-x64" : "windows-x86";
|
||||||
|
CurrentVersionText.Text = $"当前版本: v{version} | {platform}";
|
||||||
|
|
||||||
if (MainWindow.Settings?.Startup != null)
|
LoadLastCheckTime();
|
||||||
{
|
|
||||||
UpdateToggleSwitch(AutoUpdateToggle, MainWindow.Settings.Startup.IsAutoUpdate);
|
|
||||||
|
|
||||||
if (UpdateChannelComboBox != null)
|
|
||||||
{
|
|
||||||
foreach (ComboBoxItem item in UpdateChannelComboBox.Items)
|
|
||||||
{
|
|
||||||
if (item.Tag?.ToString() == MainWindow.Settings.Startup.UpdateChannel.ToString())
|
|
||||||
{
|
|
||||||
UpdateChannelComboBox.SelectedItem = item;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -60,58 +49,59 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateToggleSwitch(Border toggle, bool isOn)
|
private void LoadLastCheckTime()
|
||||||
{
|
{
|
||||||
if (toggle == null) return;
|
try
|
||||||
|
{
|
||||||
|
var lastCheckTimePath = Path.Combine(App.RootPath, "last_update_check.dat");
|
||||||
|
if (File.Exists(lastCheckTimePath))
|
||||||
|
{
|
||||||
|
var timeStr = File.ReadAllText(lastCheckTimePath);
|
||||||
|
if (DateTime.TryParse(timeStr, out var lastCheckTime))
|
||||||
|
{
|
||||||
|
var now = DateTime.Now;
|
||||||
|
var timeDiff = now - lastCheckTime;
|
||||||
|
|
||||||
toggle.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
if (timeDiff.TotalDays < 1 && lastCheckTime.Date == now.Date)
|
||||||
var innerBorder = toggle.Child as Border;
|
{
|
||||||
if (innerBorder != null)
|
LastCheckTimeText.Text = $"上次检查时间: 今天, {lastCheckTime:HH:mm}";
|
||||||
{
|
}
|
||||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
else if (timeDiff.TotalDays < 2 && lastCheckTime.Date == now.Date.AddDays(-1))
|
||||||
|
{
|
||||||
|
LastCheckTimeText.Text = $"上次检查时间: 昨天, {lastCheckTime:HH:mm}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LastCheckTimeText.Text = $"上次检查时间: {lastCheckTime:yyyy-MM-dd HH:mm}";
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LastCheckTimeText.Text = "上次检查时间: 从未";
|
||||||
}
|
}
|
||||||
else
|
catch
|
||||||
{
|
{
|
||||||
var ellipse = new Border
|
LastCheckTimeText.Text = "上次检查时间: 从未";
|
||||||
{
|
|
||||||
Width = 19,
|
|
||||||
Height = 19,
|
|
||||||
Background = Brushes.White,
|
|
||||||
CornerRadius = new CornerRadius(10),
|
|
||||||
HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left,
|
|
||||||
VerticalAlignment = VerticalAlignment.Center
|
|
||||||
};
|
|
||||||
ellipse.Effect = new System.Windows.Media.Effects.DropShadowEffect
|
|
||||||
{
|
|
||||||
BlurRadius = 4,
|
|
||||||
Direction = -45,
|
|
||||||
Color = Colors.Black,
|
|
||||||
Opacity = 0.3,
|
|
||||||
ShadowDepth = 0
|
|
||||||
};
|
|
||||||
toggle.Child = ellipse;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleSwitch_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
private void SaveLastCheckTime()
|
||||||
{
|
{
|
||||||
var toggle = sender as Border;
|
try
|
||||||
if (toggle == null) return;
|
|
||||||
|
|
||||||
var tag = toggle.Tag?.ToString();
|
|
||||||
if (tag == "AutoUpdate" && MainWindow.Settings?.Startup != null)
|
|
||||||
{
|
{
|
||||||
MainWindowSettingsHelper.UpdateSettingSafely(() =>
|
var lastCheckTimePath = Path.Combine(App.RootPath, "last_update_check.dat");
|
||||||
{
|
File.WriteAllText(lastCheckTimePath, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||||
MainWindow.Settings.Startup.IsAutoUpdate = !MainWindow.Settings.Startup.IsAutoUpdate;
|
LoadLastCheckTime();
|
||||||
UpdateToggleSwitch(toggle, MainWindow.Settings.Startup.IsAutoUpdate);
|
}
|
||||||
}, "ToggleSwitchIsAutoUpdate_Toggled", "ToggleSwitchIsAutoUpdate");
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"保存上次检查时间失败: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckUpdateButton_Click(object sender, RoutedEventArgs e)
|
private void CheckUpdateButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
CheckUpdateStatus();
|
CheckUpdateStatus(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateNowButton_Click(object sender, RoutedEventArgs e)
|
private void UpdateNowButton_Click(object sender, RoutedEventArgs e)
|
||||||
@@ -134,79 +124,70 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateChannelComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void CheckUpdateStatus(bool manualCheck = false)
|
||||||
{
|
|
||||||
if (!isLoaded || MainWindow.Settings?.Startup == null) return;
|
|
||||||
|
|
||||||
var comboBox = sender as ComboBox;
|
|
||||||
if (comboBox?.SelectedItem is ComboBoxItem selectedItem)
|
|
||||||
{
|
|
||||||
var channel = selectedItem.Tag?.ToString();
|
|
||||||
if (Enum.TryParse<UpdateChannel>(channel, out var updateChannel))
|
|
||||||
{
|
|
||||||
MainWindowSettingsHelper.UpdateSettingSafely(() =>
|
|
||||||
{
|
|
||||||
MainWindow.Settings.Startup.UpdateChannel = updateChannel;
|
|
||||||
}, "UpdateChannelSelector_Checked");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckUpdateStatus()
|
|
||||||
{
|
{
|
||||||
UpdateStatusText.Text = "正在检查更新...";
|
UpdateStatusText.Text = "正在检查更新...";
|
||||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
|
||||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||||
CheckUpdateButton.IsEnabled = false;
|
CheckUpdateButton.IsEnabled = false;
|
||||||
|
StartLoadingAnimation();
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
var updateChannel = UpdateChannel.Release;
|
||||||
if (mainWindow != null)
|
if (MainWindow.Settings?.Startup != null)
|
||||||
{
|
{
|
||||||
var field = typeof(MainWindow).GetField("AvailableLatestVersion", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
updateChannel = MainWindow.Settings.Startup.UpdateChannel;
|
||||||
if (field != null)
|
}
|
||||||
{
|
|
||||||
var availableVersion = field.GetValue(mainWindow) as string;
|
|
||||||
|
|
||||||
Dispatcher.BeginInvoke(new Action(() =>
|
var (remoteVersion, lineGroup, releaseNotes) = await AutoUpdateHelper.CheckForUpdates(updateChannel, manualCheck, false);
|
||||||
|
|
||||||
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
StopLoadingAnimation();
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(remoteVersion))
|
||||||
|
{
|
||||||
|
var localVersion = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
var localVersionStr = localVersion.ToString();
|
||||||
|
var remoteVersionStr = remoteVersion.TrimStart('v', 'V');
|
||||||
|
|
||||||
|
Version local = new Version(localVersionStr);
|
||||||
|
Version remote = new Version(remoteVersionStr);
|
||||||
|
|
||||||
|
if (remote > local)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(availableVersion))
|
UpdateStatusText.Text = "有可用更新";
|
||||||
{
|
LatestVersionText.Text = $"版本 {remoteVersion} 现已可用";
|
||||||
UpdateStatusText.Text = "有可用更新";
|
UpdateAvailablePanel.Visibility = Visibility.Visible;
|
||||||
UpdateStatusIcon.Visibility = Visibility.Visible;
|
}
|
||||||
LatestVersionText.Text = $"版本 {availableVersion} 现已可用";
|
else
|
||||||
UpdateAvailablePanel.Visibility = Visibility.Visible;
|
{
|
||||||
}
|
UpdateStatusText.Text = "你使用的是最新版本";
|
||||||
else
|
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||||
{
|
}
|
||||||
UpdateStatusText.Text = "已是最新版本";
|
|
||||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
|
||||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
|
||||||
}
|
|
||||||
CheckUpdateButton.IsEnabled = true;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Dispatcher.BeginInvoke(new Action(() =>
|
UpdateStatusText.Text = "你使用的是最新版本";
|
||||||
{
|
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||||
UpdateStatusText.Text = "检查更新失败";
|
|
||||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
|
||||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
|
||||||
CheckUpdateButton.IsEnabled = true;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (manualCheck)
|
||||||
|
{
|
||||||
|
SaveLastCheckTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckUpdateButton.IsEnabled = true;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Dispatcher.BeginInvoke(new Action(() =>
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
|
StopLoadingAnimation();
|
||||||
UpdateStatusText.Text = "检查更新失败";
|
UpdateStatusText.Text = "检查更新失败";
|
||||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
|
||||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||||
CheckUpdateButton.IsEnabled = true;
|
CheckUpdateButton.IsEnabled = true;
|
||||||
}));
|
}));
|
||||||
@@ -287,11 +268,54 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ThemeHelper.ApplyThemeToControl(this);
|
ThemeHelper.ApplyThemeToControl(this);
|
||||||
|
|
||||||
|
if (CheckUpdateButton != null)
|
||||||
|
{
|
||||||
|
CheckUpdateButton.Background = ThemeHelper.GetButtonBackgroundBrush();
|
||||||
|
CheckUpdateButton.Foreground = ThemeHelper.GetTextPrimaryBrush();
|
||||||
|
CheckUpdateButton.BorderBrush = ThemeHelper.GetBorderPrimaryBrush();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (UpdateNowButton != null)
|
||||||
|
{
|
||||||
|
UpdateNowButton.Background = new SolidColorBrush(Color.FromRgb(0, 120, 212));
|
||||||
|
UpdateNowButton.Foreground = Brushes.White;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine($"UpdateCenterPanel 应用主题时出错: {ex.Message}");
|
System.Diagnostics.Debug.WriteLine($"UpdateCenterPanel 应用主题时出错: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StartLoadingAnimation()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (LoadingSpinner != null)
|
||||||
|
{
|
||||||
|
LoadingSpinner.IsActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"启动加载动画失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopLoadingAnimation()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (LoadingSpinner != null)
|
||||||
|
{
|
||||||
|
LoadingSpinner.IsActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine($"停止加载动画失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user