Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
feat: pause button
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-wff committed Dec 14, 2023
1 parent 74b65bf commit 8028995
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 0 deletions.
Binary file added EasyGUI/Assets/Icons/pause-circle-outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions EasyGUI/Controls/Buttons/PauseButton.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<UserControl x:Class="EasyGUI.Controls.Buttons.PauseButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:buttons="clr-namespace:EasyGUI.Controls.Buttons"
xmlns:resx="clr-namespace:EasyGUI.Resources"
mc:Ignorable="d"
d:DesignHeight="50" d:DesignWidth="150">
<buttons:BaseButton ButtonText="{x:Static resx:Strings.PauseButton_Pause}"
Click="Button_OnClick"
ButtonColor="{StaticResource OrangeBrush}"
ButtonIcon="/Assets/Icons/pause-circle-outline.png" />
</UserControl>
18 changes: 18 additions & 0 deletions EasyGUI/Controls/Buttons/PauseButton.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Windows;

namespace EasyGUI.Controls.Buttons;

public partial class PauseButton
{
public PauseButton()
{
InitializeComponent();
}

public event RoutedEventHandler? Click;

private void Button_OnClick(object sender, RoutedEventArgs e)
{
Click?.Invoke(this, e);
}
}
1 change: 1 addition & 0 deletions EasyGUI/Controls/JobDisplay.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<buttons:DeleteButton Click="DeleteButton_OnClick" x:Name="DeleteButton" Margin="8,0,0,0" />
<buttons:ResumeButton Click="ResumeButton_OnClick" x:Name="ResumeButton" Margin="8,0,0,0" />
<buttons:DiscardButton Click="DiscardButton_OnClick" x:Name="DiscardButton" Margin="8,0,0,0" />
<buttons:PauseButton Click="PauseButton_OnClick" x:Name="PauseButton" Margin="8,0,0,0" />
</StackPanel>
</Grid>

Expand Down
7 changes: 7 additions & 0 deletions EasyGUI/Controls/JobDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void OnJobProgress(Job job)
public event EventHandler<JobEventArgs>? JobResumed;
public event EventHandler<JobEventArgs>? JobDeleted;
public event EventHandler<JobEventArgs>? JobDiscarded;
public event EventHandler<JobEventArgs>? JobPaused;

protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
Expand Down Expand Up @@ -133,6 +134,7 @@ private void UpdateButtons()
SetElementVisibility(DeleteButton, Job.State == JobState.End);
SetElementVisibility(ResumeButton, paused);
SetElementVisibility(DiscardButton, paused);
SetElementVisibility(PauseButton, Job.State != JobState.End && Job.CurrentlyRunning);
}

private void UpdateJobProgress()
Expand Down Expand Up @@ -216,4 +218,9 @@ private void DiscardButton_OnClick(object sender, RoutedEventArgs e)
{
JobDiscarded?.Invoke(this, new JobEventArgs(Job));
}

private void PauseButton_OnClick(object sender, RoutedEventArgs e)
{
JobPaused?.Invoke(this, new JobEventArgs(Job));
}
}
1 change: 1 addition & 0 deletions EasyGUI/Controls/JobsList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
JobResumed="JobDisplay_OnJobResumed"
JobDeleted="JobDisplay_OnJobDeleted"
JobDiscarded="JobDisplay_OnJobDiscarded"
JobPaused="JobDisplay_OnJobPaused"
JobStarted="JobDisplay_OnJobStarted" />
</DataTemplate>
</ListView.ItemTemplate>
Expand Down
7 changes: 7 additions & 0 deletions EasyGUI/Controls/JobsList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public ObservableCollection<Job> SelectedJobs

public event EventHandler<JobEventArgs>? JobDiscarded;

public event EventHandler<JobEventArgs>? JobPaused;

private void JobDisplay_OnJobStarted(object? sender, JobEventArgs e)
{
JobStarted?.Invoke(this, e);
Expand Down Expand Up @@ -90,4 +92,9 @@ private void JobDisplay_OnJobDiscarded(object? sender, JobEventArgs e)
{
JobDiscarded?.Invoke(this, e);
}

private void JobDisplay_OnJobPaused(object? sender, JobEventArgs e)
{
JobPaused?.Invoke(this, e);
}
}
6 changes: 6 additions & 0 deletions EasyGUI/EasyGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Resource Include="Assets\Icons\settings-outline.png"/>
<Resource Include="Assets\Icons\trash-outline.png"/>
<Resource Include="Assets\Icons\close-circle-outline.png"/>
<Resource Include="Assets\Icons\pause-circle-outline.png"/>
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -104,6 +105,11 @@
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Controls\Buttons\PauseButton.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions EasyGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
JobResumed="JobsList_OnJobResumed"
JobDeleted="JobsList_OnJobDeleted"
JobDiscarded="JobsList_OnJobDiscarded"
JobPaused="JobsList_OnJobPaused"
JobStarted="JobsList_OnJobStarted" />
</StackPanel>

Expand Down
6 changes: 6 additions & 0 deletions EasyGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ private void JobsList_OnJobDiscarded(object? sender, JobEventArgs e)
});
}

private void JobsList_OnJobPaused(object? sender, JobEventArgs e)
{
var job = e.Job;
Dispatcher.Invoke(() => _jobManager.PauseJob(job));
}

private void UpdateJob(Job job)
{
var jobIndex = Jobs.IndexOf(job);
Expand Down
9 changes: 9 additions & 0 deletions EasyGUI/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions EasyGUI/Resources/Strings.fr.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions EasyGUI/Resources/Strings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@
<data name="DiscardButton_Discard" xml:space="preserve">
<value>Abandonner</value>
</data>
<data name="PauseButton_Pause" xml:space="preserve">
<value>Pause</value>
</data>
</root>
3 changes: 3 additions & 0 deletions EasyGUI/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,7 @@
<data name="DiscardButton_Discard" xml:space="preserve">
<value>Discard</value>
</data>
<data name="PauseButton_Pause" xml:space="preserve">
<value>Pause</value>
</data>
</root>

0 comments on commit 8028995

Please sign in to comment.