代码清理
This commit is contained in:
@@ -43,27 +43,27 @@ namespace Ink_Canvas
|
||||
TimeSpan timeSpan = DateTime.Now - startTime;
|
||||
TimeSpan totalTimeSpan = new TimeSpan(hour, minute, second);
|
||||
double spentTimePercent = timeSpan.TotalMilliseconds / (totalSeconds * 1000.0);
|
||||
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (!isOvertimeMode)
|
||||
{
|
||||
TimeSpan leftTimeSpan = totalTimeSpan - timeSpan;
|
||||
if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1);
|
||||
|
||||
|
||||
ProcessBarTime.CurrentValue = 1 - spentTimePercent;
|
||||
TextBlockHour.Text = leftTimeSpan.Hours.ToString("00");
|
||||
TextBlockMinute.Text = leftTimeSpan.Minutes.ToString("00");
|
||||
TextBlockSecond.Text = leftTimeSpan.Seconds.ToString("00");
|
||||
TbCurrentTime.Text = leftTimeSpan.ToString(@"hh\:mm\:ss");
|
||||
|
||||
|
||||
if (spentTimePercent >= 1 && MainWindow.Settings.RandSettings?.EnableOvertimeCountUp == true)
|
||||
{
|
||||
isOvertimeMode = true;
|
||||
ProcessBarTime.CurrentValue = 0;
|
||||
ProcessBarTime.Visibility = Visibility.Collapsed;
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 播放提醒音
|
||||
PlayTimerSound();
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace Ink_Canvas
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
}
|
||||
BorderStopTime.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 播放提醒音
|
||||
PlayTimerSound();
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace Ink_Canvas
|
||||
TextBlockMinute.Text = overtimeSpan.Minutes.ToString("00");
|
||||
TextBlockSecond.Text = overtimeSpan.Seconds.ToString("00");
|
||||
TbCurrentTime.Text = overtimeSpan.ToString(@"hh\:mm\:ss");
|
||||
|
||||
|
||||
if (MainWindow.Settings.RandSettings?.EnableOvertimeRedText == true)
|
||||
{
|
||||
TextBlockHour.Foreground = Brushes.Red;
|
||||
@@ -124,7 +124,7 @@ namespace Ink_Canvas
|
||||
bool isTimerRunning = false;
|
||||
bool isPaused = false;
|
||||
bool useLegacyUI = false;
|
||||
bool isOvertimeMode = false;
|
||||
bool isOvertimeMode = false;
|
||||
|
||||
Timer timer = new Timer();
|
||||
|
||||
@@ -288,7 +288,7 @@ namespace Ink_Canvas
|
||||
TextBlockHour.Foreground = textForeground3;
|
||||
else
|
||||
TextBlockHour.Foreground = new SolidColorBrush(StringToColor("#FF5B5D5F"));
|
||||
|
||||
|
||||
isOvertimeMode = false;
|
||||
ProcessBarTime.Visibility = Visibility.Visible;
|
||||
}
|
||||
@@ -311,7 +311,7 @@ namespace Ink_Canvas
|
||||
isPaused = false;
|
||||
ProcessBarTime.CurrentValue = 0;
|
||||
ProcessBarTime.IsPaused = false;
|
||||
|
||||
|
||||
isOvertimeMode = false;
|
||||
ProcessBarTime.Visibility = Visibility.Visible;
|
||||
}
|
||||
@@ -416,7 +416,7 @@ namespace Ink_Canvas
|
||||
|
||||
isPaused = false;
|
||||
isTimerRunning = true;
|
||||
isOvertimeMode = false;
|
||||
isOvertimeMode = false;
|
||||
ProcessBarTime.Visibility = Visibility.Visible;
|
||||
timer.Start();
|
||||
UpdateStopTime();
|
||||
|
||||
@@ -25,25 +25,25 @@ namespace Ink_Canvas.Windows
|
||||
public DlassSettingsWindow(MainWindow mainWindow = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
// 初始化班级下拉框
|
||||
CmbClassSelection.Items.Clear();
|
||||
CmbClassSelection.Items.Add("(等待连接)");
|
||||
CmbClassSelection.SelectedIndex = 0;
|
||||
CmbClassSelection.IsEnabled = false;
|
||||
|
||||
|
||||
// 加载保存的token
|
||||
LoadUserToken();
|
||||
|
||||
|
||||
// 加载自动上传设置
|
||||
LoadAutoUploadSettings();
|
||||
|
||||
|
||||
// 初始化API客户端(优先使用用户token)
|
||||
InitializeApiClient();
|
||||
|
||||
|
||||
// 窗口关闭时释放资源
|
||||
Closed += (s, e) => _apiClient?.Dispose();
|
||||
|
||||
|
||||
// 测试连接
|
||||
_ = TestConnectionAsync();
|
||||
}
|
||||
@@ -55,7 +55,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var userToken = GetUserToken();
|
||||
var apiBaseUrl = MainWindow.Settings?.Dlass?.ApiBaseUrl;
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(apiBaseUrl) || apiBaseUrl.Contains("api.dlass.tech"))
|
||||
{
|
||||
apiBaseUrl = "https://dlass.tech";
|
||||
@@ -65,7 +65,7 @@ namespace Ink_Canvas.Windows
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(userToken))
|
||||
{
|
||||
_apiClient = new DlassApiClient(APP_ID, APP_SECRET, baseUrl: apiBaseUrl, userToken: userToken);
|
||||
@@ -107,7 +107,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var savedTokens = GetSavedTokens();
|
||||
var currentToken = GetUserToken();
|
||||
|
||||
|
||||
CmbSavedTokens.Items.Clear();
|
||||
if (savedTokens.Count > 0)
|
||||
{
|
||||
@@ -138,9 +138,9 @@ namespace Ink_Canvas.Windows
|
||||
CmbSavedTokens.SelectedIndex = 0;
|
||||
CmbSavedTokens.IsEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
TxtNewToken.Text = string.Empty;
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(currentToken))
|
||||
{
|
||||
TxtTokenStatus.Text = "已选择Token";
|
||||
@@ -176,7 +176,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
MainWindow.Settings.Dlass.SavedTokens = new List<string>();
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(token) && !MainWindow.Settings.Dlass.SavedTokens.Contains(token))
|
||||
{
|
||||
MainWindow.Settings.Dlass.SavedTokens.Add(token);
|
||||
@@ -203,7 +203,7 @@ namespace Ink_Canvas.Windows
|
||||
private void LoadClasses(List<WhiteboardInfo> whiteboards, UserInfo user = null)
|
||||
{
|
||||
CmbClassSelection.Items.Clear();
|
||||
|
||||
|
||||
if (whiteboards != null && whiteboards.Count > 0)
|
||||
{
|
||||
var teacherName = user?.Username ?? "未知教师";
|
||||
@@ -212,7 +212,7 @@ namespace Ink_Canvas.Windows
|
||||
.GroupBy(w => w.ClassName)
|
||||
.OrderBy(g => g.Key)
|
||||
.ToList();
|
||||
|
||||
|
||||
foreach (var group in classGroups)
|
||||
{
|
||||
var className = group.Key;
|
||||
@@ -224,7 +224,7 @@ namespace Ink_Canvas.Windows
|
||||
TeacherName = teacherName
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var savedClassName = MainWindow.Settings?.Dlass?.SelectedClassName ?? string.Empty;
|
||||
if (!string.IsNullOrEmpty(savedClassName))
|
||||
{
|
||||
@@ -243,7 +243,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
CmbClassSelection.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
CmbClassSelection.IsEnabled = true;
|
||||
}
|
||||
else
|
||||
@@ -339,7 +339,7 @@ namespace Ink_Canvas.Windows
|
||||
delayMinutes = 60;
|
||||
TxtUploadDelayMinutes.Text = "60";
|
||||
}
|
||||
|
||||
|
||||
MainWindow.Settings.Dlass.AutoUploadDelayMinutes = delayMinutes;
|
||||
MainWindow.SaveSettingsToFile();
|
||||
}
|
||||
@@ -398,13 +398,13 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var selectedToken = CmbSavedTokens.SelectedItem.ToString();
|
||||
SaveUserToken(selectedToken);
|
||||
|
||||
|
||||
_apiClient?.Dispose();
|
||||
InitializeApiClient();
|
||||
|
||||
|
||||
TxtTokenStatus.Text = "已选择Token";
|
||||
TxtTokenStatus.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 197, 94));
|
||||
|
||||
|
||||
_ = TestConnectionAsync();
|
||||
}
|
||||
}
|
||||
@@ -430,14 +430,14 @@ namespace Ink_Canvas.Windows
|
||||
|
||||
AddTokenToList(token);
|
||||
SaveUserToken(token);
|
||||
|
||||
|
||||
_apiClient?.Dispose();
|
||||
InitializeApiClient();
|
||||
|
||||
|
||||
LoadUserToken();
|
||||
|
||||
|
||||
MessageBox.Show("Token已成功保存并已选择", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
|
||||
|
||||
_ = TestConnectionAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -465,24 +465,24 @@ namespace Ink_Canvas.Windows
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
RemoveTokenFromList(selectedToken);
|
||||
|
||||
|
||||
if (GetUserToken() == selectedToken)
|
||||
{
|
||||
SaveUserToken(string.Empty);
|
||||
}
|
||||
|
||||
|
||||
_apiClient?.Dispose();
|
||||
InitializeApiClient();
|
||||
|
||||
|
||||
LoadUserToken();
|
||||
|
||||
|
||||
CmbClassSelection.Items.Clear();
|
||||
CmbClassSelection.Items.Add("(等待连接)");
|
||||
CmbClassSelection.SelectedIndex = 0;
|
||||
CmbClassSelection.IsEnabled = false;
|
||||
_currentWhiteboards.Clear();
|
||||
_currentUser = null;
|
||||
|
||||
|
||||
TxtConnectionStatus.Text = "未连接";
|
||||
TxtConnectionStatus.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(161, 161, 170));
|
||||
}
|
||||
@@ -513,7 +513,7 @@ namespace Ink_Canvas.Windows
|
||||
// 示例:保存设置到服务器
|
||||
// var settings = new { ... };
|
||||
// await _apiClient.PostAsync<ApiResponse>("/api/settings", settings);
|
||||
|
||||
|
||||
MessageBox.Show("设置已保存", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
Close();
|
||||
}
|
||||
@@ -566,21 +566,21 @@ namespace Ink_Canvas.Windows
|
||||
app_secret = APP_SECRET,
|
||||
user_token = userToken
|
||||
};
|
||||
|
||||
|
||||
var result = await _apiClient.PostAsync<AuthWithTokenResponse>("/api/whiteboard/framework/auth-with-token", authData, requireAuth: false);
|
||||
|
||||
|
||||
if (result != null && result.Success)
|
||||
{
|
||||
var whiteboards = result.Whiteboards ?? new List<WhiteboardInfo>();
|
||||
_currentWhiteboards = whiteboards;
|
||||
_currentUser = result.User;
|
||||
var whiteboardCount = whiteboards.Count;
|
||||
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
TxtConnectionStatus.Text = $"已连接 (找到 {whiteboardCount} 个白板)";
|
||||
TxtConnectionStatus.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 197, 94));
|
||||
|
||||
|
||||
// 加载班级列表
|
||||
LoadClasses(whiteboards, result.User);
|
||||
});
|
||||
@@ -596,11 +596,11 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
throw new Exception("Token格式可能不正确(长度过短,至少需要10个字符)");
|
||||
}
|
||||
|
||||
|
||||
LogHelper.WriteLogToFile($"Token验证失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -609,7 +609,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
TxtConnectionStatus.Text = "连接失败";
|
||||
TxtConnectionStatus.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(239, 68, 68));
|
||||
|
||||
|
||||
// 清空班级列表
|
||||
CmbClassSelection.Items.Clear();
|
||||
CmbClassSelection.Items.Add("(无可用班级)");
|
||||
@@ -620,9 +620,9 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region API响应模型
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// auth-with-token接口响应模型
|
||||
/// </summary>
|
||||
@@ -630,17 +630,17 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
[Newtonsoft.Json.JsonProperty("success")]
|
||||
public bool Success { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("whiteboards")]
|
||||
public List<WhiteboardInfo> Whiteboards { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("count")]
|
||||
public int Count { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("user")]
|
||||
public UserInfo User { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 白板信息模型
|
||||
/// </summary>
|
||||
@@ -648,32 +648,32 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
[Newtonsoft.Json.JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("board_id")]
|
||||
public string BoardId { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("secret_key")]
|
||||
public string SecretKey { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("class_name")]
|
||||
public string ClassName { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("class_id")]
|
||||
public int ClassId { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("is_online")]
|
||||
public bool IsOnline { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("last_heartbeat")]
|
||||
public string LastHeartbeat { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("created_at")]
|
||||
public string CreatedAt { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户信息模型
|
||||
/// </summary>
|
||||
@@ -681,14 +681,14 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
[Newtonsoft.Json.JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
|
||||
[Newtonsoft.Json.JsonProperty("email")]
|
||||
public string Email { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 班级选择项
|
||||
/// </summary>
|
||||
@@ -697,13 +697,13 @@ namespace Ink_Canvas.Windows
|
||||
public string DisplayText { get; set; }
|
||||
public string ClassName { get; set; }
|
||||
public string TeacherName { get; set; }
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return DisplayText;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using System.Timers;
|
||||
|
||||
namespace Ink_Canvas.Windows
|
||||
{
|
||||
@@ -23,23 +23,23 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
InitializeComponent();
|
||||
parentControl = parent;
|
||||
|
||||
|
||||
this.Left = 0;
|
||||
this.Top = 0;
|
||||
this.Width = SystemParameters.PrimaryScreenWidth;
|
||||
this.Height = SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
updateTimer = new System.Timers.Timer(100);
|
||||
|
||||
updateTimer = new System.Timers.Timer(100);
|
||||
updateTimer.Elapsed += UpdateTimer_Elapsed;
|
||||
updateTimer.Start();
|
||||
|
||||
|
||||
parentControl.TimerCompleted += ParentWindow_TimerCompleted;
|
||||
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow != null)
|
||||
{
|
||||
mainWindow.PauseTopmostMaintenance();
|
||||
|
||||
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
if (timerContainer != null)
|
||||
{
|
||||
@@ -47,11 +47,11 @@ namespace Ink_Canvas.Windows
|
||||
timerContainer.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 确保窗口置顶
|
||||
Loaded += FullscreenTimerWindow_Loaded;
|
||||
}
|
||||
|
||||
|
||||
private void FullscreenTimerWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 使用延迟确保窗口完全加载后再应用置顶
|
||||
@@ -60,7 +60,7 @@ namespace Ink_Canvas.Windows
|
||||
ApplyTopmost();
|
||||
}), System.Windows.Threading.DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
|
||||
#region Win32 API 声明和置顶管理
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||
@@ -118,29 +118,29 @@ namespace Ink_Canvas.Windows
|
||||
this.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UpdateTimeDisplay();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool ShouldCloseWindow()
|
||||
{
|
||||
if (parentControl == null) return true;
|
||||
|
||||
|
||||
if (MainWindow.Settings.RandSettings?.EnableOvertimeCountUp == true)
|
||||
{
|
||||
if (parentControl.IsTimerRunning)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var remainingTime = parentControl.GetRemainingTime();
|
||||
if (remainingTime.HasValue && remainingTime.Value.TotalSeconds < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -198,17 +198,17 @@ namespace Ink_Canvas.Windows
|
||||
|
||||
SetDigitDisplay("FullHour1Display", Math.Abs(hours / 10) % 10, shouldShowRed);
|
||||
SetDigitDisplay("FullHour2Display", (hours % 10 + 10) % 10, shouldShowRed);
|
||||
|
||||
|
||||
SetDigitDisplay("FullMinute1Display", minutes / 10, shouldShowRed);
|
||||
SetDigitDisplay("FullMinute2Display", minutes % 10, shouldShowRed);
|
||||
|
||||
|
||||
SetDigitDisplay("FullSecond1Display", seconds / 10, shouldShowRed);
|
||||
SetDigitDisplay("FullSecond2Display", seconds % 10, shouldShowRed);
|
||||
|
||||
|
||||
SetColonDisplay(shouldShowRed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ParentWindow_TimerCompleted(object sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
@@ -228,7 +228,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
path.Data = geometry;
|
||||
}
|
||||
|
||||
|
||||
// 设置颜色
|
||||
if (isRed)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var colon1 = this.FindName("FullColon1Display") as TextBlock;
|
||||
var colon2 = this.FindName("FullColon2Display") as TextBlock;
|
||||
|
||||
|
||||
if (colon1 != null)
|
||||
{
|
||||
if (isRed)
|
||||
@@ -261,7 +261,7 @@ namespace Ink_Canvas.Windows
|
||||
colon1.Foreground = Brushes.White;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (colon2 != null)
|
||||
{
|
||||
if (isRed)
|
||||
@@ -301,12 +301,12 @@ namespace Ink_Canvas.Windows
|
||||
if (mainWindow != null)
|
||||
{
|
||||
mainWindow.ResumeTopmostMaintenance();
|
||||
|
||||
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
if (timerContainer != null && previousTimerContainerVisibility == Visibility.Visible)
|
||||
{
|
||||
timerContainer.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
// 重置5秒最小化计时
|
||||
if (parentControl != null)
|
||||
{
|
||||
@@ -314,12 +314,12 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (parentControl != null)
|
||||
{
|
||||
parentControl.TimerCompleted -= ParentWindow_TimerCompleted;
|
||||
}
|
||||
|
||||
|
||||
// 清理资源
|
||||
if (updateTimer != null)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
@@ -5,8 +7,6 @@ using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Win32;
|
||||
using iNKORE.UI.WPF.Modern;
|
||||
|
||||
namespace Ink_Canvas.Windows
|
||||
{
|
||||
@@ -21,36 +21,36 @@ namespace Ink_Canvas.Windows
|
||||
public MinimizedTimerControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
updateTimer = new System.Timers.Timer(100);
|
||||
updateTimer.Elapsed += UpdateTimer_Elapsed;
|
||||
updateTimer.Start();
|
||||
|
||||
|
||||
ApplyTheme();
|
||||
|
||||
|
||||
// 监听主题变化事件
|
||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
|
||||
|
||||
Unloaded += MinimizedTimerControl_Unloaded;
|
||||
}
|
||||
|
||||
|
||||
private void MinimizedTimerControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 取消订阅主题变化事件
|
||||
SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged;
|
||||
|
||||
|
||||
if (parentControl != null)
|
||||
{
|
||||
parentControl.TimerCompleted -= ParentControl_TimerCompleted;
|
||||
}
|
||||
|
||||
|
||||
if (updateTimer != null)
|
||||
{
|
||||
updateTimer.Stop();
|
||||
updateTimer.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||
{
|
||||
// 当主题变化时,重新应用主题
|
||||
@@ -59,7 +59,7 @@ namespace Ink_Canvas.Windows
|
||||
RefreshTheme();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 刷新主题
|
||||
/// </summary>
|
||||
@@ -69,7 +69,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 重新应用主题
|
||||
ApplyTheme();
|
||||
|
||||
|
||||
// 强制刷新UI
|
||||
InvalidateVisual();
|
||||
}
|
||||
@@ -85,9 +85,9 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
parentControl.TimerCompleted -= ParentControl_TimerCompleted;
|
||||
}
|
||||
|
||||
|
||||
parentControl = parent;
|
||||
|
||||
|
||||
if (parentControl != null)
|
||||
{
|
||||
parentControl.TimerCompleted += ParentControl_TimerCompleted;
|
||||
@@ -105,7 +105,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (ShouldHide())
|
||||
{
|
||||
this.Visibility = Visibility.Collapsed;
|
||||
@@ -116,34 +116,34 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
UpdateTimeDisplay();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool ShouldHide()
|
||||
{
|
||||
if (parentControl == null) return true;
|
||||
|
||||
|
||||
if (parentControl.IsFullscreenWindowOpen)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (MainWindow.Settings.RandSettings?.EnableOvertimeCountUp == true)
|
||||
{
|
||||
if (parentControl.IsTimerRunning)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var remainingTime = parentControl.GetRemainingTime();
|
||||
if (remainingTime.HasValue && remainingTime.Value.TotalSeconds < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -201,17 +201,17 @@ namespace Ink_Canvas.Windows
|
||||
|
||||
SetDigitDisplay("MinHour1Display", Math.Abs(hours / 10) % 10, shouldShowRed);
|
||||
SetDigitDisplay("MinHour2Display", (hours % 10 + 10) % 10, shouldShowRed);
|
||||
|
||||
|
||||
SetDigitDisplay("MinMinute1Display", minutes / 10, shouldShowRed);
|
||||
SetDigitDisplay("MinMinute2Display", minutes % 10, shouldShowRed);
|
||||
|
||||
|
||||
SetDigitDisplay("MinSecond1Display", seconds / 10, shouldShowRed);
|
||||
SetDigitDisplay("MinSecond2Display", seconds % 10, shouldShowRed);
|
||||
|
||||
|
||||
SetColonDisplay(shouldShowRed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ParentControl_TimerCompleted(object sender, EventArgs e)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
@@ -231,7 +231,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
path.Data = geometry;
|
||||
}
|
||||
|
||||
|
||||
if (isRed)
|
||||
{
|
||||
path.Fill = Brushes.Red;
|
||||
@@ -256,7 +256,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var colon1 = this.FindName("MinColon1Display") as TextBlock;
|
||||
var colon2 = this.FindName("MinColon2Display") as TextBlock;
|
||||
|
||||
|
||||
if (colon1 != null)
|
||||
{
|
||||
if (isRed)
|
||||
@@ -277,7 +277,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (colon2 != null)
|
||||
{
|
||||
if (isRed)
|
||||
@@ -322,7 +322,7 @@ namespace Ink_Canvas.Windows
|
||||
System.Diagnostics.Debug.WriteLine($"应用主题时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ApplyTheme(Settings settings)
|
||||
{
|
||||
try
|
||||
@@ -349,7 +349,7 @@ namespace Ink_Canvas.Windows
|
||||
SetDarkThemeBorder();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 刷新数字和冒号显示的颜色
|
||||
if (parentControl != null)
|
||||
{
|
||||
@@ -361,7 +361,7 @@ namespace Ink_Canvas.Windows
|
||||
System.Diagnostics.Debug.WriteLine($"应用最小化计时器窗口主题出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool IsSystemThemeLight()
|
||||
{
|
||||
var light = false;
|
||||
@@ -432,13 +432,13 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
|
||||
private bool isDragging = false;
|
||||
private bool isDragStarted = false;
|
||||
private Point dragStartPoint;
|
||||
private Point containerStartPosition;
|
||||
private const double DragThreshold = 5.0; // 拖动阈值,像素
|
||||
|
||||
|
||||
private void MainBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ClickCount == 2)
|
||||
@@ -447,13 +447,13 @@ namespace Ink_Canvas.Windows
|
||||
if (parentControl != null)
|
||||
{
|
||||
parentControl.UpdateActivityTime();
|
||||
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow != null)
|
||||
{
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
var minimizedContainer = mainWindow.FindName("MinimizedTimerContainer") as FrameworkElement;
|
||||
|
||||
|
||||
if (timerContainer != null && minimizedContainer != null)
|
||||
{
|
||||
timerContainer.Visibility = Visibility.Visible;
|
||||
@@ -474,18 +474,18 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var point = e.GetPosition(minimizedContainer);
|
||||
var mainWindowPoint = minimizedContainer.TransformToAncestor(mainWindow).Transform(point);
|
||||
|
||||
|
||||
// 初始化拖动状态,但不立即开始拖动
|
||||
isDragging = false;
|
||||
isDragStarted = false;
|
||||
dragStartPoint = mainWindowPoint;
|
||||
|
||||
|
||||
var margin = minimizedContainer.Margin;
|
||||
containerStartPosition = new Point(margin.Left, margin.Top);
|
||||
|
||||
|
||||
if (double.IsNaN(containerStartPosition.X) || containerStartPosition.X < 0) containerStartPosition.X = 0;
|
||||
if (double.IsNaN(containerStartPosition.Y) || containerStartPosition.Y < 0) containerStartPosition.Y = 0;
|
||||
|
||||
|
||||
// 捕获鼠标并订阅事件,等待判断是拖动还是点击
|
||||
minimizedContainer.CaptureMouse();
|
||||
minimizedContainer.MouseMove += MinimizedContainer_MouseMove;
|
||||
@@ -495,42 +495,42 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void MinimizedContainer_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow == null) return;
|
||||
|
||||
|
||||
var minimizedContainer = mainWindow.FindName("MinimizedTimerContainer") as FrameworkElement;
|
||||
if (minimizedContainer == null) return;
|
||||
|
||||
|
||||
var currentPoint = e.GetPosition(mainWindow);
|
||||
var deltaX = currentPoint.X - dragStartPoint.X;
|
||||
var deltaY = currentPoint.Y - dragStartPoint.Y;
|
||||
var distance = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
|
||||
|
||||
|
||||
// 如果移动距离超过阈值,开始拖动
|
||||
if (!isDragStarted && distance > DragThreshold)
|
||||
{
|
||||
isDragStarted = true;
|
||||
isDragging = true;
|
||||
}
|
||||
|
||||
|
||||
// 如果已经开始拖动,更新位置
|
||||
if (isDragging)
|
||||
{
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
|
||||
|
||||
var newX = containerStartPosition.X + deltaX;
|
||||
var newY = containerStartPosition.Y + deltaY;
|
||||
|
||||
|
||||
if (newX < 0) newX = 0;
|
||||
if (newY < 0) newY = 0;
|
||||
|
||||
|
||||
minimizedContainer.Margin = new Thickness(newX, newY, 0, 0);
|
||||
minimizedContainer.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
minimizedContainer.VerticalAlignment = VerticalAlignment.Top;
|
||||
|
||||
|
||||
if (timerContainer != null)
|
||||
{
|
||||
timerContainer.Margin = new Thickness(newX, newY, 0, 0);
|
||||
@@ -539,12 +539,12 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void MinimizedContainer_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow == null) return;
|
||||
|
||||
|
||||
var minimizedContainer = mainWindow.FindName("MinimizedTimerContainer") as FrameworkElement;
|
||||
if (minimizedContainer != null)
|
||||
{
|
||||
@@ -552,14 +552,14 @@ namespace Ink_Canvas.Windows
|
||||
minimizedContainer.MouseMove -= MinimizedContainer_MouseMove;
|
||||
minimizedContainer.MouseLeftButtonUp -= MinimizedContainer_MouseLeftButtonUp;
|
||||
}
|
||||
|
||||
|
||||
// 如果没有开始拖动(移动距离小于阈值),则视为单击,恢复主窗口
|
||||
if (!isDragStarted)
|
||||
{
|
||||
if (parentControl != null)
|
||||
{
|
||||
parentControl.UpdateActivityTime();
|
||||
|
||||
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
if (timerContainer != null && minimizedContainer != null)
|
||||
{
|
||||
@@ -568,7 +568,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
isDragging = false;
|
||||
isDragStarted = false;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Ink_Canvas
|
||||
try
|
||||
{
|
||||
var resources = this.Resources;
|
||||
|
||||
|
||||
if (theme == "Light")
|
||||
{
|
||||
// 应用浅色主题资源
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -10,8 +12,6 @@ using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Newtonsoft.Json;
|
||||
using System.Runtime.InteropServices;
|
||||
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
|
||||
|
||||
namespace Ink_Canvas
|
||||
@@ -48,7 +48,7 @@ namespace Ink_Canvas
|
||||
|
||||
InitializeUI();
|
||||
ApplyTheme(MainWindow.Settings);
|
||||
|
||||
|
||||
// 初始化点名相关变量
|
||||
InitializeRollCallData();
|
||||
}
|
||||
@@ -63,10 +63,10 @@ namespace Ink_Canvas
|
||||
|
||||
InitializeUI();
|
||||
ApplyTheme(MainWindow.Settings);
|
||||
|
||||
|
||||
// 初始化点名相关变量
|
||||
InitializeRollCallData();
|
||||
|
||||
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
if (ControlOptionsGrid != null)
|
||||
@@ -85,7 +85,7 @@ namespace Ink_Canvas
|
||||
ResetBtn.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 单次抽模式:自动开始抽选
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
@@ -108,19 +108,19 @@ namespace Ink_Canvas
|
||||
|
||||
// 保存设置
|
||||
this.settings = settings;
|
||||
|
||||
|
||||
// 设置单次抽模式
|
||||
isSingleDrawMode = isSingleDraw;
|
||||
|
||||
InitializeUI();
|
||||
ApplyTheme(settings);
|
||||
|
||||
|
||||
// 初始化设置
|
||||
InitializeSettings();
|
||||
|
||||
|
||||
// 初始化点名相关变量
|
||||
InitializeRollCallData();
|
||||
|
||||
|
||||
// 单次抽模式:禁用控制面板,阻止用户点击按钮
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ namespace Ink_Canvas
|
||||
ResetBtn.IsEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 单次抽模式:自动开始抽选
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
@@ -165,43 +165,43 @@ namespace Ink_Canvas
|
||||
private Timer rollCallTimer;
|
||||
private Random random = new Random();
|
||||
private DateTime lastActivityTime = DateTime.Now;
|
||||
|
||||
|
||||
// 机器学习相关
|
||||
private static RollCallHistoryData historyData = null;
|
||||
private static readonly object historyLock = new object();
|
||||
private static int maxRecentHistory = 20;
|
||||
private static double avoidanceWeight = 0.8;
|
||||
private const double FREQUENCY_WEIGHT = 0.2;
|
||||
|
||||
private static double avoidanceWeight = 0.8;
|
||||
private const double FREQUENCY_WEIGHT = 0.2;
|
||||
|
||||
// 概率相关
|
||||
private const double DEFAULT_PROBABILITY = 1.0;
|
||||
private const double BASE_PROBABILITY_DECAY_FACTOR = 0.5;
|
||||
private const double MIN_PROBABILITY = 0.01;
|
||||
private const double PROBABILITY_RECOVERY_RATE = 0.2;
|
||||
private const double FREQUENCY_BOOST_FACTOR = 2.0;
|
||||
|
||||
private const double DEFAULT_PROBABILITY = 1.0;
|
||||
private const double BASE_PROBABILITY_DECAY_FACTOR = 0.5;
|
||||
private const double MIN_PROBABILITY = 0.01;
|
||||
private const double PROBABILITY_RECOVERY_RATE = 0.2;
|
||||
private const double FREQUENCY_BOOST_FACTOR = 2.0;
|
||||
|
||||
// 单次抽相关
|
||||
private bool isSingleDrawMode = false;
|
||||
private Random singleDrawRandom = new Random();
|
||||
|
||||
|
||||
// 设置相关
|
||||
private Settings settings;
|
||||
private int autoCloseWaitTime = 2500; // 自动关闭等待时间(毫秒)
|
||||
|
||||
|
||||
// 点名模式
|
||||
private string selectedRollCallMode = "Random"; // 默认随机点名
|
||||
|
||||
|
||||
// 外部点名相关
|
||||
private string selectedExternalCaller = "ClassIsland";
|
||||
|
||||
|
||||
// 开始点名按钮的数据
|
||||
private string originalStartBtnIconData = "M5 7C5 8.06087 5.42143 9.07828 6.17157 9.82843C6.92172 10.5786 7.93913 11 9 11C10.0609 11 11.0783 10.5786 11.8284 9.82843C12.5786 9.07828 13 8.06087 13 7C13 5.93913 12.5786 4.92172 11.8284 4.17157C11.0783 3.42143 10.0609 3 9 3C7.93913 3 6.92172 3.42143 6.17157 4.17157C5.42143 4.92172 5 5.93913 5 7Z M3 21V19C3 17.9391 3.42143 16.9217 4.17157 16.1716C4.92172 15.4214 5.93913 15 7 15H11C12.0609 15 13.0783 15.4214 13.8284 16.1716C14.5786 16.9217 15 17.9391 15 19V21 M16 3.13C16.8604 3.35031 17.623 3.85071 18.1676 4.55232C18.7122 5.25392 19.0078 6.11683 19.0078 7.005C19.0078 7.89318 18.7122 8.75608 18.1676 9.45769C17.623 10.1593 16.8604 10.6597 16 10.88 M21 21V19C20.9949 18.1172 20.6979 17.2608 20.1553 16.5644C19.6126 15.868 18.8548 15.3707 18 15.15";
|
||||
private string originalStartBtnText = "开始点名";
|
||||
|
||||
|
||||
// 外部点名按钮的数据
|
||||
private string externalCallerBtnIconData = "M9 15L15 9 M11 6L11.463 5.464C12.4008 4.52633 13.6727 3.9996 14.9989 3.99969C16.325 3.99979 17.5968 4.52669 18.5345 5.4645C19.4722 6.40231 19.9989 7.67419 19.9988 9.00035C19.9987 10.3265 19.4718 11.5983 18.534 12.536L18 13 M13.0001 18L12.6031 18.534C11.6544 19.4722 10.3739 19.9984 9.03964 19.9984C7.70535 19.9984 6.42489 19.4722 5.47614 18.534C5.0085 18.0716 4.63724 17.521 4.38385 16.9141C4.13047 16.3073 4 15.6561 4 14.9985C4 14.3408 4.13047 13.6897 4.38385 13.0829C4.63724 12.476 5.0085 11.9254 5.47614 11.463L6.00014 11";
|
||||
private string externalCallerBtnText = "外部点名";
|
||||
|
||||
|
||||
// JSON文件路径
|
||||
private static readonly string ConfigsFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Configs");
|
||||
private static readonly string RollCallHistoryJsonPath = System.IO.Path.Combine(ConfigsFolder, "RollCallHistory.json");
|
||||
@@ -211,7 +211,7 @@ namespace Ink_Canvas
|
||||
private void InitializeUI()
|
||||
{
|
||||
UpdateCountDisplay();
|
||||
LoadNamesFromFile();
|
||||
LoadNamesFromFile();
|
||||
UpdateListCountDisplay();
|
||||
LoadRollCallHistory();
|
||||
LoadSettings();
|
||||
@@ -308,7 +308,7 @@ namespace Ink_Canvas
|
||||
private void InitializeRollCallData()
|
||||
{
|
||||
// 初始化点名定时器
|
||||
rollCallTimer = new Timer(100);
|
||||
rollCallTimer = new Timer(100);
|
||||
rollCallTimer.Elapsed += RollCallTimer_Elapsed;
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 更新窗口资源
|
||||
var resources = this.Resources;
|
||||
|
||||
|
||||
if (theme == "Light")
|
||||
{
|
||||
// 应用浅色主题资源
|
||||
@@ -459,10 +459,10 @@ namespace Ink_Canvas
|
||||
private List<string> SelectNamesSequentially(List<string> availableNames, int count)
|
||||
{
|
||||
if (availableNames.Count == 0) return new List<string>();
|
||||
|
||||
|
||||
var selectedNames = new List<string>();
|
||||
int startIndex = 0;
|
||||
|
||||
|
||||
// 从历史记录中找到上次选择的位置
|
||||
if (historyData.History != null && historyData.History.Count > 0)
|
||||
{
|
||||
@@ -476,13 +476,13 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < count && i < availableNames.Count; i++)
|
||||
{
|
||||
int index = (startIndex + i) % availableNames.Count;
|
||||
selectedNames.Add(availableNames[index]);
|
||||
}
|
||||
|
||||
|
||||
return selectedNames;
|
||||
}
|
||||
|
||||
@@ -492,15 +492,15 @@ namespace Ink_Canvas
|
||||
private List<string> SelectNamesInGroups(List<string> availableNames, int count)
|
||||
{
|
||||
if (availableNames.Count == 0) return new List<string>();
|
||||
|
||||
|
||||
var selectedNames = new List<string>();
|
||||
int groupSize = Math.Max(1, availableNames.Count / count);
|
||||
|
||||
|
||||
for (int i = 0; i < count && i * groupSize < availableNames.Count; i++)
|
||||
{
|
||||
int startIndex = i * groupSize;
|
||||
int endIndex = Math.Min(startIndex + groupSize, availableNames.Count);
|
||||
|
||||
|
||||
// 从当前组中随机选择一个人
|
||||
var group = availableNames.GetRange(startIndex, endIndex - startIndex);
|
||||
if (group.Count > 0)
|
||||
@@ -509,7 +509,7 @@ namespace Ink_Canvas
|
||||
selectedNames.Add(group[randomIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return selectedNames;
|
||||
}
|
||||
#endregion
|
||||
@@ -646,12 +646,12 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 获取基础概率
|
||||
double baseProbability = GetNameProbability(name);
|
||||
|
||||
|
||||
// 根据最近历史记录调整概率
|
||||
double adjustedProbability = AdjustProbabilityByRecentHistory(name, baseProbability);
|
||||
|
||||
|
||||
double finalProbability = AdjustProbabilityByFrequency(name, adjustedProbability);
|
||||
|
||||
|
||||
nameProbabilities[name] = finalProbability;
|
||||
}
|
||||
|
||||
@@ -692,13 +692,13 @@ namespace Ink_Canvas
|
||||
int recentCount = recentHistory.Count(n => n == name);
|
||||
|
||||
if (recentCount == 0)
|
||||
return baseProbability;
|
||||
return baseProbability;
|
||||
|
||||
double recentFrequency = (double)recentCount / Math.Min(recentHistory.Count, maxRecentHistory);
|
||||
|
||||
|
||||
double reductionFactor = 1.0 - (recentFrequency * avoidanceWeight);
|
||||
reductionFactor = Math.Max(reductionFactor, MIN_PROBABILITY / DEFAULT_PROBABILITY); // 确保不会降得太低
|
||||
|
||||
|
||||
return baseProbability * reductionFactor;
|
||||
}
|
||||
|
||||
@@ -732,20 +732,20 @@ namespace Ink_Canvas
|
||||
double frequencyRatio = nameFrequency / averageFrequency;
|
||||
|
||||
double frequencyGap = 1.0 - frequencyRatio;
|
||||
double boostFactor = FREQUENCY_BOOST_FACTOR * frequencyGap * frequencyGap;
|
||||
|
||||
double boostFactor = FREQUENCY_BOOST_FACTOR * frequencyGap * frequencyGap;
|
||||
|
||||
// 增加概率
|
||||
double boostedProbability = baseProbability * (1.0 + boostFactor);
|
||||
|
||||
|
||||
return Math.Min(boostedProbability, DEFAULT_PROBABILITY * 10.0);
|
||||
}
|
||||
else if (nameFrequency > averageFrequency)
|
||||
{
|
||||
double frequencyRatio = nameFrequency / averageFrequency;
|
||||
|
||||
double reductionFactor = 1.0 - (frequencyRatio - 1.0) * 0.3;
|
||||
|
||||
double reductionFactor = 1.0 - (frequencyRatio - 1.0) * 0.3;
|
||||
reductionFactor = Math.Max(reductionFactor, MIN_PROBABILITY / DEFAULT_PROBABILITY);
|
||||
|
||||
|
||||
return baseProbability * reductionFactor;
|
||||
}
|
||||
|
||||
@@ -782,8 +782,8 @@ namespace Ink_Canvas
|
||||
int nameCount = kvp.Value;
|
||||
|
||||
// 获取当前保存的概率(如果不存在则使用默认值)
|
||||
double currentProbability = historyData.NameProbabilities.ContainsKey(name)
|
||||
? historyData.NameProbabilities[name]
|
||||
double currentProbability = historyData.NameProbabilities.ContainsKey(name)
|
||||
? historyData.NameProbabilities[name]
|
||||
: DEFAULT_PROBABILITY;
|
||||
|
||||
// 计算该名字的选中频率
|
||||
@@ -795,24 +795,24 @@ namespace Ink_Canvas
|
||||
// 计算频率差异比例
|
||||
double frequencyRatio = nameFrequency / averageFrequency;
|
||||
double frequencyGap = 1.0 - frequencyRatio;
|
||||
double boostFactor = FREQUENCY_BOOST_FACTOR * frequencyGap * frequencyGap;
|
||||
|
||||
double boostFactor = FREQUENCY_BOOST_FACTOR * frequencyGap * frequencyGap;
|
||||
|
||||
// 增加概率
|
||||
double boostedProbability = currentProbability * (1.0 + boostFactor);
|
||||
|
||||
|
||||
// 限制最大概率,避免过高
|
||||
boostedProbability = Math.Min(boostedProbability, DEFAULT_PROBABILITY * 10.0);
|
||||
|
||||
|
||||
// 保存更新后的概率
|
||||
historyData.NameProbabilities[name] = boostedProbability;
|
||||
}
|
||||
else if (nameFrequency > averageFrequency)
|
||||
{
|
||||
double frequencyRatio = nameFrequency / averageFrequency;
|
||||
|
||||
double reductionFactor = 1.0 - (frequencyRatio - 1.0) * 0.3;
|
||||
|
||||
double reductionFactor = 1.0 - (frequencyRatio - 1.0) * 0.3;
|
||||
reductionFactor = Math.Max(reductionFactor, MIN_PROBABILITY / DEFAULT_PROBABILITY);
|
||||
|
||||
|
||||
double reducedProbability = currentProbability * reductionFactor;
|
||||
historyData.NameProbabilities[name] = reducedProbability;
|
||||
}
|
||||
@@ -963,19 +963,19 @@ namespace Ink_Canvas
|
||||
{
|
||||
double nameFrequency = (double)historyData.NameFrequency[name] / totalSelections;
|
||||
double averageFrequency = 1.0 / uniqueNamesCount;
|
||||
|
||||
|
||||
if (nameFrequency > averageFrequency)
|
||||
{
|
||||
double frequencyRatio = nameFrequency / averageFrequency;
|
||||
frequencyBasedDecay = 1.0 - (frequencyRatio - 1.0) * 0.2;
|
||||
frequencyBasedDecay = 1.0 - (frequencyRatio - 1.0) * 0.2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double decayFactor = BASE_PROBABILITY_DECAY_FACTOR * (1.0 + avoidanceWeight) * frequencyBasedDecay;
|
||||
decayFactor = Math.Min(decayFactor, 0.85);
|
||||
|
||||
decayFactor = Math.Min(decayFactor, 0.85);
|
||||
|
||||
double newProbability = currentProbability * decayFactor;
|
||||
newProbability = Math.Max(newProbability, MIN_PROBABILITY); // 确保不低于最小概率
|
||||
historyData.NameProbabilities[name] = newProbability;
|
||||
@@ -1120,7 +1120,7 @@ namespace Ink_Canvas
|
||||
MainResultDisplay.Text = "";
|
||||
MainResultDisplay.Visibility = Visibility.Collapsed;
|
||||
MultiResultScrollViewer.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
// 显示所有结果(最多20个)
|
||||
Result1Display.Text = results.Count > 0 ? results[0] : "";
|
||||
Result2Display.Text = results.Count > 1 ? results[1] : "";
|
||||
@@ -1150,10 +1150,10 @@ namespace Ink_Canvas
|
||||
private void CountPlus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isRollCalling) return;
|
||||
|
||||
|
||||
// 获取老点名UI的设置
|
||||
int maxPeopleLimit = settings?.RandSettings?.RandWindowOnceMaxStudents ?? 10;
|
||||
|
||||
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
// 单次抽模式:最多选择60个数字,但受设置限制
|
||||
@@ -1176,7 +1176,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
currentCount = Math.Min(currentCount + 1, maxCount);
|
||||
}
|
||||
|
||||
|
||||
UpdateCountDisplay();
|
||||
}
|
||||
|
||||
@@ -1194,7 +1194,7 @@ namespace Ink_Canvas
|
||||
// 打开名单导入窗口,与老点名UI保持一致
|
||||
var namesInputWindow = new NamesInputWindow();
|
||||
namesInputWindow.ShowDialog();
|
||||
|
||||
|
||||
// 重新加载名单
|
||||
LoadNamesFromFile();
|
||||
UpdateListCountDisplay();
|
||||
@@ -1260,7 +1260,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
// 存储选择的模式
|
||||
selectedRollCallMode = mode;
|
||||
|
||||
|
||||
// 重置所有按钮状态
|
||||
RandomModeText.FontWeight = FontWeights.Normal;
|
||||
RandomModeText.Opacity = 0.6;
|
||||
@@ -1271,7 +1271,7 @@ namespace Ink_Canvas
|
||||
GroupModeText.FontWeight = FontWeights.Normal;
|
||||
GroupModeText.Opacity = 0.6;
|
||||
GroupModeText.Foreground = new SolidColorBrush(Color.FromRgb(102, 102, 102));
|
||||
|
||||
|
||||
// 重置外部点名模式按钮状态
|
||||
ExternalCallerModeText.FontWeight = FontWeights.Normal;
|
||||
ExternalCallerModeText.Opacity = 0.6;
|
||||
@@ -1288,13 +1288,13 @@ namespace Ink_Canvas
|
||||
RandomModeText.Foreground = new SolidColorBrush(Colors.White);
|
||||
SegmentedIndicator.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
SegmentedIndicator.CornerRadius = new CornerRadius(7.5, 0, 0, 7.5);
|
||||
|
||||
|
||||
// 添加动画效果
|
||||
var randomAnimation = new System.Windows.Media.Animation.ThicknessAnimation(
|
||||
new Thickness(0, 0, 0, 0),
|
||||
TimeSpan.FromMilliseconds(200));
|
||||
SegmentedIndicator.BeginAnimation(Border.MarginProperty, randomAnimation);
|
||||
|
||||
|
||||
// 恢复开始点名按钮的原始图标和文字
|
||||
RestoreStartRollCallButton();
|
||||
UpdateStatusDisplay("已选择点名模式: 随机点名");
|
||||
@@ -1305,13 +1305,13 @@ namespace Ink_Canvas
|
||||
SequentialModeText.Foreground = new SolidColorBrush(Colors.White);
|
||||
SegmentedIndicator.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
SegmentedIndicator.CornerRadius = new CornerRadius(0, 0, 0, 0);
|
||||
|
||||
|
||||
// 添加动画效果 - 移动到中间位置
|
||||
var sequentialAnimation = new System.Windows.Media.Animation.ThicknessAnimation(
|
||||
new Thickness(100, 0, 0, 0),
|
||||
TimeSpan.FromMilliseconds(200));
|
||||
SegmentedIndicator.BeginAnimation(Border.MarginProperty, sequentialAnimation);
|
||||
|
||||
|
||||
// 恢复开始点名按钮的原始图标和文字
|
||||
RestoreStartRollCallButton();
|
||||
UpdateStatusDisplay("已选择点名模式: 顺序点名");
|
||||
@@ -1322,13 +1322,13 @@ namespace Ink_Canvas
|
||||
GroupModeText.Foreground = new SolidColorBrush(Colors.White);
|
||||
SegmentedIndicator.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
SegmentedIndicator.CornerRadius = new CornerRadius(0, 7.5, 7.5, 0);
|
||||
|
||||
|
||||
// 添加动画效果 - 移动到右侧位置
|
||||
var groupAnimation = new System.Windows.Media.Animation.ThicknessAnimation(
|
||||
new Thickness(200, 0, 0, 0),
|
||||
TimeSpan.FromMilliseconds(200));
|
||||
SegmentedIndicator.BeginAnimation(Border.MarginProperty, groupAnimation);
|
||||
|
||||
|
||||
// 恢复开始点名按钮的原始图标和文字
|
||||
RestoreStartRollCallButton();
|
||||
UpdateStatusDisplay("已选择点名模式: 分组点名");
|
||||
@@ -1339,10 +1339,10 @@ namespace Ink_Canvas
|
||||
ExternalCallerModeText.Opacity = 1.0;
|
||||
ExternalCallerModeText.Foreground = new SolidColorBrush(Colors.White);
|
||||
ExternalCallerModeIndicator.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
// 隐藏其他模式的指示器
|
||||
SegmentedIndicator.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
// 切换到外部点名按钮的图标和文字
|
||||
UpdateStartRollCallButtonForExternal();
|
||||
UpdateStatusDisplay($"已选择点名模式: 外部点名 ({selectedExternalCaller})");
|
||||
@@ -1354,7 +1354,7 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"设置点名模式选择时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新开始点名按钮为外部点名样式
|
||||
/// </summary>
|
||||
@@ -1369,14 +1369,14 @@ namespace Ink_Canvas
|
||||
// 外部点名使用按钮前景色而不是主按钮前景色
|
||||
StartRollCallBtnIcon.Stroke = (Brush)FindResource("NewRollCallWindowButtonForeground");
|
||||
}
|
||||
|
||||
|
||||
// 更新文字
|
||||
if (StartRollCallBtnText != null)
|
||||
{
|
||||
StartRollCallBtnText.Text = externalCallerBtnText;
|
||||
StartRollCallBtnText.Foreground = (Brush)FindResource("NewRollCallWindowButtonForeground");
|
||||
}
|
||||
|
||||
|
||||
// 更新按钮背景色为普通按钮背景
|
||||
StartRollCallBtn.Background = (Brush)FindResource("NewRollCallWindowButtonBackground");
|
||||
}
|
||||
@@ -1385,7 +1385,7 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"更新开始点名按钮为外部点名样式时出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 恢复开始点名按钮的原始样式
|
||||
/// </summary>
|
||||
@@ -1399,14 +1399,14 @@ namespace Ink_Canvas
|
||||
StartRollCallBtnIcon.Data = Geometry.Parse(originalStartBtnIconData);
|
||||
StartRollCallBtnIcon.Stroke = (Brush)FindResource("NewRollCallWindowPrimaryButtonForeground");
|
||||
}
|
||||
|
||||
|
||||
// 恢复文字
|
||||
if (StartRollCallBtnText != null)
|
||||
{
|
||||
StartRollCallBtnText.Text = originalStartBtnText;
|
||||
StartRollCallBtnText.Foreground = (Brush)FindResource("NewRollCallWindowPrimaryButtonForeground");
|
||||
}
|
||||
|
||||
|
||||
// 恢复按钮背景色为主按钮背景
|
||||
StartRollCallBtn.Background = (Brush)FindResource("NewRollCallWindowPrimaryButtonBackground");
|
||||
}
|
||||
@@ -1443,7 +1443,7 @@ namespace Ink_Canvas
|
||||
if (ExternalCallerTypeComboBox.SelectedItem is ComboBoxItem selectedItem)
|
||||
{
|
||||
selectedExternalCaller = selectedItem.Content.ToString();
|
||||
|
||||
|
||||
if (selectedRollCallMode == "External")
|
||||
{
|
||||
UpdateStatusDisplay($"已选择外部点名: {selectedExternalCaller}");
|
||||
@@ -1456,7 +1456,7 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private static bool isExternalCallerFirstClick = true;
|
||||
private static bool isExternalCallerFirstClick = true;
|
||||
|
||||
private void ExternalCaller_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -1513,7 +1513,7 @@ namespace Ink_Canvas
|
||||
ExternalCaller_Click(sender, e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
// 单次抽模式:直接开始抽选
|
||||
@@ -1576,18 +1576,18 @@ namespace Ink_Canvas
|
||||
{
|
||||
const int animationTimes = 100; // 动画次数
|
||||
const int sleepTime = 5; // 每次动画间隔(毫秒)
|
||||
|
||||
|
||||
new System.Threading.Thread(() =>
|
||||
{
|
||||
List<string> usedNames = new List<string>();
|
||||
|
||||
|
||||
// 确保动画期间主显示区域可见
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainResultDisplay.Visibility = Visibility.Visible;
|
||||
MultiResultScrollViewer.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
|
||||
|
||||
for (int i = 0; i < animationTimes; i++)
|
||||
{
|
||||
// 随机选择一个名字进行动画显示
|
||||
@@ -1595,7 +1595,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
int randomIndex = new Random().Next(0, nameList.Count);
|
||||
string displayName = nameList[randomIndex];
|
||||
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 确保主显示区域在动画期间保持可见
|
||||
@@ -1603,16 +1603,16 @@ namespace Ink_Canvas
|
||||
MainResultDisplay.Text = displayName;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
System.Threading.Thread.Sleep(sleepTime);
|
||||
}
|
||||
|
||||
|
||||
// 动画结束,显示最终结果
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 根据选择的模式进行不同的点名逻辑
|
||||
var selectedNames = SelectNamesByMode(nameList, currentCount);
|
||||
|
||||
|
||||
// 更新历史记录
|
||||
UpdateRollCallHistory(selectedNames);
|
||||
|
||||
@@ -1646,40 +1646,40 @@ namespace Ink_Canvas
|
||||
{
|
||||
const int animationTimes = 100; // 动画次数
|
||||
const int sleepTime = 5; // 每次动画间隔(毫秒)
|
||||
|
||||
|
||||
new System.Threading.Thread(() =>
|
||||
{
|
||||
List<int> usedNumbers = new List<int>();
|
||||
|
||||
|
||||
// 确保动画期间主显示区域可见
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainResultDisplay.Visibility = Visibility.Visible;
|
||||
MultiResultScrollViewer.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
|
||||
|
||||
for (int i = 0; i < animationTimes; i++)
|
||||
{
|
||||
// 随机选择一个数字进行动画显示
|
||||
int randomNumber = new Random().Next(1, 61); // 1-60
|
||||
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 确保主显示区域在动画期间保持可见
|
||||
MainResultDisplay.Visibility = Visibility.Visible;
|
||||
MainResultDisplay.Text = randomNumber.ToString();
|
||||
});
|
||||
|
||||
|
||||
System.Threading.Thread.Sleep(sleepTime);
|
||||
}
|
||||
|
||||
|
||||
// 动画结束,显示最终结果
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 根据选择的模式进行不同的抽选逻辑
|
||||
var numberList = Enumerable.Range(1, 60).Select(n => n.ToString()).ToList();
|
||||
var selectedNumbers = SelectNamesByMode(numberList, currentCount);
|
||||
|
||||
|
||||
// 更新历史记录
|
||||
UpdateRollCallHistory(selectedNumbers);
|
||||
|
||||
@@ -1724,7 +1724,7 @@ namespace Ink_Canvas
|
||||
{
|
||||
const int animationTimes = 100; // 动画次数
|
||||
const int sleepTime = 5; // 每次动画间隔(毫秒),参考老点名窗口
|
||||
|
||||
|
||||
new System.Threading.Thread(() =>
|
||||
{
|
||||
if (nameList.Count > 0)
|
||||
@@ -1746,7 +1746,7 @@ namespace Ink_Canvas
|
||||
private void StartSingleDrawNameAnimation(int animationTimes, int sleepTime)
|
||||
{
|
||||
List<string> usedNames = new List<string>();
|
||||
|
||||
|
||||
for (int i = 0; i < animationTimes; i++)
|
||||
{
|
||||
// 随机选择一个名字进行动画显示,避免立即重复
|
||||
@@ -1755,23 +1755,23 @@ namespace Ink_Canvas
|
||||
{
|
||||
randomName = nameList[singleDrawRandom.Next(0, nameList.Count)];
|
||||
} while (usedNames.Count > 0 && usedNames[usedNames.Count - 1] == randomName);
|
||||
|
||||
|
||||
usedNames.Add(randomName);
|
||||
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainResultDisplay.Text = randomName;
|
||||
});
|
||||
|
||||
|
||||
System.Threading.Thread.Sleep(sleepTime);
|
||||
}
|
||||
|
||||
|
||||
// 动画结束,显示最终结果
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 根据选择的模式进行不同的抽选逻辑
|
||||
var selectedNames = SelectNamesByMode(nameList, currentCount);
|
||||
|
||||
|
||||
// 更新历史记录
|
||||
UpdateRollCallHistory(selectedNames);
|
||||
|
||||
@@ -1783,7 +1783,7 @@ namespace Ink_Canvas
|
||||
isRollCalling = false;
|
||||
StartRollCallBtn.Visibility = Visibility.Visible;
|
||||
StopRollCallBtn.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
new System.Threading.Thread(() =>
|
||||
@@ -1819,7 +1819,7 @@ namespace Ink_Canvas
|
||||
private void StartSingleDrawNumberAnimation(int animationTimes, int sleepTime)
|
||||
{
|
||||
List<int> usedNumbers = new List<int>();
|
||||
|
||||
|
||||
for (int i = 0; i < animationTimes; i++)
|
||||
{
|
||||
// 随机选择一个数字进行动画显示,避免立即重复
|
||||
@@ -1828,27 +1828,27 @@ namespace Ink_Canvas
|
||||
{
|
||||
randomNumber = singleDrawRandom.Next(1, 61); // 1-60
|
||||
} while (usedNumbers.Count > 0 && usedNumbers[usedNumbers.Count - 1] == randomNumber);
|
||||
|
||||
|
||||
usedNumbers.Add(randomNumber);
|
||||
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
MainResultDisplay.Text = randomNumber.ToString();
|
||||
});
|
||||
|
||||
|
||||
System.Threading.Thread.Sleep(sleepTime);
|
||||
}
|
||||
|
||||
|
||||
// 动画结束,显示最终结果
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// 根据选择的模式进行不同的抽选逻辑
|
||||
var numberList = Enumerable.Range(1, 60).Select(n => n.ToString()).ToList();
|
||||
var selectedNumbers = SelectNamesByMode(numberList, currentCount);
|
||||
|
||||
|
||||
// 更新历史记录
|
||||
UpdateRollCallHistory(selectedNumbers);
|
||||
|
||||
|
||||
if (selectedNumbers.Count == 1)
|
||||
{
|
||||
MainResultDisplay.Text = selectedNumbers[0];
|
||||
@@ -1858,19 +1858,19 @@ namespace Ink_Canvas
|
||||
{
|
||||
MainResultDisplay.Text = "抽选结果";
|
||||
MultiResultPanel.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
Result1Display.Text = selectedNumbers.Count > 0 ? selectedNumbers[0] : "";
|
||||
Result2Display.Text = selectedNumbers.Count > 1 ? selectedNumbers[1] : "";
|
||||
Result3Display.Text = selectedNumbers.Count > 2 ? selectedNumbers[2] : "";
|
||||
|
||||
|
||||
UpdateStatusDisplay($"抽选完成,共选择 {selectedNumbers.Count} 个数字");
|
||||
}
|
||||
|
||||
|
||||
// 停止点名状态
|
||||
isRollCalling = false;
|
||||
StartRollCallBtn.Visibility = Visibility.Visible;
|
||||
StopRollCallBtn.Visibility = Visibility.Collapsed;
|
||||
|
||||
|
||||
if (isSingleDrawMode)
|
||||
{
|
||||
new System.Threading.Thread(() =>
|
||||
@@ -1908,21 +1908,21 @@ namespace Ink_Canvas
|
||||
{
|
||||
var selectedNumbers = new List<string>();
|
||||
var usedNumbers = new List<int>();
|
||||
|
||||
|
||||
for (int i = 0; i < count && usedNumbers.Count < 60; i++)
|
||||
{
|
||||
int randomNumber = singleDrawRandom.Next(1, 61); // 1-60
|
||||
|
||||
|
||||
// 避免重复选择
|
||||
while (usedNumbers.Contains(randomNumber))
|
||||
{
|
||||
randomNumber = singleDrawRandom.Next(1, 61);
|
||||
}
|
||||
|
||||
|
||||
usedNumbers.Add(randomNumber);
|
||||
selectedNumbers.Add(randomNumber.ToString());
|
||||
}
|
||||
|
||||
|
||||
return selectedNumbers;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Newtonsoft.Json;
|
||||
using MessageBox = iNKORE.UI.WPF.Modern.Controls.MessageBox;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -95,26 +94,26 @@ namespace Ink_Canvas
|
||||
// 显示统计信息
|
||||
int totalCount = historyData.History.Count;
|
||||
string lastUpdate = historyData.LastUpdate.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
|
||||
// 计算累计统计信息
|
||||
var statsLines = new System.Collections.Generic.List<string>();
|
||||
statsLines.Add($"");
|
||||
statsLines.Add($"");
|
||||
statsLines.Add($"累计抽选次数统计:");
|
||||
|
||||
|
||||
// 按累计次数降序排序显示
|
||||
var sortedStats = nameCountDict.OrderByDescending(kvp => kvp.Value).ToList();
|
||||
foreach (var kvp in sortedStats)
|
||||
{
|
||||
statsLines.Add($" {kvp.Key}: {kvp.Value}次");
|
||||
}
|
||||
|
||||
|
||||
statsLines.Add($"");
|
||||
statsLines.Add($"共 {totalCount} 条记录,最后更新:{lastUpdate}");
|
||||
|
||||
|
||||
// 组合历史记录和统计信息
|
||||
TextBoxHistory.Text = string.Join(Environment.NewLine, historyLines) +
|
||||
Environment.NewLine +
|
||||
TextBoxHistory.Text = string.Join(Environment.NewLine, historyLines) +
|
||||
Environment.NewLine +
|
||||
string.Join(Environment.NewLine, statsLines);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -184,7 +183,7 @@ namespace Ink_Canvas
|
||||
try
|
||||
{
|
||||
var resources = this.Resources;
|
||||
|
||||
|
||||
if (theme == "Light")
|
||||
{
|
||||
// 应用浅色主题资源
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Media;
|
||||
@@ -7,10 +9,6 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using Newtonsoft.Json;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Win32;
|
||||
namespace Ink_Canvas.Windows
|
||||
{
|
||||
/// <summary>
|
||||
@@ -41,25 +39,25 @@ namespace Ink_Canvas.Windows
|
||||
|
||||
// 应用主题
|
||||
ApplyTheme();
|
||||
|
||||
|
||||
// 初始化隐藏定时器
|
||||
hideTimer = new Timer(1000); // 每秒检查一次
|
||||
hideTimer.Elapsed += HideTimer_Elapsed;
|
||||
lastActivityTime = DateTime.Now;
|
||||
|
||||
|
||||
// 监听主题变化事件
|
||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
|
||||
|
||||
// 监听卸载事件,清理资源
|
||||
Unloaded += TimerControl_Unloaded;
|
||||
}
|
||||
|
||||
|
||||
private void TimerControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 取消订阅主题变化事件
|
||||
SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged;
|
||||
}
|
||||
|
||||
|
||||
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||
{
|
||||
// 当主题变化时,重新应用主题
|
||||
@@ -68,7 +66,7 @@ namespace Ink_Canvas.Windows
|
||||
RefreshTheme();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 刷新主题
|
||||
/// </summary>
|
||||
@@ -78,7 +76,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 重新应用主题
|
||||
ApplyTheme();
|
||||
|
||||
|
||||
// 强制刷新UI
|
||||
InvalidateVisual();
|
||||
}
|
||||
@@ -87,23 +85,23 @@ namespace Ink_Canvas.Windows
|
||||
LogHelper.WriteLogToFile($"刷新计时器窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 事件定义
|
||||
/// <summary>
|
||||
/// 计时器完成事件
|
||||
/// </summary>
|
||||
public event EventHandler TimerCompleted;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 关闭事件 - 通知主窗口隐藏容器
|
||||
/// </summary>
|
||||
public event EventHandler CloseRequested;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 显示最小化视图事件
|
||||
/// </summary>
|
||||
public event EventHandler ShowMinimizedRequested;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏最小化视图事件
|
||||
/// </summary>
|
||||
@@ -129,7 +127,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
TimeSpan leftTimeSpan = totalTimeSpan - timeSpan;
|
||||
if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1);
|
||||
|
||||
|
||||
int totalHours = (int)leftTimeSpan.TotalHours;
|
||||
int displayHours = totalHours;
|
||||
|
||||
@@ -141,10 +139,10 @@ namespace Ink_Canvas.Windows
|
||||
SetDigitDisplay("Digit4Display", leftTimeSpan.Minutes % 10);
|
||||
SetDigitDisplay("Digit5Display", leftTimeSpan.Seconds / 10);
|
||||
SetDigitDisplay("Digit6Display", leftTimeSpan.Seconds % 10);
|
||||
|
||||
|
||||
SetColonDisplay(false);
|
||||
|
||||
if (leftTimeSpan.TotalSeconds <= 6 && leftTimeSpan.TotalSeconds > 0 &&
|
||||
|
||||
if (leftTimeSpan.TotalSeconds <= 6 && leftTimeSpan.TotalSeconds > 0 &&
|
||||
MainWindow.Settings.RandSettings?.EnableProgressiveReminder == true &&
|
||||
!hasPlayedProgressiveReminder)
|
||||
{
|
||||
@@ -165,19 +163,19 @@ namespace Ink_Canvas.Windows
|
||||
SetDigitDisplay("Digit4Display", 0);
|
||||
SetDigitDisplay("Digit5Display", 0);
|
||||
SetDigitDisplay("Digit6Display", 0);
|
||||
|
||||
|
||||
SetColonDisplay(false);
|
||||
timer.Stop();
|
||||
isTimerRunning = false;
|
||||
StartPauseIcon.Data = Geometry.Parse(PlayIconData);
|
||||
PlayTimerSound();
|
||||
|
||||
|
||||
// 禁用全屏按钮
|
||||
if (FullscreenBtn != null)
|
||||
{
|
||||
FullscreenBtn.IsEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
TimerCompleted?.Invoke(this, EventArgs.Empty);
|
||||
HandleTimerCompletion();
|
||||
}
|
||||
@@ -206,7 +204,7 @@ namespace Ink_Canvas.Windows
|
||||
SetDigitDisplay("Digit4Display", minutesOnes, shouldShowRed);
|
||||
SetDigitDisplay("Digit5Display", secondsTens, shouldShowRed);
|
||||
SetDigitDisplay("Digit6Display", secondsOnes, shouldShowRed);
|
||||
|
||||
|
||||
SetColonDisplay(shouldShowRed);
|
||||
}
|
||||
});
|
||||
@@ -224,22 +222,22 @@ namespace Ink_Canvas.Windows
|
||||
|
||||
bool isTimerRunning = false;
|
||||
bool isPaused = false;
|
||||
bool isOvertimeMode = false;
|
||||
bool isOvertimeMode = false;
|
||||
TimeSpan remainingTime = TimeSpan.Zero;
|
||||
bool hasPlayedProgressiveReminder = false;
|
||||
|
||||
bool hasPlayedProgressiveReminder = false;
|
||||
|
||||
Timer timer = new Timer();
|
||||
private Timer hideTimer;
|
||||
private DateTime lastActivityTime;
|
||||
private DateTime lastActivityTime;
|
||||
public TimeSpan? GetTotalTimeSpan()
|
||||
{
|
||||
return new TimeSpan(hour, minute, second);
|
||||
}
|
||||
|
||||
|
||||
public TimeSpan? GetElapsedTime()
|
||||
{
|
||||
if (isPaused) return null;
|
||||
|
||||
|
||||
return DateTime.Now - startTime;
|
||||
}
|
||||
|
||||
@@ -336,7 +334,7 @@ namespace Ink_Canvas.Windows
|
||||
SetDarkThemeBorder();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 刷新数字和冒号显示的颜色
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
@@ -379,7 +377,7 @@ namespace Ink_Canvas.Windows
|
||||
SetDigitDisplay("Digit4Display", minute % 10);
|
||||
SetDigitDisplay("Digit5Display", second / 10);
|
||||
SetDigitDisplay("Digit6Display", second % 10);
|
||||
|
||||
|
||||
SetColonDisplay(false);
|
||||
}
|
||||
|
||||
@@ -394,10 +392,10 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 计算已经过去的时间
|
||||
TimeSpan elapsedTime = DateTime.Now - startTime;
|
||||
|
||||
|
||||
// 计算新的总时间
|
||||
TimeSpan newTotalTime = new TimeSpan(hour, minute, second);
|
||||
|
||||
|
||||
// 如果新设置的时间小于已经过去的时间,则设置为0
|
||||
if (newTotalTime <= elapsedTime)
|
||||
{
|
||||
@@ -428,10 +426,10 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 计算已经过去的时间
|
||||
TimeSpan elapsedTime = DateTime.Now - startTime;
|
||||
|
||||
|
||||
// 计算新的总时间
|
||||
TimeSpan newTotalTime = new TimeSpan(newHour, newMinute, newSecond);
|
||||
|
||||
|
||||
// 如果新设置的时间小于已经过去的时间,则设置为0
|
||||
if (newTotalTime <= elapsedTime)
|
||||
{
|
||||
@@ -456,13 +454,13 @@ namespace Ink_Canvas.Windows
|
||||
public TimeSpan? GetRemainingTime()
|
||||
{
|
||||
if (isPaused) return null;
|
||||
|
||||
|
||||
var elapsed = DateTime.Now - startTime;
|
||||
var totalTimeSpan = new TimeSpan(hour, minute, second);
|
||||
var leftTimeSpan = totalTimeSpan - elapsed;
|
||||
|
||||
|
||||
if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1);
|
||||
|
||||
|
||||
return leftTimeSpan;
|
||||
}
|
||||
|
||||
@@ -486,14 +484,14 @@ namespace Ink_Canvas.Windows
|
||||
if (path != null)
|
||||
{
|
||||
digit = Math.Max(0, Math.Min(9, digit));
|
||||
|
||||
|
||||
string resourceKey = $"Digit{digit}";
|
||||
var geometry = this.FindResource(resourceKey) as Geometry;
|
||||
if (geometry != null)
|
||||
{
|
||||
path.Data = geometry;
|
||||
}
|
||||
|
||||
|
||||
if (isRed)
|
||||
{
|
||||
path.Fill = Brushes.Red;
|
||||
@@ -521,7 +519,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var colon1 = this.FindName("Colon1Display") as TextBlock;
|
||||
var colon2 = this.FindName("Colon2Display") as TextBlock;
|
||||
|
||||
|
||||
if (colon1 != null)
|
||||
{
|
||||
if (isRed)
|
||||
@@ -541,7 +539,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (colon2 != null)
|
||||
{
|
||||
if (isRed)
|
||||
@@ -816,15 +814,15 @@ namespace Ink_Canvas.Windows
|
||||
isPaused = false;
|
||||
isTimerRunning = true;
|
||||
isOvertimeMode = false;
|
||||
hasPlayedProgressiveReminder = false;
|
||||
hasPlayedProgressiveReminder = false;
|
||||
timer.Start();
|
||||
|
||||
|
||||
// 启动隐藏定时器
|
||||
hideTimer.Start();
|
||||
|
||||
// 保存到最近计时记录
|
||||
SaveRecentTimer();
|
||||
|
||||
|
||||
// 启用全屏按钮
|
||||
if (FullscreenBtn != null)
|
||||
{
|
||||
@@ -836,31 +834,31 @@ namespace Ink_Canvas.Windows
|
||||
private void Reset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UpdateActivityTime();
|
||||
|
||||
|
||||
if (isTimerRunning)
|
||||
{
|
||||
// 停止计时器
|
||||
timer.Stop();
|
||||
isTimerRunning = false;
|
||||
isPaused = false;
|
||||
|
||||
|
||||
if (hideTimer != null)
|
||||
{
|
||||
hideTimer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateDigitDisplays();
|
||||
SetColonDisplay(false);
|
||||
|
||||
|
||||
if (StartPauseIcon != null)
|
||||
{
|
||||
StartPauseIcon.Data = Geometry.Parse(PlayIconData);
|
||||
}
|
||||
|
||||
|
||||
isOvertimeMode = false;
|
||||
hasPlayedProgressiveReminder = false;
|
||||
|
||||
|
||||
// 禁用全屏按钮
|
||||
if (FullscreenBtn != null)
|
||||
{
|
||||
@@ -1146,10 +1144,10 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
// 如果存在重复,将其移到最前面
|
||||
string duplicateTimer = GetRecentTimerByIndex(existingIndex);
|
||||
|
||||
|
||||
// 移除重复项
|
||||
RemoveRecentTimerByIndex(existingIndex);
|
||||
|
||||
|
||||
// 将重复项添加到最前面
|
||||
recentTimer6 = recentTimer5;
|
||||
recentTimer5 = recentTimer4;
|
||||
@@ -1354,9 +1352,9 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
|
||||
private FullscreenTimerWindow fullscreenWindow;
|
||||
|
||||
|
||||
public bool IsFullscreenWindowOpen => fullscreenWindow != null && fullscreenWindow.IsVisible;
|
||||
|
||||
|
||||
private void Fullscreen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (fullscreenWindow != null && fullscreenWindow.IsVisible)
|
||||
@@ -1365,7 +1363,7 @@ namespace Ink_Canvas.Windows
|
||||
fullscreenWindow = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (isTimerRunning && !isPaused)
|
||||
{
|
||||
fullscreenWindow = new FullscreenTimerWindow(this);
|
||||
@@ -1374,7 +1372,7 @@ namespace Ink_Canvas.Windows
|
||||
HideMinimizedRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void MainBorder_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
UpdateActivityTime();
|
||||
@@ -1393,7 +1391,7 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TitleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
UpdateActivityTime();
|
||||
@@ -1412,25 +1410,25 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private bool isDragging = false;
|
||||
private Point dragStartPoint;
|
||||
private Point containerStartPosition;
|
||||
|
||||
|
||||
private void DragTimerContainer(MainWindow mainWindow, Point startPoint, MouseButtonEventArgs e)
|
||||
{
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
if (timerContainer == null) return;
|
||||
|
||||
|
||||
isDragging = true;
|
||||
dragStartPoint = startPoint;
|
||||
|
||||
if (timerContainer.HorizontalAlignment == HorizontalAlignment.Center ||
|
||||
|
||||
if (timerContainer.HorizontalAlignment == HorizontalAlignment.Center ||
|
||||
timerContainer.VerticalAlignment == VerticalAlignment.Center)
|
||||
{
|
||||
var timerPoint = timerContainer.TransformToAncestor(mainWindow).Transform(new Point(0, 0));
|
||||
containerStartPosition = new Point(timerPoint.X, timerPoint.Y);
|
||||
|
||||
|
||||
timerContainer.Margin = new Thickness(containerStartPosition.X, containerStartPosition.Y, 0, 0);
|
||||
timerContainer.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
timerContainer.VerticalAlignment = VerticalAlignment.Top;
|
||||
@@ -1439,44 +1437,44 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var margin = timerContainer.Margin;
|
||||
containerStartPosition = new Point(margin.Left, margin.Top);
|
||||
|
||||
|
||||
if (double.IsNaN(containerStartPosition.X) || containerStartPosition.X < 0) containerStartPosition.X = 0;
|
||||
if (double.IsNaN(containerStartPosition.Y) || containerStartPosition.Y < 0) containerStartPosition.Y = 0;
|
||||
}
|
||||
|
||||
|
||||
timerContainer.CaptureMouse();
|
||||
timerContainer.MouseMove += TimerContainer_MouseMove;
|
||||
timerContainer.MouseLeftButtonUp += TimerContainer_MouseLeftButtonUp;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
private void TimerContainer_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (!isDragging) return;
|
||||
|
||||
|
||||
UpdateActivityTime();
|
||||
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow == null) return;
|
||||
|
||||
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
var minimizedContainer = mainWindow.FindName("MinimizedTimerContainer") as FrameworkElement;
|
||||
if (timerContainer == null) return;
|
||||
|
||||
|
||||
var currentPoint = e.GetPosition(mainWindow);
|
||||
var deltaX = currentPoint.X - dragStartPoint.X;
|
||||
var deltaY = currentPoint.Y - dragStartPoint.Y;
|
||||
|
||||
|
||||
var newX = containerStartPosition.X + deltaX;
|
||||
var newY = containerStartPosition.Y + deltaY;
|
||||
|
||||
|
||||
if (newX < 0) newX = 0;
|
||||
if (newY < 0) newY = 0;
|
||||
|
||||
|
||||
timerContainer.Margin = new Thickness(newX, newY, 0, 0);
|
||||
timerContainer.HorizontalAlignment = HorizontalAlignment.Left;
|
||||
timerContainer.VerticalAlignment = VerticalAlignment.Top;
|
||||
|
||||
|
||||
if (minimizedContainer != null && minimizedContainer.Visibility == Visibility.Visible)
|
||||
{
|
||||
minimizedContainer.Margin = new Thickness(newX, newY, 0, 0);
|
||||
@@ -1484,16 +1482,16 @@ namespace Ink_Canvas.Windows
|
||||
minimizedContainer.VerticalAlignment = VerticalAlignment.Top;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void TimerContainer_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!isDragging) return;
|
||||
|
||||
|
||||
isDragging = false;
|
||||
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow == null) return;
|
||||
|
||||
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
if (timerContainer != null)
|
||||
{
|
||||
@@ -1502,7 +1500,7 @@ namespace Ink_Canvas.Windows
|
||||
timerContainer.MouseLeftButtonUp -= TimerContainer_MouseLeftButtonUp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void HandleTimerCompletion()
|
||||
{
|
||||
// 计时器结束时,如果显示的是最小化视图,恢复到主窗口视图
|
||||
@@ -1513,7 +1511,7 @@ namespace Ink_Canvas.Windows
|
||||
{
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
var minimizedContainer = mainWindow.FindName("MinimizedTimerContainer") as FrameworkElement;
|
||||
|
||||
|
||||
// 如果最小化视图可见,恢复到主窗口视图
|
||||
if (minimizedContainer != null && minimizedContainer.Visibility == Visibility.Visible)
|
||||
{
|
||||
@@ -1521,11 +1519,11 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 重置计时器状态
|
||||
ResetTimerState();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置计时器状态
|
||||
/// </summary>
|
||||
@@ -1539,32 +1537,32 @@ namespace Ink_Canvas.Windows
|
||||
timer.Stop();
|
||||
isTimerRunning = false;
|
||||
isPaused = false;
|
||||
|
||||
|
||||
if (hideTimer != null)
|
||||
{
|
||||
hideTimer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 重置时间到默认值
|
||||
hour = 0;
|
||||
minute = 5;
|
||||
second = 0;
|
||||
|
||||
|
||||
// 更新显示
|
||||
UpdateDigitDisplays();
|
||||
SetColonDisplay(false);
|
||||
|
||||
|
||||
// 重置图标
|
||||
if (StartPauseIcon != null)
|
||||
{
|
||||
StartPauseIcon.Data = Geometry.Parse(PlayIconData);
|
||||
}
|
||||
|
||||
|
||||
// 重置状态标志
|
||||
isOvertimeMode = false;
|
||||
hasPlayedProgressiveReminder = false;
|
||||
|
||||
|
||||
// 禁用全屏按钮
|
||||
if (FullscreenBtn != null)
|
||||
{
|
||||
@@ -1572,15 +1570,15 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void HideTimer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (!isTimerRunning || isPaused) return;
|
||||
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var timeSinceLastActivity = DateTime.Now - lastActivityTime;
|
||||
|
||||
|
||||
if (timeSinceLastActivity.TotalSeconds >= 5)
|
||||
{
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
@@ -1595,17 +1593,17 @@ namespace Ink_Canvas.Windows
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void UpdateActivityTime()
|
||||
{
|
||||
lastActivityTime = DateTime.Now;
|
||||
|
||||
|
||||
var mainWindow = Application.Current.MainWindow as MainWindow;
|
||||
if (mainWindow != null)
|
||||
{
|
||||
var timerContainer = mainWindow.FindName("TimerContainer") as FrameworkElement;
|
||||
var minimizedContainer = mainWindow.FindName("MinimizedTimerContainer") as FrameworkElement;
|
||||
|
||||
|
||||
if (timerContainer != null && minimizedContainer != null)
|
||||
{
|
||||
if (timerContainer.Visibility == Visibility.Collapsed && minimizedContainer.Visibility == Visibility.Visible)
|
||||
|
||||
Reference in New Issue
Block a user