add:仿希沃计时器
This commit is contained in:
@@ -3295,6 +3295,15 @@
|
||||
FontWeight="Bold"
|
||||
Toggled="ToggleSwitchUseLegacyTimerUI_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="启用仿希沃UI"
|
||||
VerticalAlignment="Center" FontSize="14" Margin="0,0,16,0" />
|
||||
<ui:ToggleSwitch OnContent="" OffContent=""
|
||||
Name="ToggleSwitchUseSeewoStyleUI"
|
||||
IsOn="False" FontFamily="Microsoft YaHei UI"
|
||||
FontWeight="Bold"
|
||||
Toggled="ToggleSwitchUseSeewoStyleUI_Toggled" />
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<TextBlock Foreground="#fafafa" Text="计时器提醒音量" VerticalAlignment="Center"
|
||||
FontSize="14" Margin="0,0,16,0" />
|
||||
|
||||
@@ -1041,7 +1041,7 @@ namespace Ink_Canvas
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardBorderTools);
|
||||
AnimationsHelper.HideWithSlideAndFade(BoardImageOptionsPanel);
|
||||
|
||||
new CountdownTimerWindow().Show();
|
||||
CountdownTimerWindow.CreateTimerWindow().Show();
|
||||
}
|
||||
|
||||
private void OperatingGuideWindowIcon_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
|
||||
@@ -2603,6 +2603,23 @@ namespace Ink_Canvas
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.RandSettings.UseLegacyTimerUI = ToggleSwitchUseLegacyTimerUI.IsOn;
|
||||
if (ToggleSwitchUseLegacyTimerUI.IsOn)
|
||||
{
|
||||
ToggleSwitchUseSeewoStyleUI.IsOn = false;
|
||||
Settings.RandSettings.UseSeewoStyleUI = false;
|
||||
}
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ToggleSwitchUseSeewoStyleUI_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.RandSettings.UseSeewoStyleUI = ToggleSwitchUseSeewoStyleUI.IsOn;
|
||||
if (ToggleSwitchUseSeewoStyleUI.IsOn)
|
||||
{
|
||||
ToggleSwitchUseLegacyTimerUI.IsOn = false;
|
||||
Settings.RandSettings.UseLegacyTimerUI = false;
|
||||
}
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
|
||||
@@ -883,6 +883,7 @@ namespace Ink_Canvas
|
||||
|
||||
// 计时器设置
|
||||
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
|
||||
ToggleSwitchUseSeewoStyleUI.IsOn = Settings.RandSettings.UseSeewoStyleUI;
|
||||
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
|
||||
|
||||
// 加载自定义点名背景
|
||||
@@ -904,6 +905,7 @@ namespace Ink_Canvas
|
||||
ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
|
||||
ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
|
||||
ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
|
||||
ToggleSwitchUseSeewoStyleUI.IsOn = Settings.RandSettings.UseSeewoStyleUI;
|
||||
TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
|
||||
}
|
||||
|
||||
|
||||
@@ -631,6 +631,8 @@ namespace Ink_Canvas
|
||||
public List<CustomPickNameBackground> CustomPickNameBackgrounds { get; set; } = new List<CustomPickNameBackground>();
|
||||
[JsonProperty("useLegacyTimerUI")]
|
||||
public bool UseLegacyTimerUI { get; set; } = false;
|
||||
[JsonProperty("useSeewoStyleUI")]
|
||||
public bool UseSeewoStyleUI { get; set; } = false;
|
||||
[JsonProperty("timerVolume")]
|
||||
public double TimerVolume { get; set; } = 1.0;
|
||||
[JsonProperty("customTimerSoundPath")]
|
||||
|
||||
@@ -24,6 +24,18 @@ namespace Ink_Canvas
|
||||
InitializeUI();
|
||||
}
|
||||
|
||||
public static Window CreateTimerWindow()
|
||||
{
|
||||
if (MainWindow.Settings.RandSettings?.UseSeewoStyleUI == true)
|
||||
{
|
||||
return new SeewoStyleTimerWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new CountdownTimerWindow();
|
||||
}
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (!isTimerRunning || isPaused)
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
<Window x:Class="Ink_Canvas.SeewoStyleTimerWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Ink_Canvas"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
ui:ThemeManager.RequestedTheme="Light" Topmost="True" Background="Transparent"
|
||||
mc:Ignorable="d" WindowStyle="None" AllowsTransparency="True"
|
||||
Loaded="Window_Loaded" Closing="Window_Closing" WindowStartupLocation="CenterScreen"
|
||||
Title="Ink Canvas 画板 - 计时器" Height="400" Width="600">
|
||||
<Border Background="White" CornerRadius="15" BorderThickness="1" BorderBrush="#E0E0E0" Margin="10">
|
||||
<Grid>
|
||||
<!-- 顶部标题栏 -->
|
||||
<Grid Height="50" Background="White" x:Name="TitleBar" Margin="0,19,0,309">
|
||||
<TextBlock Text="计时" FontSize="20" FontWeight="Bold"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Margin="22,0,0,0" Foreground="#333333" x:Name="TitleText"/>
|
||||
<Border x:Name="BtnClose" MouseUp="BtnClose_MouseUp"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Center"
|
||||
Margin="0,0,22,0" Background="#F5F5F5" Height="30" Width="30"
|
||||
CornerRadius="15" Cursor="Hand">
|
||||
<TextBlock Text="×" FontSize="16" FontWeight="Bold"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
Foreground="#666666"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<!-- 主要内容区域 -->
|
||||
<Grid Margin="0,50,0,0">
|
||||
<!-- 6位数字显示区域 -->
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
x:Name="MainDisplayGrid">
|
||||
<!-- 6位数字水平排列 -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
|
||||
x:Name="DigitsPanel" Margin="0,-43,0,41">
|
||||
<!-- 小时组(十位和个位) -->
|
||||
<Grid Margin="0,0,30,0" HorizontalAlignment="Center" Width="120">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<!-- 第1位数字(小时十位) -->
|
||||
<Grid Margin="0,0,15,0">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<!-- 上方+按钮 -->
|
||||
<Button x:Name="Digit1PlusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit1Plus_Click" Cursor="Hand" Margin="0,0,0,8">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="+" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
<!-- 数字显示 -->
|
||||
<TextBlock x:Name="Digit1Display" Text="0" FontSize="64" FontWeight="Bold"
|
||||
HorizontalAlignment="Center" Foreground="#333333" Margin="0,0,0,8"/>
|
||||
<!-- 下方-按钮 -->
|
||||
<Button x:Name="Digit1MinusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit1Minus_Click" Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="-" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- 第2位数字(小时个位) -->
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<!-- 上方+按钮 -->
|
||||
<Button x:Name="Digit2PlusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit2Plus_Click" Cursor="Hand" Margin="0,0,0,8">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="+" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
<!-- 数字显示 -->
|
||||
<TextBlock x:Name="Digit2Display" Text="0" FontSize="64" FontWeight="Bold"
|
||||
HorizontalAlignment="Center" Foreground="#333333" Margin="0,0,0,8"/>
|
||||
<!-- 下方-按钮 -->
|
||||
<Button x:Name="Digit2MinusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit2Minus_Click" Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="-" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<!-- 时标签 -->
|
||||
<TextBlock Text="时" FontSize="16" HorizontalAlignment="Center"
|
||||
Foreground="#666666" Margin="0,112,0,-13"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 分钟组(十位和个位) -->
|
||||
<Grid Margin="0,0,30,0" HorizontalAlignment="Center" Width="120">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<!-- 第3位数字(分钟十位) -->
|
||||
<Grid Margin="0,0,15,0">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<!-- 上方+按钮 -->
|
||||
<Button x:Name="Digit3PlusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit3Plus_Click" Cursor="Hand" Margin="0,0,0,8">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="+" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
<!-- 数字显示 -->
|
||||
<TextBlock x:Name="Digit3Display" Text="0" FontSize="64" FontWeight="Bold"
|
||||
HorizontalAlignment="Center" Foreground="#333333" Margin="0,0,0,8"/>
|
||||
<!-- 下方-按钮 -->
|
||||
<Button x:Name="Digit3MinusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit3Minus_Click" Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="-" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- 第4位数字(分钟个位) -->
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<!-- 上方+按钮 -->
|
||||
<Button x:Name="Digit4PlusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit4Plus_Click" Cursor="Hand" Margin="0,0,0,8">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="+" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
<!-- 数字显示 -->
|
||||
<TextBlock x:Name="Digit4Display" Text="5" FontSize="64" FontWeight="Bold"
|
||||
HorizontalAlignment="Center" Foreground="#333333" Margin="0,0,0,8"/>
|
||||
<!-- 下方-按钮 -->
|
||||
<Button x:Name="Digit4MinusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit4Minus_Click" Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="-" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<!-- 分标签 -->
|
||||
<TextBlock Text="分" FontSize="16" HorizontalAlignment="Center"
|
||||
Foreground="#666666" Margin="0,112,0,-12"/>
|
||||
</Grid>
|
||||
|
||||
<!-- 秒组(十位和个位) -->
|
||||
<Grid Width="120">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<!-- 第5位数字(秒十位) -->
|
||||
<Grid Margin="0,0,15,0">
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<!-- 上方+按钮 -->
|
||||
<Button x:Name="Digit5PlusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit5Plus_Click" Cursor="Hand" Margin="0,0,0,8">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="+" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
<!-- 数字显示 -->
|
||||
<TextBlock x:Name="Digit5Display" Text="0" FontSize="64" FontWeight="Bold"
|
||||
HorizontalAlignment="Center" Foreground="#333333" Margin="0,0,0,8"/>
|
||||
<!-- 下方-按钮 -->
|
||||
<Button x:Name="Digit5MinusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit5Minus_Click" Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="-" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<!-- 第6位数字(秒个位) -->
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<!-- 上方+按钮 -->
|
||||
<Button x:Name="Digit6PlusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit6Plus_Click" Cursor="Hand" Margin="0,0,0,8">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="+" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
<!-- 数字显示 -->
|
||||
<TextBlock x:Name="Digit6Display" Text="0" FontSize="64" FontWeight="Bold"
|
||||
HorizontalAlignment="Center" Foreground="#333333" Margin="0,0,0,8"/>
|
||||
<!-- 下方-按钮 -->
|
||||
<Button x:Name="Digit6MinusBtn" Width="40" Height="40" Background="#F0F0F0"
|
||||
BorderThickness="0" Click="Digit6Minus_Click" Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="15">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock Text="-" FontSize="14" FontWeight="Bold" Foreground="#666666"/>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<!-- 秒标签 -->
|
||||
<TextBlock Text="秒" FontSize="16" HorizontalAlignment="Center"
|
||||
Foreground="#666666" Margin="0,112,0,-12"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- 底部控制按钮区域 -->
|
||||
<Grid HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,20">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<!-- 全屏按钮 -->
|
||||
<Button x:Name="FullscreenBtn" Width="80" Height="40" Background="#F5F5F5"
|
||||
BorderThickness="0" Click="Fullscreen_Click" Cursor="Hand" Margin="0,0,30,0">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="8">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<TextBlock Text="⛶" FontSize="16" Foreground="#666666" Margin="0,0,5,0"/>
|
||||
<TextBlock Text="全屏" FontSize="12" Foreground="#666666"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<!-- 开始/暂停按钮 -->
|
||||
<Button x:Name="StartPauseBtn" Width="80" Height="80" Background="#4CAF50"
|
||||
BorderThickness="0" Click="StartPause_Click" Cursor="Hand" Margin="0,0,30,0">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="40">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<TextBlock x:Name="StartPauseIcon" Text="▶" FontSize="32" Foreground="White"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
|
||||
<!-- 重置按钮 -->
|
||||
<Button x:Name="ResetBtn" Width="80" Height="40" Background="#F5F5F5"
|
||||
BorderThickness="0" Click="Reset_Click" Cursor="Hand">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="8">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<TextBlock Text="↻" FontSize="16" Foreground="#666666" Margin="0,0,5,0"/>
|
||||
<TextBlock Text="重置" FontSize="12" Foreground="#666666"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Window>
|
||||
@@ -0,0 +1,475 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.Media;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
/// <summary>
|
||||
/// 仿希沃风格的倒计时器窗口
|
||||
/// </summary>
|
||||
public partial class SeewoStyleTimerWindow : Window
|
||||
{
|
||||
public SeewoStyleTimerWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25);
|
||||
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
timer.Interval = 50;
|
||||
InitializeUI();
|
||||
|
||||
// 监听窗口大小变化
|
||||
this.SizeChanged += SeewoStyleTimerWindow_SizeChanged;
|
||||
}
|
||||
|
||||
private void SeewoStyleTimerWindow_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
// 根据窗口大小动态调整控件
|
||||
if (WindowState == WindowState.Maximized)
|
||||
{
|
||||
AdjustFontSizesForFullscreen(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
AdjustFontSizesForFullscreen(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (!isTimerRunning || isPaused)
|
||||
{
|
||||
timer.Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
TimeSpan timeSpan = DateTime.Now - startTime;
|
||||
TimeSpan totalTimeSpan = new TimeSpan(hour, minute, second);
|
||||
TimeSpan leftTimeSpan = totalTimeSpan - timeSpan;
|
||||
if (leftTimeSpan.Milliseconds > 0) leftTimeSpan += new TimeSpan(0, 0, 1);
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
Digit1Display.Text = (leftTimeSpan.Hours / 10).ToString();
|
||||
Digit2Display.Text = (leftTimeSpan.Hours % 10).ToString();
|
||||
Digit3Display.Text = (leftTimeSpan.Minutes / 10).ToString();
|
||||
Digit4Display.Text = (leftTimeSpan.Minutes % 10).ToString();
|
||||
Digit5Display.Text = (leftTimeSpan.Seconds / 10).ToString();
|
||||
Digit6Display.Text = (leftTimeSpan.Seconds % 10).ToString();
|
||||
|
||||
if (leftTimeSpan.TotalSeconds <= 0)
|
||||
{
|
||||
Digit1Display.Text = "0";
|
||||
Digit2Display.Text = "0";
|
||||
Digit3Display.Text = "0";
|
||||
Digit4Display.Text = "0";
|
||||
Digit5Display.Text = "0";
|
||||
Digit6Display.Text = "0";
|
||||
timer.Stop();
|
||||
isTimerRunning = false;
|
||||
StartPauseIcon.Text = "▶";
|
||||
PlayTimerSound();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SoundPlayer player = new SoundPlayer();
|
||||
MediaPlayer mediaPlayer = new MediaPlayer();
|
||||
|
||||
int hour = 0;
|
||||
int minute = 5;
|
||||
int second = 0;
|
||||
|
||||
DateTime startTime = DateTime.Now;
|
||||
DateTime pauseTime = DateTime.Now;
|
||||
|
||||
bool isTimerRunning = false;
|
||||
bool isPaused = false;
|
||||
|
||||
Timer timer = new Timer();
|
||||
|
||||
private void InitializeUI()
|
||||
{
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void UpdateDigitDisplays()
|
||||
{
|
||||
Digit1Display.Text = (hour / 10).ToString();
|
||||
Digit2Display.Text = (hour % 10).ToString();
|
||||
Digit3Display.Text = (minute / 10).ToString();
|
||||
Digit4Display.Text = (minute % 10).ToString();
|
||||
Digit5Display.Text = (second / 10).ToString();
|
||||
Digit6Display.Text = (second % 10).ToString();
|
||||
}
|
||||
|
||||
// 第1位数字(小时十位)
|
||||
private void Digit1Plus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
hour += 10;
|
||||
if (hour >= 100) hour = 0;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void Digit1Minus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
hour -= 10;
|
||||
if (hour < 0) hour = 90;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
// 第2位数字(小时个位)
|
||||
private void Digit2Plus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
hour++;
|
||||
if (hour >= 100) hour = 0;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void Digit2Minus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
hour--;
|
||||
if (hour < 0) hour = 99;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
// 第3位数字(分钟十位)
|
||||
private void Digit3Plus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
minute += 10;
|
||||
if (minute >= 60) minute = 0;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void Digit3Minus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
minute -= 10;
|
||||
if (minute < 0) minute = 50;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
// 第4位数字(分钟个位)
|
||||
private void Digit4Plus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
minute++;
|
||||
if (minute >= 60) minute = 0;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void Digit4Minus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
minute--;
|
||||
if (minute < 0) minute = 59;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
// 第5位数字(秒十位)
|
||||
private void Digit5Plus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
second += 10;
|
||||
if (second >= 60) second = 0;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void Digit5Minus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
second -= 10;
|
||||
if (second < 0) second = 50;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
// 第6位数字(秒个位)
|
||||
private void Digit6Plus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
second++;
|
||||
if (second >= 60) second = 0;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void Digit6Minus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isTimerRunning) return;
|
||||
second--;
|
||||
if (second < 0) second = 59;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
private void StartPause_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (isPaused && isTimerRunning)
|
||||
{
|
||||
// 继续计时
|
||||
startTime += DateTime.Now - pauseTime;
|
||||
StartPauseIcon.Text = "⏸";
|
||||
isPaused = false;
|
||||
timer.Start();
|
||||
}
|
||||
else if (isTimerRunning)
|
||||
{
|
||||
// 暂停计时
|
||||
pauseTime = DateTime.Now;
|
||||
StartPauseIcon.Text = "▶";
|
||||
isPaused = true;
|
||||
timer.Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 开始计时
|
||||
if (hour == 0 && minute == 0 && second == 0)
|
||||
{
|
||||
second = 1;
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
|
||||
startTime = DateTime.Now;
|
||||
StartPauseIcon.Text = "⏸";
|
||||
isPaused = false;
|
||||
isTimerRunning = true;
|
||||
timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void Reset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isTimerRunning)
|
||||
{
|
||||
UpdateDigitDisplays();
|
||||
}
|
||||
else if (isTimerRunning && isPaused)
|
||||
{
|
||||
UpdateDigitDisplays();
|
||||
StartPauseIcon.Text = "▶";
|
||||
isTimerRunning = false;
|
||||
timer.Stop();
|
||||
isPaused = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = DateTime.Now;
|
||||
Timer_Elapsed(timer, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void Fullscreen_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (WindowState == WindowState.Normal)
|
||||
{
|
||||
WindowState = WindowState.Maximized;
|
||||
// 全屏时调整字体大小
|
||||
AdjustFontSizesForFullscreen(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = WindowState.Normal;
|
||||
// 恢复普通窗口时的字体大小
|
||||
AdjustFontSizesForFullscreen(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustFontSizesForFullscreen(bool isFullscreen)
|
||||
{
|
||||
if (isFullscreen)
|
||||
{
|
||||
// 全屏时增大字体
|
||||
Digit1Display.FontSize = 120;
|
||||
Digit2Display.FontSize = 120;
|
||||
Digit3Display.FontSize = 120;
|
||||
Digit4Display.FontSize = 120;
|
||||
Digit5Display.FontSize = 120;
|
||||
Digit6Display.FontSize = 120;
|
||||
|
||||
// 增大按钮尺寸
|
||||
Digit1PlusBtn.Width = 50;
|
||||
Digit1PlusBtn.Height = 50;
|
||||
Digit1MinusBtn.Width = 50;
|
||||
Digit1MinusBtn.Height = 50;
|
||||
|
||||
Digit2PlusBtn.Width = 50;
|
||||
Digit2PlusBtn.Height = 50;
|
||||
Digit2MinusBtn.Width = 50;
|
||||
Digit2MinusBtn.Height = 50;
|
||||
|
||||
Digit3PlusBtn.Width = 50;
|
||||
Digit3PlusBtn.Height = 50;
|
||||
Digit3MinusBtn.Width = 50;
|
||||
Digit3MinusBtn.Height = 50;
|
||||
|
||||
Digit4PlusBtn.Width = 50;
|
||||
Digit4PlusBtn.Height = 50;
|
||||
Digit4MinusBtn.Width = 50;
|
||||
Digit4MinusBtn.Height = 50;
|
||||
|
||||
Digit5PlusBtn.Width = 50;
|
||||
Digit5PlusBtn.Height = 50;
|
||||
Digit5MinusBtn.Width = 50;
|
||||
Digit5MinusBtn.Height = 50;
|
||||
|
||||
Digit6PlusBtn.Width = 50;
|
||||
Digit6PlusBtn.Height = 50;
|
||||
Digit6MinusBtn.Width = 50;
|
||||
Digit6MinusBtn.Height = 50;
|
||||
|
||||
// 增大控制按钮
|
||||
StartPauseBtn.Width = 150;
|
||||
StartPauseBtn.Height = 150;
|
||||
FullscreenBtn.Width = 150;
|
||||
FullscreenBtn.Height = 60;
|
||||
ResetBtn.Width = 150;
|
||||
ResetBtn.Height = 60;
|
||||
|
||||
// 调整按钮字体大小
|
||||
StartPauseIcon.FontSize = 48;
|
||||
|
||||
// 调整标题栏和关闭按钮在全屏时的位置
|
||||
TitleBar.Height = 80;
|
||||
TitleText.FontSize = 32;
|
||||
BtnClose.Width = 50;
|
||||
BtnClose.Height = 50;
|
||||
|
||||
// 调整数字显示区域的间距
|
||||
MainDisplayGrid.Margin = new Thickness(0, 20, 0, 20);
|
||||
|
||||
// 调整时间单位标签的字体大小(现在每个时间组都有自己的标签)
|
||||
// 这些标签现在直接在每个时间组内,不需要单独处理
|
||||
}
|
||||
else
|
||||
{
|
||||
// 恢复普通窗口时的尺寸
|
||||
Digit1Display.FontSize = 64;
|
||||
Digit2Display.FontSize = 64;
|
||||
Digit3Display.FontSize = 64;
|
||||
Digit4Display.FontSize = 64;
|
||||
Digit5Display.FontSize = 64;
|
||||
Digit6Display.FontSize = 64;
|
||||
|
||||
// 恢复按钮尺寸
|
||||
Digit1PlusBtn.Width = 30;
|
||||
Digit1PlusBtn.Height = 30;
|
||||
Digit1MinusBtn.Width = 30;
|
||||
Digit1MinusBtn.Height = 30;
|
||||
|
||||
Digit2PlusBtn.Width = 30;
|
||||
Digit2PlusBtn.Height = 30;
|
||||
Digit2MinusBtn.Width = 30;
|
||||
Digit2MinusBtn.Height = 30;
|
||||
|
||||
Digit3PlusBtn.Width = 30;
|
||||
Digit3PlusBtn.Height = 30;
|
||||
Digit3MinusBtn.Width = 30;
|
||||
Digit3MinusBtn.Height = 30;
|
||||
|
||||
Digit4PlusBtn.Width = 30;
|
||||
Digit4PlusBtn.Height = 30;
|
||||
Digit4MinusBtn.Width = 30;
|
||||
Digit4MinusBtn.Height = 30;
|
||||
|
||||
Digit5PlusBtn.Width = 30;
|
||||
Digit5PlusBtn.Height = 30;
|
||||
Digit5MinusBtn.Width = 30;
|
||||
Digit5MinusBtn.Height = 30;
|
||||
|
||||
Digit6PlusBtn.Width = 30;
|
||||
Digit6PlusBtn.Height = 30;
|
||||
Digit6MinusBtn.Width = 30;
|
||||
Digit6MinusBtn.Height = 30;
|
||||
|
||||
// 恢复控制按钮尺寸
|
||||
StartPauseBtn.Width = 80;
|
||||
StartPauseBtn.Height = 80;
|
||||
FullscreenBtn.Width = 80;
|
||||
FullscreenBtn.Height = 40;
|
||||
ResetBtn.Width = 80;
|
||||
ResetBtn.Height = 40;
|
||||
|
||||
// 恢复按钮字体大小
|
||||
StartPauseIcon.FontSize = 32;
|
||||
|
||||
// 恢复标题栏和关闭按钮的普通尺寸
|
||||
TitleBar.Height = 50;
|
||||
TitleText.FontSize = 20;
|
||||
BtnClose.Width = 30;
|
||||
BtnClose.Height = 30;
|
||||
|
||||
// 恢复数字显示区域的间距
|
||||
MainDisplayGrid.Margin = new Thickness(0, 0, 0, 0);
|
||||
|
||||
// 恢复时间单位标签的字体大小(现在每个时间组都有自己的标签)
|
||||
// 这些标签现在直接在每个时间组内,不需要单独处理
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayTimerSound()
|
||||
{
|
||||
try
|
||||
{
|
||||
double volume = MainWindow.Settings.RandSettings?.TimerVolume ?? 1.0;
|
||||
mediaPlayer.Volume = volume;
|
||||
|
||||
if (!string.IsNullOrEmpty(MainWindow.Settings.RandSettings?.CustomTimerSoundPath) &&
|
||||
System.IO.File.Exists(MainWindow.Settings.RandSettings.CustomTimerSoundPath))
|
||||
{
|
||||
// 播放自定义铃声
|
||||
mediaPlayer.Open(new Uri(MainWindow.Settings.RandSettings.CustomTimerSoundPath));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 播放默认铃声
|
||||
string tempPath = System.IO.Path.GetTempFileName() + ".wav";
|
||||
using (var stream = Properties.Resources.TimerDownNotice)
|
||||
{
|
||||
using (var fileStream = new System.IO.FileStream(tempPath, System.IO.FileMode.Create))
|
||||
{
|
||||
stream.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
mediaPlayer.Open(new Uri(tempPath));
|
||||
}
|
||||
|
||||
mediaPlayer.Play();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 如果播放失败,静默处理
|
||||
System.Diagnostics.Debug.WriteLine($"播放计时器铃声失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 窗口加载时的初始化
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
isTimerRunning = false;
|
||||
}
|
||||
|
||||
private void BtnClose_MouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void WindowDragMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user