From e689705d91cf1dea0d36a1c348bfce4f9e872106 Mon Sep 17 00:00:00 2001 From: Adrien Allard Date: Wed, 6 Jun 2018 08:37:31 +0200 Subject: [PATCH] Display conversion progress on the taskbar item. --- .../FileConverter/Windows/MainWindow.xaml | 9 ++++- .../FileConverter/Windows/MainWindow.xaml.cs | 39 ++++++++++++++++++- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Application/FileConverter/Windows/MainWindow.xaml b/Application/FileConverter/Windows/MainWindow.xaml index d15af3e..f1c5614 100644 --- a/Application/FileConverter/Windows/MainWindow.xaml +++ b/Application/FileConverter/Windows/MainWindow.xaml @@ -11,6 +11,8 @@ x:Name="FileConverterMainWindow" Height="500" Width="950" MinHeight="250" MinWidth="500" WindowStartupLocation="CenterScreen" Icon="/FileConverter;component/Resources/ApplicationIcon.ico"> + + @@ -21,6 +23,11 @@ + + + @@ -44,7 +51,7 @@ - + diff --git a/Application/FileConverter/Windows/MainWindow.xaml.cs b/Application/FileConverter/Windows/MainWindow.xaml.cs index 0e6fe95..1e83147 100644 --- a/Application/FileConverter/Windows/MainWindow.xaml.cs +++ b/Application/FileConverter/Windows/MainWindow.xaml.cs @@ -3,9 +3,11 @@ namespace FileConverter { using System.ComponentModel; + using System.Collections.ObjectModel; using System.Runtime.CompilerServices; using System.Windows; + using FileConverter.ConversionJobs; using FileConverter.Annotations; using FileConverter.Windows; @@ -16,17 +18,17 @@ namespace FileConverter private UpgradeWindow upgradeWindow; private string informationMessage; + private ObservableCollection conversionJobs; public MainWindow() { this.InitializeComponent(); Application application = Application.Current as Application; + this.ConvertionJobs = new ObservableCollection(application.ConvertionJobs); application.OnApplicationTerminate += this.Application_OnApplicationTerminate; - this.ConverterJobsList.ItemsSource = application.ConvertionJobs; - if (application.HideMainWindow) { this.Hide(); @@ -60,6 +62,24 @@ namespace FileConverter } } + public ObservableCollection ConvertionJobs + { + get + { + return this.conversionJobs; + } + + private set + { + this.conversionJobs = value; + + foreach (var job in this.conversionJobs) + { + job.PropertyChanged += this.ConversionJob_PropertyChanged; + } + } + } + public void OnNewVersionReleased(UpgradeVersionDescription upgradeVersionDescription) { this.ShowUpgradeWindow(); @@ -80,6 +100,11 @@ namespace FileConverter { base.OnClosing(eventArgs); + foreach (var job in this.conversionJobs) + { + job.PropertyChanged -= this.ConversionJob_PropertyChanged; + } + Application application = Application.Current as Application; if (application.UpgradeVersionDescription != null && application.UpgradeVersionDescription.NeedToUpgrade && !application.UpgradeVersionDescription.InstallerDownloadDone) @@ -90,6 +115,16 @@ namespace FileConverter } } + private void ConversionJob_PropertyChanged(object sender, PropertyChangedEventArgs eventArgs) + { + if (eventArgs.PropertyName != "State" && eventArgs.PropertyName != "Progress") + { + return; + } + + this.OnPropertyChanged(nameof(this.ConvertionJobs)); + } + private void SettingsButton_OnClick(object sender, RoutedEventArgs e) { this.ShowSettingsWindow();