Skip to content

Commit

Permalink
Add Timer event trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
dogzz9445 committed Jun 19, 2024
1 parent 8586fd2 commit 7bf3a64
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Shared/Corathing.UI.WPF/Styles/Templates.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type Button}"
x:Key="TemplateStyleChangedButton">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
Value="True">
<Setter Property="Background"
Value="LightGray" />
</DataTrigger>

<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
Value="False">
<Setter Property="Background"
Value="Transparent" />
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
xmlns:local="clr-namespace:Corathing.Widgets.Basics.Widgets.Timers"
xmlns:circulars="clr-namespace:Corathing.UI.WPF.Controls.CircularProgressBars;assembly=Corathing.UI.WPF"
xmlns:converters="clr-namespace:Corathing.UI.WPF.Converters;assembly=Corathing.UI.WPF"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
x:Name="TimerWidgetMainControl"
mc:Ignorable="d"
d:DesignHeight="128" d:DesignWidth="128">
<UserControl.Resources>
Expand All @@ -16,9 +18,30 @@
<converters:TimeSpanSecondToDoubleConverter x:Key="TimeSpanSecondToDoubleConverter" />
<converters:BoolNotNullToVisibilityConverter x:Key="BoolNotNullToVisibilityConverter" />
<converters:InvertBoolNullToVisibilityConverter x:Key="InvertBoolNullToVisibilityConverter" />
<Style TargetType="{x:Type local:TimerWidget}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
Value="True">
<Setter Property="Background"
Value="LightGray" />
</DataTrigger>

<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
Value="False">
<Setter Property="Background"
Value="Transparent" />
</DataTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<b:Interaction.Triggers>
<b:EventTrigger EventName="MouseLeftButtonDown"
SourceObject="{Binding ElementName=TimerWidgetMainControl}">
<b:InvokeCommandAction Command="{Binding ToggleTimerCommand}" />
</b:EventTrigger>
</b:Interaction.Triggers>
<circulars:CircularProgressBar Padding="4"
Style="{StaticResource AutoCircularProgressBar}"
Maximum="{Binding ConfiguringTime, Converter={StaticResource TimeSpanSecondToDoubleConverter}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ private void OnTimerTick(object sender, EventArgs e)
RamainingTime -= TimeSpan.FromSeconds(1);
}

[RelayCommand]
public void ToggleTimer()
{
if (EditMode == true)
return;

if (IsRunning)
Stop();
else
Start();
}

[RelayCommand]
public void Start()
{
Expand Down

0 comments on commit 7bf3a64

Please sign in to comment.