add:新设置
This commit is contained in:
@@ -71,7 +71,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
var copyright = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyCopyrightAttribute>();
|
||||
if (copyright != null && !string.IsNullOrEmpty(copyright.Copyright))
|
||||
{
|
||||
{
|
||||
var copyrightText = copyright.Copyright;
|
||||
AboutCopyright.Text = copyrightText;
|
||||
AboutBottomCopyright.Text = copyrightText.Replace("Copyright ©", "© Copyright") + " 所有";
|
||||
@@ -97,13 +97,13 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
var bt = File.GetCreationTime(filePath);
|
||||
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');
|
||||
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 = $"{bt.Year}-{m}-{d} {h}:{min}:{s}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AboutBuildTime.Text = "获取失败";
|
||||
@@ -122,7 +122,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
try
|
||||
{
|
||||
var support = TouchTabletDetectHelper.IsTouchEnabled();
|
||||
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
|
||||
var touchcount = TouchTabletDetectHelper.GetTouchTabletDevices().Count;
|
||||
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
@@ -145,7 +145,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
AboutTouchTabletText.Text = "检测失败");
|
||||
System.Diagnostics.Debug.WriteLine($"检测触摸设备失败: {ex.Message}");
|
||||
}
|
||||
@@ -208,12 +208,12 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
|
||||
try
|
||||
{
|
||||
ManagementObjectCollection collection;
|
||||
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
|
||||
collection = searcher.Get();
|
||||
ManagementObjectCollection collection;
|
||||
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
|
||||
collection = searcher.Get();
|
||||
|
||||
foreach (var device in collection)
|
||||
{
|
||||
foreach (var device in collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
var name = device.GetPropertyValue("Name")?.ToString() ?? "";
|
||||
@@ -231,7 +231,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
descLower.Contains("touch") ||
|
||||
descLower.Contains("digitizer"))
|
||||
{
|
||||
devices.Add(new USBDeviceInfo(
|
||||
devices.Add(new USBDeviceInfo(
|
||||
device.GetPropertyValue("DeviceID")?.ToString() ?? "",
|
||||
device.GetPropertyValue("PNPDeviceID")?.ToString() ?? "",
|
||||
description
|
||||
@@ -242,9 +242,9 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collection.Dispose();
|
||||
collection.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -271,10 +271,10 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
public static DateTimeOffset? GetBuildDateTime(Assembly assembly)
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = assembly.Location;
|
||||
{
|
||||
var path = assembly.Location;
|
||||
if (string.IsNullOrEmpty(path) || !File.Exists(path))
|
||||
{
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -298,18 +298,18 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
fileStream.Read(fileHeader, 0, fileHeader.Length);
|
||||
|
||||
var pinnedBuffer = GCHandle.Alloc(fileHeader, GCHandleType.Pinned);
|
||||
try
|
||||
{
|
||||
var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER));
|
||||
try
|
||||
{
|
||||
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 buildTime = epoch.AddSeconds(coffHeader.TimeDateStamp);
|
||||
return new DateTimeOffset(buildTime.ToLocalTime());
|
||||
}
|
||||
finally
|
||||
{
|
||||
pinnedBuffer.Free();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
pinnedBuffer.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -461,7 +461,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
System.Diagnostics.Debug.WriteLine($"打开贡献者名单失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 应用主题
|
||||
/// </summary>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="950" d:DesignWidth="640">
|
||||
<UserControl.Resources>
|
||||
@@ -75,49 +76,42 @@
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<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">
|
||||
<TextBlock Foreground="#2e3436" FontSize="24" FontWeight="Bold" Text="更新中心" Margin="0,0,0,8"/>
|
||||
<TextBlock Foreground="#878787" FontSize="14" Text="检查并安装 InkCanvasForClass 的最新更新" TextWrapping="Wrap" Margin="0,0,0,24"/>
|
||||
<StackPanel Margin="60,24,60,24">
|
||||
<TextBlock Foreground="#2e3436" FontSize="28" FontWeight="Bold" Text="InkCanvasForClass 更新" 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>
|
||||
<Grid Margin="0,0,0,16">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="18" FontWeight="SemiBold" Text="当前版本" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<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"/>
|
||||
|
||||
<Grid Margin="0,0,0,16">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#2e3436" FontSize="18" FontWeight="SemiBold" Text="更新状态" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<TextBlock Name="UpdateStatusText" Foreground="#878787" FontSize="16" Text="正在检查更新..." VerticalAlignment="Center"/>
|
||||
<Image Name="UpdateStatusIcon" Margin="8,0,0,0" Width="20" Height="20" VerticalAlignment="Center" Visibility="Collapsed">
|
||||
<Image.Source>
|
||||
<DrawingImage>
|
||||
<DrawingImage.Drawing>
|
||||
<DrawingGroup ClipGeometry="M0,0 V16 H16 V0 H0 Z">
|
||||
<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" Margin="0,0,0,16"/>
|
||||
|
||||
<StackPanel Name="UpdateAvailablePanel" Visibility="Collapsed">
|
||||
<TextBlock Name="UpdateStatusText" Foreground="#2e3436" FontSize="18" FontWeight="SemiBold" Text="正在检查更新..." TextWrapping="Wrap" Margin="0,0,0,8"/>
|
||||
<TextBlock Name="LastCheckTimeText" Foreground="#878787" FontSize="14" Text="上次检查时间: 从未" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<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>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,24">
|
||||
<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">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<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"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Name="UpdateAvailablePanel" Visibility="Collapsed" Margin="0,0,0,24">
|
||||
<Border BorderBrush="#e6e6e6" BorderThickness="1" CornerRadius="8" Padding="16" Background="#F9F9F9">
|
||||
<StackPanel>
|
||||
<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"/>
|
||||
<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>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="4" Padding="{TemplateBinding Padding}">
|
||||
@@ -127,47 +121,8 @@
|
||||
</Button.Template>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<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">
|
||||
<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>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
using iNKORE.UI.WPF.Helpers;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
@@ -27,6 +29,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
isLoaded = true;
|
||||
LoadSettings();
|
||||
CheckUpdateStatus();
|
||||
ApplyTheme();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,24 +38,10 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadLastCheckTime();
|
||||
}
|
||||
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;
|
||||
|
||||
toggle.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
|
||||
var innerBorder = toggle.Child as Border;
|
||||
if (innerBorder != null)
|
||||
try
|
||||
{
|
||||
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
|
||||
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;
|
||||
|
||||
if (timeDiff.TotalDays < 1 && lastCheckTime.Date == now.Date)
|
||||
{
|
||||
LastCheckTimeText.Text = $"上次检查时间: 今天, {lastCheckTime:HH:mm}";
|
||||
}
|
||||
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
|
||||
{
|
||||
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;
|
||||
LastCheckTimeText.Text = "上次检查时间: 从未";
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSwitch_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
private void SaveLastCheckTime()
|
||||
{
|
||||
var toggle = sender as Border;
|
||||
if (toggle == null) return;
|
||||
|
||||
var tag = toggle.Tag?.ToString();
|
||||
if (tag == "AutoUpdate" && MainWindow.Settings?.Startup != null)
|
||||
try
|
||||
{
|
||||
MainWindowSettingsHelper.UpdateSettingSafely(() =>
|
||||
{
|
||||
MainWindow.Settings.Startup.IsAutoUpdate = !MainWindow.Settings.Startup.IsAutoUpdate;
|
||||
UpdateToggleSwitch(toggle, MainWindow.Settings.Startup.IsAutoUpdate);
|
||||
}, "ToggleSwitchIsAutoUpdate_Toggled", "ToggleSwitchIsAutoUpdate");
|
||||
var lastCheckTimePath = Path.Combine(App.RootPath, "last_update_check.dat");
|
||||
File.WriteAllText(lastCheckTimePath, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
LoadLastCheckTime();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"保存上次检查时间失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckUpdateButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CheckUpdateStatus();
|
||||
CheckUpdateStatus(true);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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()
|
||||
private void CheckUpdateStatus(bool manualCheck = false)
|
||||
{
|
||||
UpdateStatusText.Text = "正在检查更新...";
|
||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||
CheckUpdateButton.IsEnabled = false;
|
||||
StartLoadingAnimation();
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow != null)
|
||||
var updateChannel = UpdateChannel.Release;
|
||||
if (MainWindow.Settings?.Startup != null)
|
||||
{
|
||||
var field = typeof(MainWindow).GetField("AvailableLatestVersion", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
if (field != null)
|
||||
updateChannel = MainWindow.Settings.Startup.UpdateChannel;
|
||||
}
|
||||
|
||||
var (remoteVersion, lineGroup, releaseNotes) = await AutoUpdateHelper.CheckForUpdates(updateChannel, manualCheck, false);
|
||||
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
StopLoadingAnimation();
|
||||
|
||||
if (!string.IsNullOrEmpty(remoteVersion))
|
||||
{
|
||||
var availableVersion = field.GetValue(mainWindow) as string;
|
||||
var localVersion = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
var localVersionStr = localVersion.ToString();
|
||||
var remoteVersionStr = remoteVersion.TrimStart('v', 'V');
|
||||
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
Version local = new Version(localVersionStr);
|
||||
Version remote = new Version(remoteVersionStr);
|
||||
|
||||
if (remote > local)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(availableVersion))
|
||||
{
|
||||
UpdateStatusText.Text = "有可用更新";
|
||||
UpdateStatusIcon.Visibility = Visibility.Visible;
|
||||
LatestVersionText.Text = $"版本 {availableVersion} 现已可用";
|
||||
UpdateAvailablePanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText.Text = "已是最新版本";
|
||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
CheckUpdateButton.IsEnabled = true;
|
||||
}));
|
||||
UpdateStatusText.Text = "有可用更新";
|
||||
LatestVersionText.Text = $"版本 {remoteVersion} 现已可用";
|
||||
UpdateAvailablePanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateStatusText.Text = "你使用的是最新版本";
|
||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
UpdateStatusText.Text = "检查更新失败";
|
||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||
CheckUpdateButton.IsEnabled = true;
|
||||
}));
|
||||
UpdateStatusText.Text = "你使用的是最新版本";
|
||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
if (manualCheck)
|
||||
{
|
||||
SaveLastCheckTime();
|
||||
}
|
||||
|
||||
CheckUpdateButton.IsEnabled = true;
|
||||
}));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
{
|
||||
StopLoadingAnimation();
|
||||
UpdateStatusText.Text = "检查更新失败";
|
||||
UpdateStatusIcon.Visibility = Visibility.Collapsed;
|
||||
UpdateAvailablePanel.Visibility = Visibility.Collapsed;
|
||||
CheckUpdateButton.IsEnabled = true;
|
||||
}));
|
||||
@@ -287,11 +268,54 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
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