1145141919810
代码清理
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Threading;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Ink_Canvas.Windows
|
||||
{
|
||||
@@ -18,7 +17,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
private DispatcherTimer _timer;
|
||||
private int _loadingStep = 0;
|
||||
private int _actualSplashStyle = 1;
|
||||
private int _actualSplashStyle = 1;
|
||||
private readonly string[] _loadingMessages = {
|
||||
"正在启动 Ink Canvas...",
|
||||
"正在初始化组件...",
|
||||
@@ -37,13 +36,13 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 设置窗口居中
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
|
||||
|
||||
// 设置版本号
|
||||
SetVersionText();
|
||||
|
||||
|
||||
// 加载启动图片并获取实际样式
|
||||
_actualSplashStyle = LoadSplashImageWithStyle();
|
||||
|
||||
|
||||
// 启动加载动画
|
||||
StartLoadingAnimation();
|
||||
}
|
||||
@@ -52,7 +51,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
_timer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(1200)
|
||||
Interval = TimeSpan.FromMilliseconds(1200)
|
||||
};
|
||||
_timer.Tick += Timer_Tick;
|
||||
_timer.Start();
|
||||
@@ -83,7 +82,7 @@ namespace Ink_Canvas.Windows
|
||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseIn }
|
||||
};
|
||||
|
||||
fadeOutAnimation.Completed += (s, e) =>
|
||||
fadeOutAnimation.Completed += (s, e) =>
|
||||
{
|
||||
this.Close();
|
||||
};
|
||||
@@ -101,7 +100,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 设置进度条颜色
|
||||
SetProgressBarColor();
|
||||
|
||||
|
||||
// 获取进度条容器的实际宽度
|
||||
double containerWidth = ProgressBarBackground.ActualWidth;
|
||||
if (containerWidth <= 0)
|
||||
@@ -109,13 +108,13 @@ namespace Ink_Canvas.Windows
|
||||
// 如果ActualWidth为0,使用设计时宽度
|
||||
containerWidth = 530;
|
||||
}
|
||||
|
||||
|
||||
// 计算目标宽度
|
||||
double targetWidth = containerWidth * (progress / 100.0);
|
||||
|
||||
|
||||
// 创建Storyboard动画
|
||||
var storyboard = new Storyboard();
|
||||
|
||||
|
||||
// 创建宽度动画
|
||||
var widthAnimation = new DoubleAnimation
|
||||
{
|
||||
@@ -124,20 +123,20 @@ namespace Ink_Canvas.Windows
|
||||
Duration = TimeSpan.FromMilliseconds(300),
|
||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
||||
};
|
||||
|
||||
|
||||
// 设置动画目标
|
||||
Storyboard.SetTarget(widthAnimation, ProgressBarFill);
|
||||
Storyboard.SetTargetProperty(widthAnimation, new PropertyPath(Border.WidthProperty));
|
||||
|
||||
|
||||
// 添加动画到Storyboard
|
||||
storyboard.Children.Add(widthAnimation);
|
||||
|
||||
|
||||
// 添加动画完成事件
|
||||
storyboard.Completed += (s, e) =>
|
||||
{
|
||||
// 确保最终值正确设置
|
||||
ProgressBarFill.Width = targetWidth;
|
||||
|
||||
|
||||
// 根据进度调整圆角
|
||||
if (progress >= 100)
|
||||
{
|
||||
@@ -150,7 +149,7 @@ namespace Ink_Canvas.Windows
|
||||
ProgressBarFill.CornerRadius = new CornerRadius(0, 0, 0, 7);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 开始动画
|
||||
storyboard.Begin();
|
||||
});
|
||||
@@ -171,7 +170,7 @@ namespace Ink_Canvas.Windows
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
LoadingText.Text = message;
|
||||
|
||||
|
||||
// 根据实际启动动画样式调整加载文本样式
|
||||
if (actualSplashStyle == 6) // 马年限定
|
||||
{
|
||||
@@ -180,7 +179,7 @@ namespace Ink_Canvas.Windows
|
||||
LoadingText.FontWeight = FontWeights.SemiBold;
|
||||
LoadingText.Foreground = Brushes.White;
|
||||
LoadingText.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
LoadingText.Margin = new Thickness(0,200,140,4);
|
||||
LoadingText.Margin = new Thickness(0, 200, 140, 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -189,7 +188,7 @@ namespace Ink_Canvas.Windows
|
||||
LoadingText.FontWeight = FontWeights.SemiBold;
|
||||
LoadingText.Foreground = Brushes.White;
|
||||
LoadingText.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
LoadingText.Margin = new Thickness(0,200,0,0);
|
||||
LoadingText.Margin = new Thickness(0, 200, 0, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -282,7 +281,7 @@ namespace Ink_Canvas.Windows
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine($"加载启动图片失败: {ex.Message}");
|
||||
return GetActualStyle(1);
|
||||
return GetActualStyle(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +295,7 @@ namespace Ink_Canvas.Windows
|
||||
// 读取设置
|
||||
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "Settings.json");
|
||||
int splashStyle = 1; // 默认跟随四季
|
||||
|
||||
|
||||
if (File.Exists(settingsPath))
|
||||
{
|
||||
var json = File.ReadAllText(settingsPath);
|
||||
@@ -313,7 +312,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
catch
|
||||
{
|
||||
string imageName = GetImageNameByStyle(1);
|
||||
string imageName = GetImageNameByStyle(1);
|
||||
return $"pack://application:,,,/Resources/Startup-animation/{imageName}";
|
||||
}
|
||||
}
|
||||
@@ -330,7 +329,7 @@ namespace Ink_Canvas.Windows
|
||||
// 读取设置
|
||||
var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs", "Settings.json");
|
||||
int splashStyle = 1; // 默认跟随四季
|
||||
|
||||
|
||||
if (File.Exists(settingsPath))
|
||||
{
|
||||
var json = File.ReadAllText(settingsPath);
|
||||
@@ -349,7 +348,7 @@ namespace Ink_Canvas.Windows
|
||||
catch
|
||||
{
|
||||
actualStyle = GetActualStyle(1);
|
||||
string imageName = GetImageNameByStyle(1);
|
||||
string imageName = GetImageNameByStyle(1);
|
||||
return $"pack://application:,,,/Resources/Startup-animation/{imageName}";
|
||||
}
|
||||
}
|
||||
@@ -367,16 +366,16 @@ namespace Ink_Canvas.Windows
|
||||
var random = new Random();
|
||||
var randomStyles = new[] { 2, 3, 4, 5, 6 }; // 春季、夏季、秋季、冬季、马年限定
|
||||
return randomStyles[random.Next(randomStyles.Length)];
|
||||
|
||||
|
||||
case 1: // 跟随四季
|
||||
var month = DateTime.Now.Month;
|
||||
if (month >= 3 && month <= 5) return 2; // 春季
|
||||
if (month >= 6 && month <= 8) return 3; // 夏季
|
||||
if (month >= 9 && month <= 11) return 4; // 秋季
|
||||
return 5; // 冬季
|
||||
|
||||
|
||||
default:
|
||||
return style;
|
||||
return style;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,14 +390,14 @@ namespace Ink_Canvas.Windows
|
||||
var random = new Random();
|
||||
var randomStyles = new[] { 2, 3, 4, 5, 6 }; // 春季、夏季、秋季、冬季、马年限定
|
||||
return GetImageNameByStyle(randomStyles[random.Next(randomStyles.Length)]);
|
||||
|
||||
|
||||
case 1: // 跟随四季
|
||||
var month = DateTime.Now.Month;
|
||||
if (month >= 3 && month <= 5) return GetImageNameByStyle(2); // 春季
|
||||
if (month >= 6 && month <= 8) return GetImageNameByStyle(3); // 夏季
|
||||
if (month >= 9 && month <= 11) return GetImageNameByStyle(4); // 秋季
|
||||
return GetImageNameByStyle(5); // 冬季
|
||||
|
||||
|
||||
case 2: // 春季
|
||||
return "ICC Spring.png";
|
||||
case 3: // 夏季
|
||||
@@ -410,7 +409,7 @@ namespace Ink_Canvas.Windows
|
||||
case 6: // 马年限定
|
||||
return "ICC Horse.png";
|
||||
default:// 默认返回
|
||||
return "ICC Horse.png";
|
||||
return "ICC Horse.png";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +419,7 @@ namespace Ink_Canvas.Windows
|
||||
private void SetProgressBarColor()
|
||||
{
|
||||
Color progressColor;
|
||||
|
||||
|
||||
switch (_actualSplashStyle)
|
||||
{
|
||||
case 2: // 春季 - H=136, S=15, L=22
|
||||
@@ -442,14 +441,14 @@ namespace Ink_Canvas.Windows
|
||||
progressColor = Colors.White;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// 创建渐变画刷
|
||||
var gradientBrush = new LinearGradientBrush
|
||||
{
|
||||
StartPoint = new System.Windows.Point(0, 0),
|
||||
EndPoint = new System.Windows.Point(1, 0)
|
||||
};
|
||||
|
||||
|
||||
// 根据颜色类型设置渐变
|
||||
if (_actualSplashStyle == 6) // 马年限定使用白色渐变
|
||||
{
|
||||
@@ -459,7 +458,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
else // 其他样式使用HSL颜色的渐变
|
||||
{
|
||||
var lighterColor = Color.FromArgb(255,
|
||||
var lighterColor = Color.FromArgb(255,
|
||||
(byte)Math.Min(255, progressColor.R + 30),
|
||||
(byte)Math.Min(255, progressColor.G + 30),
|
||||
(byte)Math.Min(255, progressColor.B + 30));
|
||||
@@ -467,12 +466,12 @@ namespace Ink_Canvas.Windows
|
||||
(byte)Math.Max(0, progressColor.R - 30),
|
||||
(byte)Math.Max(0, progressColor.G - 30),
|
||||
(byte)Math.Max(0, progressColor.B - 30));
|
||||
|
||||
|
||||
gradientBrush.GradientStops.Add(new GradientStop(lighterColor, 0));
|
||||
gradientBrush.GradientStops.Add(new GradientStop(progressColor, 0.5));
|
||||
gradientBrush.GradientStops.Add(new GradientStop(darkerColor, 1));
|
||||
}
|
||||
|
||||
|
||||
ProgressBarFill.Background = gradientBrush;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user