add:issue #224
This commit is contained in:
@@ -44,18 +44,18 @@
|
||||
<Grid Name="GridAdjustHour" Visibility="Visible" Margin="-29,-30,0,-30" Width="29">
|
||||
<ui:SimpleStackPanel Spacing="2">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_1">
|
||||
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourPlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click">
|
||||
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourPlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_2">
|
||||
<TextBlock Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourMinus1Text" Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_3">
|
||||
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="HourMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
</Grid>
|
||||
@@ -91,18 +91,18 @@
|
||||
<Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29">
|
||||
<ui:SimpleStackPanel Spacing="2">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_5">
|
||||
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinutePlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_4">
|
||||
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinutePlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_6">
|
||||
<TextBlock Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinuteMinus1Text" Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_7">
|
||||
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="MinuteMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<Border x:Name="BtnTimeSetOkay" MouseUp="Grid_MouseUp"
|
||||
@@ -151,18 +151,18 @@
|
||||
<Grid Visibility="{Binding ElementName=GridAdjustHour, Path=Visibility}" Margin="-29,-30,0,-30" Width="29">
|
||||
<ui:SimpleStackPanel Spacing="2">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_8">
|
||||
<TextBlock Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondPlus5Text" Text="∧∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_9">
|
||||
<TextBlock Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondPlus1Text" Text="∧" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
<ui:SimpleStackPanel Spacing="2" VerticalAlignment="Bottom">
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_10">
|
||||
<TextBlock Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondMinus1Text" Text="∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
<Button Height="13" Width="{Binding ElementName=GridAdjustHour, Path=ActualWidth}" Click="Button_Click_11">
|
||||
<TextBlock Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
<TextBlock x:Name="SecondMinus5Text" Text="∨∨" Margin="-10" FontSize="8" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Button>
|
||||
</ui:SimpleStackPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using Ink_Canvas.Resources;
|
||||
using System;
|
||||
using System.Media;
|
||||
using System.Timers;
|
||||
@@ -6,6 +7,7 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
@@ -21,6 +23,7 @@ namespace Ink_Canvas
|
||||
|
||||
timer.Elapsed += Timer_Elapsed;
|
||||
timer.Interval = 50;
|
||||
InitializeUI();
|
||||
}
|
||||
|
||||
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
|
||||
@@ -62,24 +65,25 @@ namespace Ink_Canvas
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
//Play sound
|
||||
player.Stream = Properties.Resources.TimerDownNotice;
|
||||
player.Play();
|
||||
PlayTimerSound();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
SoundPlayer player = new SoundPlayer();
|
||||
MediaPlayer mediaPlayer = new MediaPlayer();
|
||||
|
||||
int hour = 0;
|
||||
int hour;
|
||||
int minute = 1;
|
||||
int second = 0;
|
||||
int second;
|
||||
int totalSeconds = 60;
|
||||
|
||||
DateTime startTime = DateTime.Now;
|
||||
DateTime pauseTime = DateTime.Now;
|
||||
|
||||
bool isTimerRunning = false;
|
||||
bool isPaused = false;
|
||||
bool isTimerRunning;
|
||||
bool isPaused;
|
||||
bool useLegacyUI;
|
||||
|
||||
Timer timer = new Timer();
|
||||
|
||||
@@ -334,6 +338,97 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeUI()
|
||||
{
|
||||
// 从设置中读取配置
|
||||
if (MainWindow.Settings.RandSettings != null)
|
||||
{
|
||||
useLegacyUI = MainWindow.Settings.RandSettings.UseLegacyTimerUI;
|
||||
UpdateButtonTexts();
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshUI()
|
||||
{
|
||||
InitializeUI();
|
||||
}
|
||||
|
||||
private void UpdateButtonTexts()
|
||||
{
|
||||
if (useLegacyUI)
|
||||
{
|
||||
// 老版UI:使用+5, +1, -1, -5
|
||||
HourPlus5Text.Text = "+5";
|
||||
HourPlus1Text.Text = "+1";
|
||||
HourMinus1Text.Text = "-1";
|
||||
HourMinus5Text.Text = "-5";
|
||||
|
||||
MinutePlus5Text.Text = "+5";
|
||||
MinutePlus1Text.Text = "+1";
|
||||
MinuteMinus1Text.Text = "-1";
|
||||
MinuteMinus5Text.Text = "-5";
|
||||
|
||||
SecondPlus5Text.Text = "+5";
|
||||
SecondPlus1Text.Text = "+1";
|
||||
SecondMinus1Text.Text = "-1";
|
||||
SecondMinus5Text.Text = "-5";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 新版UI:使用箭头符号
|
||||
HourPlus5Text.Text = "∧∧";
|
||||
HourPlus1Text.Text = "∧";
|
||||
HourMinus1Text.Text = "∨";
|
||||
HourMinus5Text.Text = "∨∨";
|
||||
|
||||
MinutePlus5Text.Text = "∧∧";
|
||||
MinutePlus1Text.Text = "∧";
|
||||
MinuteMinus1Text.Text = "∨";
|
||||
MinuteMinus5Text.Text = "∨∨";
|
||||
|
||||
SecondPlus5Text.Text = "∧∧";
|
||||
SecondPlus1Text.Text = "∧";
|
||||
SecondMinus1Text.Text = "∨";
|
||||
SecondMinus5Text.Text = "∨∨";
|
||||
}
|
||||
}
|
||||
|
||||
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_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
isTimerRunning = false;
|
||||
@@ -344,7 +439,7 @@ namespace Ink_Canvas
|
||||
Close();
|
||||
}
|
||||
|
||||
private bool _isInCompact = false;
|
||||
private bool _isInCompact;
|
||||
|
||||
private void BtnMinimal_OnMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
|
||||
@@ -398,7 +398,7 @@ namespace Ink_Canvas.Windows
|
||||
((Border)border).Background = new SolidColorBrush(Color.FromRgb(138, 138, 138));
|
||||
}
|
||||
|
||||
private Border _sidebarItemMouseDownBorder = null;
|
||||
private Border _sidebarItemMouseDownBorder;
|
||||
|
||||
private void SidebarItem_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
@@ -999,7 +999,7 @@ namespace Ink_Canvas.Windows
|
||||
public Image ThumbImage { get; set; }
|
||||
public Border TrackBorder { get; set; }
|
||||
public Border ValueBorder { get; set; }
|
||||
public bool IsTouchCaptured { get; set; } = false;
|
||||
public bool IsTouchCaptured { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user