优化代码
This commit is contained in:
@@ -67,7 +67,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
@@ -109,7 +109,7 @@ namespace Ink_Canvas
|
||||
MainWindow.SaveSettingsToFile();
|
||||
|
||||
IsSuccess = true;
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
||||
@@ -110,7 +110,7 @@ namespace Ink_Canvas
|
||||
MainWindow.SaveSettingsToFile();
|
||||
|
||||
IsSuccess = true;
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Media;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Application = System.Windows.Application;
|
||||
using MouseEventArgs = System.Windows.Input.MouseEventArgs;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -51,7 +57,7 @@ namespace Ink_Canvas
|
||||
TextBlockSecond.Text = "00";
|
||||
timer.Stop();
|
||||
isTimerRunning = false;
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
|
||||
SymbolIconStart.Symbol = Symbol.Play;
|
||||
BtnStartCover.Visibility = Visibility.Visible;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
@@ -70,16 +76,16 @@ namespace Ink_Canvas
|
||||
|
||||
SoundPlayer player = new SoundPlayer();
|
||||
|
||||
int hour = 0;
|
||||
int hour;
|
||||
int minute = 1;
|
||||
int second = 0;
|
||||
int second;
|
||||
int totalSeconds = 60;
|
||||
|
||||
DateTime startTime = DateTime.Now;
|
||||
DateTime pauseTime = DateTime.Now;
|
||||
|
||||
bool isTimerRunning = false;
|
||||
bool isPaused = false;
|
||||
bool isTimerRunning;
|
||||
bool isPaused;
|
||||
|
||||
Timer timer = new Timer();
|
||||
|
||||
@@ -202,12 +208,12 @@ namespace Ink_Canvas
|
||||
if (WindowState == WindowState.Normal)
|
||||
{
|
||||
WindowState = WindowState.Maximized;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.BackToWindow;
|
||||
SymbolIconFullscreen.Symbol = Symbol.BackToWindow;
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = WindowState.Normal;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.FullScreen;
|
||||
SymbolIconFullscreen.Symbol = Symbol.FullScreen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,7 +228,6 @@ namespace Ink_Canvas
|
||||
BtnStartCover.Visibility = Visibility.Collapsed;
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
return;
|
||||
}
|
||||
else if (isTimerRunning && isPaused)
|
||||
{
|
||||
@@ -233,7 +238,7 @@ namespace Ink_Canvas
|
||||
BtnStartCover.Visibility = Visibility.Collapsed;
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
|
||||
SymbolIconStart.Symbol = Symbol.Play;
|
||||
isTimerRunning = false;
|
||||
timer.Stop();
|
||||
isPaused = false;
|
||||
@@ -283,7 +288,7 @@ namespace Ink_Canvas
|
||||
startTime += DateTime.Now - pauseTime;
|
||||
ProcessBarTime.IsPaused = false;
|
||||
TextBlockHour.Foreground = Brushes.Black;
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pause;
|
||||
SymbolIconStart.Symbol = Symbol.Pause;
|
||||
isPaused = false;
|
||||
timer.Start();
|
||||
UpdateStopTime();
|
||||
@@ -295,7 +300,7 @@ namespace Ink_Canvas
|
||||
pauseTime = DateTime.Now;
|
||||
ProcessBarTime.IsPaused = true;
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Play;
|
||||
SymbolIconStart.Symbol = Symbol.Play;
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
isPaused = true;
|
||||
timer.Stop();
|
||||
@@ -307,7 +312,7 @@ namespace Ink_Canvas
|
||||
totalSeconds = ((hour * 60) + minute) * 60 + second;
|
||||
ProcessBarTime.IsPaused = false;
|
||||
TextBlockHour.Foreground = Brushes.Black;
|
||||
SymbolIconStart.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.Pause;
|
||||
SymbolIconStart.Symbol = Symbol.Pause;
|
||||
BtnResetCover.Visibility = Visibility.Collapsed;
|
||||
|
||||
if (totalSeconds <= 10)
|
||||
@@ -335,7 +340,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
isTimerRunning = false;
|
||||
}
|
||||
@@ -345,7 +350,7 @@ namespace Ink_Canvas
|
||||
Close();
|
||||
}
|
||||
|
||||
private bool _isInCompact = false;
|
||||
private bool _isInCompact;
|
||||
|
||||
private void BtnMinimal_OnMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
@@ -364,7 +369,7 @@ namespace Ink_Canvas
|
||||
dpiScaleY = source.CompositionTarget.TransformToDevice.M22;
|
||||
}
|
||||
IntPtr windowHandle = new WindowInteropHelper(this).Handle;
|
||||
System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.FromHandle(windowHandle);
|
||||
Screen screen = Screen.FromHandle(windowHandle);
|
||||
double screenWidth = screen.Bounds.Width / dpiScaleX, screenHeight = screen.Bounds.Height / dpiScaleY;
|
||||
Left = (screenWidth / 2) - (Width / 2);
|
||||
Top = (screenHeight / 2) - (Height / 2);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ namespace Ink_Canvas.ProcessBars
|
||||
//达到100%则闭合整个
|
||||
if (angel == 360)
|
||||
{
|
||||
myCycleProcessBar.Data = Geometry.Parse(myCycleProcessBar.Data.ToString() + " z");
|
||||
myCycleProcessBar.Data = Geometry.Parse(myCycleProcessBar.Data + " z");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using MdXaml;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -98,7 +101,7 @@ namespace Ink_Canvas
|
||||
UseImmersiveDarkMode(new WindowInteropHelper(this).Handle, true);
|
||||
|
||||
// 窗口加载完成后再次确保按钮可见
|
||||
this.Loaded += HasNewUpdateWindow_Loaded;
|
||||
Loaded += HasNewUpdateWindow_Loaded;
|
||||
}
|
||||
|
||||
private void HasNewUpdateWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
@@ -231,35 +234,35 @@ namespace Ink_Canvas
|
||||
bool needsAdjustment = false;
|
||||
|
||||
// 如果窗口高度超过最大允许高度,调整窗口高度
|
||||
if (this.Height > maxHeight)
|
||||
if (Height > maxHeight)
|
||||
{
|
||||
this.Height = maxHeight;
|
||||
Height = maxHeight;
|
||||
needsAdjustment = true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window height to: {this.Height}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window height to: {Height}");
|
||||
}
|
||||
|
||||
// 如果窗口宽度超过最大允许宽度,调整窗口宽度
|
||||
if (this.Width > maxWidth)
|
||||
if (Width > maxWidth)
|
||||
{
|
||||
this.Width = maxWidth;
|
||||
Width = maxWidth;
|
||||
needsAdjustment = true;
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window width to: {this.Width}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Adjusted window width to: {Width}");
|
||||
}
|
||||
|
||||
// 如果屏幕分辨率较低,调整更多UI元素
|
||||
if (screenHeight < 768 || screenWidth < 1024 || needsAdjustment)
|
||||
{
|
||||
// 查找相关控件并调整大小
|
||||
var markdownViewer = this.FindName("markdownContent") as MdXaml.MarkdownScrollViewer;
|
||||
var updateNowButton = this.FindName("UpdateNowButton") as Button;
|
||||
var updateLaterButton = this.FindName("UpdateLaterButton") as Button;
|
||||
var skipVersionButton = this.FindName("SkipVersionButton") as Button;
|
||||
var markdownViewer = FindName("markdownContent") as MarkdownScrollViewer;
|
||||
var updateNowButton = FindName("UpdateNowButton") as Button;
|
||||
var updateLaterButton = FindName("UpdateLaterButton") as Button;
|
||||
var skipVersionButton = FindName("SkipVersionButton") as Button;
|
||||
|
||||
// 查找包含ScrollViewer的边框控件,减小其高度
|
||||
var contentBorders = this.FindVisualChildren<Border>().ToList();
|
||||
var contentBorders = FindVisualChildren<Border>().ToList();
|
||||
foreach (var border in contentBorders)
|
||||
{
|
||||
if (border.Child is ScrollViewer || border.Child is iNKORE.UI.WPF.Modern.Controls.ScrollViewerEx)
|
||||
if (border.Child is ScrollViewer || border.Child is ScrollViewerEx)
|
||||
{
|
||||
// 减小内容显示区域的高度
|
||||
if (border.Height > 180)
|
||||
@@ -267,7 +270,7 @@ namespace Ink_Canvas
|
||||
border.Height = 160;
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Reduced content area height");
|
||||
}
|
||||
else if (border.Child is iNKORE.UI.WPF.Modern.Controls.ScrollViewerEx scrollViewer && scrollViewer.Height > 160)
|
||||
else if (border.Child is ScrollViewerEx scrollViewer && scrollViewer.Height > 160)
|
||||
{
|
||||
scrollViewer.Height = 160;
|
||||
LogHelper.WriteLogToFile("AutoUpdate | Reduced scroll viewer height");
|
||||
@@ -289,12 +292,12 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
// 确保窗口在屏幕范围内
|
||||
if (this.Left < 0) this.Left = 0;
|
||||
if (this.Top < 0) this.Top = 0;
|
||||
if (this.Left + this.Width > screenWidth) this.Left = screenWidth - this.Width;
|
||||
if (this.Top + this.Height > screenHeight) this.Top = screenHeight - this.Height;
|
||||
if (Left < 0) Left = 0;
|
||||
if (Top < 0) Top = 0;
|
||||
if (Left + Width > screenWidth) Left = screenWidth - Width;
|
||||
if (Top + Height > screenHeight) Top = screenHeight - Height;
|
||||
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Final window size: {this.Width}x{this.Height}");
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | Final window size: {Width}x{Height}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -332,7 +335,7 @@ namespace Ink_Canvas
|
||||
if (string.IsNullOrEmpty(downloadUrl))
|
||||
{
|
||||
// 自动更新场景下,downloadUrl为null,直接用主下载目录
|
||||
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
string updatesFolderPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate");
|
||||
downloadUrl = Path.Combine(updatesFolderPath, $"InkCanvasForClass.CE.{version}.zip");
|
||||
}
|
||||
LogHelper.WriteLogToFile($"AutoUpdate | 开始安装版本: {version}");
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Linq; // Added for OrderByDescending
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
// Added for OrderByDescending
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -22,7 +22,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
|
||||
private List<VersionItem> versionList = new List<VersionItem>();
|
||||
private VersionItem selectedItem = null;
|
||||
private VersionItem selectedItem;
|
||||
private UpdateChannel channel = UpdateChannel.Release;
|
||||
private CancellationTokenSource downloadCts = null;
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Ink_Canvas
|
||||
else
|
||||
{
|
||||
ReleaseNotesViewer.Markdown = "未获取到历史版本信息。";
|
||||
LogHelper.WriteLogToFile($"HistoryRollback | 未获取到历史版本信息", LogHelper.LogType.Warning);
|
||||
LogHelper.WriteLogToFile("HistoryRollback | 未获取到历史版本信息", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ namespace Ink_Canvas
|
||||
DownloadProgressBar.Value = 100;
|
||||
DownloadProgressText.Text = "下载完成,准备安装...";
|
||||
await Task.Delay(800);
|
||||
this.DialogResult = true;
|
||||
this.Close();
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Ink_Canvas
|
||||
|
||||
private void CloseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using Ink_Canvas.Helpers;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -26,7 +27,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (originText != TextBoxNames.Text)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -28,10 +29,10 @@ namespace Ink_Canvas
|
||||
private void BtnFullscreen_MouseUp(object sender, MouseButtonEventArgs e) {
|
||||
if (WindowState == WindowState.Normal) {
|
||||
WindowState = WindowState.Maximized;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.BackToWindow;
|
||||
SymbolIconFullscreen.Symbol = Symbol.BackToWindow;
|
||||
} else {
|
||||
WindowState = WindowState.Normal;
|
||||
SymbolIconFullscreen.Symbol = iNKORE.UI.WPF.Modern.Controls.Symbol.FullScreen;
|
||||
SymbolIconFullscreen.Symbol = Symbol.FullScreen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
using Ink_Canvas.Helpers.Plugins;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using Ink_Canvas.Helpers;
|
||||
using System.Linq;
|
||||
using Ink_Canvas.Helpers.Plugins;
|
||||
using Ink_Canvas.Helpers.Plugins.BuiltIn;
|
||||
using Ink_Canvas.Helpers.Plugins.BuiltIn.SuperLauncher;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Microsoft.Win32;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Ink_Canvas.Windows
|
||||
{
|
||||
@@ -36,7 +41,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
|
||||
OnPropertyChanged(nameof(SelectedPlugin));
|
||||
LogHelper.WriteLogToFile("插件列表已刷新", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件列表已刷新");
|
||||
}
|
||||
|
||||
private IPlugin _selectedPlugin;
|
||||
@@ -90,20 +95,20 @@ namespace Ink_Canvas.Windows
|
||||
LoadPlugins();
|
||||
|
||||
// 注册窗口关闭事件
|
||||
this.Closing += PluginSettingsWindow_Closing;
|
||||
Closing += PluginSettingsWindow_Closing;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口关闭事件处理
|
||||
/// </summary>
|
||||
private void PluginSettingsWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void PluginSettingsWindow_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存插件配置
|
||||
LogHelper.WriteLogToFile("插件管理窗口关闭,保存插件配置...", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件管理窗口关闭,保存插件配置...");
|
||||
PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile("插件配置已保存", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件配置已保存");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -118,7 +123,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
Plugins.Clear();
|
||||
|
||||
LogHelper.WriteLogToFile($"开始加载插件列表到UI,插件总数: {PluginManager.Instance.Plugins.Count}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"开始加载插件列表到UI,插件总数: {PluginManager.Instance.Plugins.Count}");
|
||||
|
||||
// 添加所有已加载的插件
|
||||
foreach (var plugin in PluginManager.Instance.Plugins)
|
||||
@@ -132,8 +137,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
|
||||
// 记录插件详细信息
|
||||
LogHelper.WriteLogToFile($"正在加载插件到UI: 类型={plugin.GetType().FullName}, 名称={plugin.Name ?? "未命名"}, 状态={isEnabled}",
|
||||
LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"正在加载插件到UI: 类型={plugin.GetType().FullName}, 名称={plugin.Name ?? "未命名"}, 状态={isEnabled}");
|
||||
|
||||
// 创建视图模型并添加到集合
|
||||
var viewModel = new PluginViewModel(plugin)
|
||||
@@ -142,17 +146,17 @@ namespace Ink_Canvas.Windows
|
||||
};
|
||||
Plugins.Add(viewModel);
|
||||
|
||||
LogHelper.WriteLogToFile($"已加载插件到UI列表: {plugin.Name},状态: {(isEnabled ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"已加载插件到UI列表: {plugin.Name},状态: {(isEnabled ? "启用" : "禁用")}");
|
||||
}
|
||||
|
||||
// 绑定到ListView
|
||||
LogHelper.WriteLogToFile($"绑定 {Plugins.Count} 个插件到ListView", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"绑定 {Plugins.Count} 个插件到ListView");
|
||||
PluginListView.ItemsSource = Plugins;
|
||||
|
||||
// 如果有插件,选择第一个
|
||||
if (Plugins.Count > 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"选择第一个插件: {Plugins[0].Name}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"选择第一个插件: {Plugins[0].Name}");
|
||||
PluginListView.SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
@@ -389,7 +393,7 @@ namespace Ink_Canvas.Windows
|
||||
File.Copy(pluginPath, targetPath, true);
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {SelectedPlugin.Name} 已成功导出到: {targetPath}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {SelectedPlugin.Name} 已成功导出到: {targetPath}");
|
||||
MessageBox.Show($"插件 {SelectedPlugin.Name} 已成功导出!", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
@@ -407,7 +411,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
try
|
||||
{
|
||||
if (sender is iNKORE.UI.WPF.Modern.Controls.ToggleSwitch toggleSwitch &&
|
||||
if (sender is ToggleSwitch toggleSwitch &&
|
||||
toggleSwitch.Tag is IPlugin plugin)
|
||||
{
|
||||
// 记录当前开关状态
|
||||
@@ -418,14 +422,14 @@ namespace Ink_Canvas.Windows
|
||||
string pluginName = plugin.Name;
|
||||
bool wasBuiltIn = plugin.IsBuiltIn;
|
||||
|
||||
LogHelper.WriteLogToFile($"UI开关切换: {pluginName}, 目标状态: {(targetState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"UI开关切换: {pluginName}, 目标状态: {(targetState ? "启用" : "禁用")}");
|
||||
|
||||
// 切换插件状态
|
||||
PluginManager.Instance.TogglePlugin(plugin, targetState);
|
||||
|
||||
// 立即同步保存配置到文件(确保状态被立即持久化)
|
||||
PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile($"插件状态已立即保存到配置文件", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile("插件状态已立即保存到配置文件");
|
||||
|
||||
// 延迟一下再检查状态,确保变更已应用
|
||||
Dispatcher.BeginInvoke(new Action(() =>
|
||||
@@ -451,7 +455,7 @@ namespace Ink_Canvas.Windows
|
||||
|
||||
// 检查实际状态
|
||||
bool actualState = currentPlugin is PluginBase pb && pb.IsEnabled;
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 实际状态: {(actualState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} 实际状态: {(actualState ? "启用" : "禁用")}");
|
||||
|
||||
// 更新视图模型
|
||||
PluginViewModel viewModel = null;
|
||||
@@ -469,14 +473,14 @@ namespace Ink_Canvas.Windows
|
||||
// 确保视图模型状态与实际状态一致
|
||||
if (viewModel.IsEnabled != actualState)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"同步视图模型状态: {(actualState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"同步视图模型状态: {(actualState ? "启用" : "禁用")}");
|
||||
viewModel.IsEnabled = actualState;
|
||||
}
|
||||
|
||||
// 确保UI开关状态与实际状态一致
|
||||
if (toggleSwitch.IsOn != actualState)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"同步UI开关状态: {(actualState ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"同步UI开关状态: {(actualState ? "启用" : "禁用")}");
|
||||
toggleSwitch.IsOn = actualState;
|
||||
}
|
||||
}
|
||||
@@ -491,21 +495,21 @@ namespace Ink_Canvas.Windows
|
||||
if (wasBuiltIn)
|
||||
{
|
||||
// 特殊插件刷新逻辑,如果是超级启动台插件,立即刷新UI
|
||||
if (currentPlugin is Helpers.Plugins.BuiltIn.SuperLauncherPlugin &&
|
||||
PluginSettingsContainer.Content is Helpers.Plugins.BuiltIn.SuperLauncher.LauncherSettingsControl)
|
||||
if (currentPlugin is SuperLauncherPlugin &&
|
||||
PluginSettingsContainer.Content is LauncherSettingsControl)
|
||||
{
|
||||
// 重新获取设置界面
|
||||
PluginSettingsContainer.Content = currentPlugin.GetSettingsView();
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} UI状态同步完成", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"插件 {pluginName} UI状态同步完成");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"同步UI状态时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}), System.Windows.Threading.DispatcherPriority.Background);
|
||||
}), DispatcherPriority.Background);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -567,7 +571,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 应用界面的状态到插件
|
||||
PluginManager.Instance.TogglePlugin(actualPlugin, uiState);
|
||||
LogHelper.WriteLogToFile($"手动保存:同步插件 {actualPlugin.Name} 状态 {pluginState} -> {uiState}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"手动保存:同步插件 {actualPlugin.Name} 状态 {pluginState} -> {uiState}");
|
||||
syncCount++;
|
||||
}
|
||||
|
||||
@@ -575,7 +579,7 @@ namespace Ink_Canvas.Windows
|
||||
if (PluginManager.Instance.PluginStates.TryGetValue(pluginTypeName, out bool configState) && configState != uiState)
|
||||
{
|
||||
PluginManager.Instance.PluginStates[pluginTypeName] = uiState;
|
||||
LogHelper.WriteLogToFile($"手动保存:更新配置中插件 {actualPlugin.Name} 状态 {configState} -> {uiState}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"手动保存:更新配置中插件 {actualPlugin.Name} 状态 {configState} -> {uiState}");
|
||||
syncCount++;
|
||||
}
|
||||
}
|
||||
@@ -591,7 +595,7 @@ namespace Ink_Canvas.Windows
|
||||
PluginManager.Instance.SaveConfig();
|
||||
|
||||
// 记录日志
|
||||
LogHelper.WriteLogToFile($"用户手动保存插件状态配置,同步了 {syncCount} 个状态变更", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"用户手动保存插件状态配置,同步了 {syncCount} 个状态变更");
|
||||
|
||||
// 刷新插件列表,确保UI与最新状态同步
|
||||
RefreshPluginList();
|
||||
@@ -642,7 +646,7 @@ namespace Ink_Canvas.Windows
|
||||
get
|
||||
{
|
||||
string name = Plugin?.Name ?? "未命名插件";
|
||||
LogHelper.WriteLogToFile($"获取插件名称: {name},类型: {Plugin?.GetType().FullName ?? "未知"}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"获取插件名称: {name},类型: {Plugin?.GetType().FullName ?? "未知"}");
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -672,7 +676,7 @@ namespace Ink_Canvas.Windows
|
||||
_isEnabled = plugin is PluginBase pluginBase && pluginBase.IsEnabled;
|
||||
|
||||
// 记录日志
|
||||
LogHelper.WriteLogToFile($"创建插件视图模型: {plugin?.GetType().FullName ?? "未知"}, 名称: {plugin?.Name ?? "未命名"}", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"创建插件视图模型: {plugin?.GetType().FullName ?? "未知"}, 名称: {plugin?.Name ?? "未命名"}");
|
||||
|
||||
// 注册插件状态变更事件
|
||||
if (plugin is PluginBase pb)
|
||||
@@ -694,9 +698,9 @@ namespace Ink_Canvas.Windows
|
||||
// 确保配置立即保存
|
||||
if (sender is IPlugin plugin)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"视图模型捕获到插件 {plugin.Name} 状态变更: {(isEnabled ? "启用" : "禁用")}", LogHelper.LogType.Info);
|
||||
Helpers.Plugins.PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile($"视图模型已触发配置保存", LogHelper.LogType.Info);
|
||||
LogHelper.WriteLogToFile($"视图模型捕获到插件 {plugin.Name} 状态变更: {(isEnabled ? "启用" : "禁用")}");
|
||||
PluginManager.Instance.SaveConfig();
|
||||
LogHelper.WriteLogToFile("视图模型已触发配置保存");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Microsoft.VisualBasic;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using Microsoft.VisualBasic;
|
||||
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
|
||||
|
||||
namespace Ink_Canvas {
|
||||
@@ -35,7 +38,7 @@ namespace Ink_Canvas {
|
||||
{
|
||||
// 默认背景(无背景)
|
||||
BackgroundImage.ImageSource = null;
|
||||
MainBorder.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(240, 243, 249));
|
||||
MainBorder.Background = new SolidColorBrush(Color.FromRgb(240, 243, 249));
|
||||
}
|
||||
else if (selectedIndex <= settings.RandSettings.CustomPickNameBackgrounds.Count)
|
||||
{
|
||||
@@ -43,7 +46,7 @@ namespace Ink_Canvas {
|
||||
var customBackground = settings.RandSettings.CustomPickNameBackgrounds[selectedIndex - 1];
|
||||
if (File.Exists(customBackground.FilePath))
|
||||
{
|
||||
var bitmap = new System.Windows.Media.Imaging.BitmapImage();
|
||||
var bitmap = new BitmapImage();
|
||||
bitmap.BeginInit();
|
||||
bitmap.UriSource = new Uri(customBackground.FilePath);
|
||||
bitmap.EndInit();
|
||||
@@ -69,16 +72,16 @@ namespace Ink_Canvas {
|
||||
// 加载背景
|
||||
LoadBackground(settings);
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(100);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
BorderBtnRand_MouseUp(BorderBtnRand, null);
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public static int randSeed = 0;
|
||||
public bool isAutoClose = false;
|
||||
public bool isAutoClose;
|
||||
public bool isNotRepeatName = false;
|
||||
|
||||
public int TotalCount = 1;
|
||||
@@ -118,7 +121,7 @@ namespace Ink_Canvas {
|
||||
LabelOutput2.Visibility = Visibility.Collapsed;
|
||||
LabelOutput3.Visibility = Visibility.Collapsed;
|
||||
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
for (int i = 0; i < RandWaitingTimes; i++) {
|
||||
int rand = random.Next(1, PeopleCount + 1);
|
||||
while (rands.Contains(rand)) {
|
||||
@@ -152,55 +155,55 @@ namespace Ink_Canvas {
|
||||
outputString += Names[rand - 1] + Environment.NewLine;
|
||||
} else {
|
||||
outputs.Add(rand.ToString());
|
||||
outputString += rand.ToString() + Environment.NewLine;
|
||||
outputString += rand + Environment.NewLine;
|
||||
}
|
||||
}
|
||||
if (TotalCount <= 5) {
|
||||
LabelOutput.Content = outputString.ToString().Trim();
|
||||
LabelOutput.Content = outputString.Trim();
|
||||
} else if (TotalCount <= 10) {
|
||||
LabelOutput2.Visibility = Visibility.Visible;
|
||||
outputString = "";
|
||||
for (int i = 0; i < (outputs.Count + 1) / 2; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput.Content = outputString.ToString().Trim();
|
||||
LabelOutput.Content = outputString.Trim();
|
||||
outputString = "";
|
||||
for (int i = (outputs.Count + 1) / 2; i < outputs.Count; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput2.Content = outputString.ToString().Trim();
|
||||
LabelOutput2.Content = outputString.Trim();
|
||||
} else {
|
||||
LabelOutput2.Visibility = Visibility.Visible;
|
||||
LabelOutput3.Visibility = Visibility.Visible;
|
||||
outputString = "";
|
||||
for (int i = 0; i < (outputs.Count + 1) / 3; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput.Content = outputString.ToString().Trim();
|
||||
LabelOutput.Content = outputString.Trim();
|
||||
outputString = "";
|
||||
for (int i = (outputs.Count + 1) / 3; i < (outputs.Count + 1) * 2 / 3; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput2.Content = outputString.ToString().Trim();
|
||||
LabelOutput2.Content = outputString.Trim();
|
||||
outputString = "";
|
||||
for (int i = (outputs.Count + 1) * 2 / 3; i < outputs.Count; i++) {
|
||||
outputString += outputs[i].ToString() + Environment.NewLine;
|
||||
outputString += outputs[i] + Environment.NewLine;
|
||||
}
|
||||
LabelOutput3.Content = outputString.ToString().Trim();
|
||||
LabelOutput3.Content = outputString.Trim();
|
||||
}
|
||||
|
||||
if (isAutoClose) {
|
||||
new Thread(new ThreadStart(() => {
|
||||
new Thread(() => {
|
||||
Thread.Sleep(RandDoneAutoCloseWaitTime);
|
||||
Application.Current.Dispatcher.Invoke(() => {
|
||||
PeopleControlPane.Opacity = 1;
|
||||
PeopleControlPane.IsHitTestVisible = true;
|
||||
Close();
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
});
|
||||
})).Start();
|
||||
}).Start();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
@@ -261,7 +264,7 @@ namespace Ink_Canvas {
|
||||
|
||||
try
|
||||
{
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "classisland://plugins/IslandCaller/Run",
|
||||
UseShellExecute = true
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user