diff --git a/Application/FileConverter/Application.xaml b/Application/FileConverter/Application.xaml
index 67f9e09..89ccb9e 100644
--- a/Application/FileConverter/Application.xaml
+++ b/Application/FileConverter/Application.xaml
@@ -16,24 +16,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ DocumentStyle="{StaticResource DocumentStyle}"
+ Heading1Style="{StaticResource PageHeader}"
+ Heading2Style="{StaticResource SubHeader}"
+ Heading3Style="{StaticResource SubHeaderSecondary}"/>
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Application/FileConverter/FileConverter.csproj b/Application/FileConverter/FileConverter.csproj
index eb5aa77..3ebc9d7 100644
--- a/Application/FileConverter/FileConverter.csproj
+++ b/Application/FileConverter/FileConverter.csproj
@@ -190,11 +190,11 @@
-
-
+
+
diff --git a/Application/FileConverter/Services/IUpgradeService.cs b/Application/FileConverter/Services/IUpgradeService.cs
index 2ac4498..e6a955b 100644
--- a/Application/FileConverter/Services/IUpgradeService.cs
+++ b/Application/FileConverter/Services/IUpgradeService.cs
@@ -2,6 +2,8 @@
namespace FileConverter.Services
{
+ using System.Threading.Tasks;
+
public interface IUpgradeService
{
event System.EventHandler NewVersionAvailable;
@@ -16,5 +18,7 @@ namespace FileConverter.Services
void StartUpgrade();
void CancelUpgrade();
+
+ Task GetChangeLogAsync(UpgradeService.OnUpgradeOperationCompletedEventHandler onGetCompleteDelegate = null);
}
}
diff --git a/Application/FileConverter/Services/UpgradeService.cs b/Application/FileConverter/Services/UpgradeService.cs
index 9568cad..8920a88 100644
--- a/Application/FileConverter/Services/UpgradeService.cs
+++ b/Application/FileConverter/Services/UpgradeService.cs
@@ -3,20 +3,41 @@
namespace FileConverter.Services
{
using System;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Net;
+ using System.Text.RegularExpressions;
using System.Threading.Tasks;
-
+ using System.Xml;
+ using System.Xml.Serialization;
+
+ using FileConverter.Annotations;
+ using FileConverter.Diagnostics;
+
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Ioc;
public class UpgradeService : ObservableObject, IUpgradeService
{
+#if DEBUG
+ private const string BaseURI = "https://raw.githubusercontent.com/Tichau/FileConverter/integration/";
+#else
+ private const string BaseURI = "https://raw.githubusercontent.com/Tichau/FileConverter/master/";
+#endif
+
+ [NotNull]
+ private readonly WebClient webClient = new WebClient();
+
private UpgradeVersionDescription upgradeVersionDescription;
public UpgradeService()
{
+ this.UpgradeVersionDescription = new UpgradeVersionDescription();
SimpleIoc.Default.Register(() => this);
}
+ public delegate void OnUpgradeOperationCompletedEventHandler(UpgradeVersionDescription upgradeVersionDescription);
+
public event System.EventHandler NewVersionAvailable;
public UpgradeVersionDescription UpgradeVersionDescription
@@ -28,13 +49,13 @@ namespace FileConverter.Services
this.RaisePropertyChanged();
}
}
-
+
public void CheckForUpgrade()
{
try
{
#if DEBUG
- Task task = Upgrade.Helpers.GetLatestVersionDescriptionAsync(this.OnGetLatestVersionDescription);
+ Task task = this.GetLatestVersionDescriptionAsync(this.OnGetLatestVersionDescription);
#else
long fileTime = Registry.GetValue(Registry.Keys.LastUpdateCheckDate);
DateTime lastUpdateDateTime = DateTime.FromFileTime(fileTime);
@@ -42,7 +63,7 @@ namespace FileConverter.Services
TimeSpan durationSinceLastUpdate = DateTime.Now.Subtract(lastUpdateDateTime);
if (durationSinceLastUpdate > new TimeSpan(1, 0, 0, 0))
{
- Task task = Upgrade.Helpers.GetLatestVersionDescriptionAsync(this.OnGetLatestVersionDescription);
+ Task task = this.GetLatestVersionDescriptionAsync(this.OnGetLatestVersionDescription);
}
#endif
}
@@ -63,7 +84,7 @@ namespace FileConverter.Services
try
{
this.UpgradeVersionDescription.NeedToUpgrade = true;
- Task task = Upgrade.Helpers.DownloadInstallerAsync(this.upgradeVersionDescription);
+ Task task = this.DownloadInstallerAsync();
}
catch (Exception exception)
{
@@ -75,14 +96,43 @@ namespace FileConverter.Services
{
if (this.UpgradeVersionDescription == null)
{
- Diagnostics.Debug.Log("Can't cancel upgrade because there is no upgrade in progress.");
+ Debug.Log("Can't cancel upgrade because there is no upgrade in progress.");
return;
}
- Diagnostics.Debug.Log("Cancel application upgrade.");
+ Debug.Log("Cancel application upgrade.");
this.UpgradeVersionDescription.NeedToUpgrade = false;
}
+ public async Task GetChangeLogAsync(OnUpgradeOperationCompletedEventHandler onGetCompleteDelegate = null)
+ {
+ if (this.UpgradeVersionDescription == null)
+ {
+ throw new ArgumentNullException(nameof(this.UpgradeVersionDescription));
+ }
+
+ this.UpgradeVersionDescription.ChangeLog = Properties.Resources.DownloadingChangeLog;
+
+ Uri uri = new Uri(UpgradeService.BaseURI + "CHANGELOG.md");
+ try
+ {
+ Stream stream = await this.webClient.OpenReadTaskAsync(uri);
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ this.UpgradeVersionDescription.ChangeLog = reader.ReadToEnd();
+ }
+ }
+ catch (Exception)
+ {
+ Debug.LogError("Error while retrieving change log.");
+ return null;
+ }
+
+ onGetCompleteDelegate?.Invoke(this.UpgradeVersionDescription);
+
+ return this.UpgradeVersionDescription.ChangeLog;
+ }
+
private void OnGetLatestVersionDescription(UpgradeVersionDescription description)
{
if (description == null)
@@ -101,5 +151,123 @@ namespace FileConverter.Services
this.NewVersionAvailable?.Invoke(this, description);
}
+
+ private async Task GetLatestVersionDescriptionAsync(OnUpgradeOperationCompletedEventHandler onGetCompleteDelegate = null)
+ {
+#if BUILD32
+ Uri uri = new Uri(Helpers.BaseURI + "version (x86).xml");
+#else
+ Uri uri = new Uri(UpgradeService.BaseURI + "version.xml");
+#endif
+
+ UpgradeVersionDescription description = null;
+ try
+ {
+ Stream stream = await this.webClient.OpenReadTaskAsync(uri);
+
+ XmlRootAttribute xmlRoot = new XmlRootAttribute
+ {
+ ElementName = "Version"
+ };
+
+ XmlSerializer serializer = new XmlSerializer(typeof(UpgradeVersionDescription), xmlRoot);
+
+ XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
+ {
+ IgnoreWhitespace = true,
+ IgnoreComments = true
+ };
+
+ using (XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings))
+ {
+ description = (UpgradeVersionDescription)serializer.Deserialize(xmlReader);
+ }
+ }
+ catch (Exception)
+ {
+ Debug.Log("Error while retrieving change log.");
+ return null;
+ }
+
+ onGetCompleteDelegate?.Invoke(description);
+
+ return description;
+ }
+
+ private async Task DownloadInstallerAsync()
+ {
+ if (this.UpgradeVersionDescription == null)
+ {
+ throw new ArgumentNullException(nameof(this.UpgradeVersionDescription));
+ }
+
+ if (this.UpgradeVersionDescription.InstallerDownloadInProgress)
+ {
+ throw new Exception("The installer download is currently in progress.");
+ }
+
+ Uri uri = new Uri(this.UpgradeVersionDescription.InstallerURL);
+
+ string fileName = "FileConverter-setup.msi";
+ Regex retrieveFileNameRegex = new Regex("/([^/]*)");
+ MatchCollection matchCollection = retrieveFileNameRegex.Matches(this.UpgradeVersionDescription.InstallerURL);
+ if (matchCollection.Count > 0)
+ {
+ Match match = matchCollection[matchCollection.Count - 1];
+ if (match.Groups.Count > 1)
+ {
+ fileName = match.Groups[1].Value;
+ }
+ }
+
+ string tempPath = System.IO.Path.GetTempPath();
+ string installerPath = System.IO.Path.Combine(tempPath, fileName);
+
+ this.UpgradeVersionDescription.InstallerPath = installerPath;
+ this.UpgradeVersionDescription.InstallerDownloadInProgress = true;
+ this.UpgradeVersionDescription.InstallerDownloadProgress = 0;
+
+ // Source: https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel#2904963
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+
+ this.webClient.DownloadProgressChanged += this.WebClient_DownloadProgressChanged;
+ this.webClient.DownloadFileCompleted += this.WebClient_DownloadFileCompleted;
+ Task downloadTask = this.webClient.DownloadFileTaskAsync(uri, installerPath);
+ if (downloadTask != null)
+ {
+ await downloadTask;
+ }
+ }
+
+ private void WebClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
+ {
+ this.webClient.DownloadProgressChanged -= this.WebClient_DownloadProgressChanged;
+ this.webClient.DownloadFileCompleted -= this.WebClient_DownloadFileCompleted;
+
+ if (e.Error != null)
+ {
+ Debug.LogError("Failed to download the new File Converter upgrade. You should try again or download it manually.");
+ Debug.Log(e.Error.ToString());
+ if (this.UpgradeVersionDescription != null)
+ {
+ this.UpgradeVersionDescription.NeedToUpgrade = false;
+ }
+ }
+
+ if (this.UpgradeVersionDescription != null)
+ {
+ this.UpgradeVersionDescription.InstallerDownloadProgress = 100;
+ this.UpgradeVersionDescription.InstallerDownloadInProgress = false;
+ this.UpgradeVersionDescription = null;
+ }
+ }
+
+ private void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs eventArgs)
+ {
+ if (this.UpgradeVersionDescription != null)
+ {
+ this.UpgradeVersionDescription.InstallerDownloadProgress = eventArgs.ProgressPercentage;
+ }
+ }
}
}
diff --git a/Application/FileConverter/Upgrade/UpgradeVersionDescription.cs b/Application/FileConverter/Services/UpgradeVersionDescription.cs
similarity index 69%
rename from Application/FileConverter/Upgrade/UpgradeVersionDescription.cs
rename to Application/FileConverter/Services/UpgradeVersionDescription.cs
index 844f0e9..6457ce0 100644
--- a/Application/FileConverter/Upgrade/UpgradeVersionDescription.cs
+++ b/Application/FileConverter/Services/UpgradeVersionDescription.cs
@@ -1,6 +1,6 @@
// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
-namespace FileConverter
+namespace FileConverter.Services
{
using System.ComponentModel;
using System.Runtime.CompilerServices;
@@ -8,12 +8,14 @@ namespace FileConverter
using FileConverter.Annotations;
- public class UpgradeVersionDescription : INotifyPropertyChanged
+ using GalaSoft.MvvmLight;
+
+ public class UpgradeVersionDescription : ObservableObject
{
private int installerDownloadProgress;
private bool installerDownloadInProgress;
- public event PropertyChangedEventHandler PropertyChanged;
+ private string changeLog;
[XmlElement("Latest")]
public Version LatestVersion
@@ -28,12 +30,16 @@ namespace FileConverter
get;
set;
}
-
+
[XmlIgnore]
public string ChangeLog
{
- get;
- set;
+ get => this.changeLog;
+ set
+ {
+ this.changeLog = value;
+ this.RaisePropertyChanged();
+ }
}
[XmlIgnore]
@@ -54,9 +60,9 @@ namespace FileConverter
set
{
this.installerDownloadInProgress = value;
- this.OnPropertyChanged();
- this.OnPropertyChanged(nameof(this.InstallerDownloadDone));
- this.OnPropertyChanged(nameof(this.InstallerDownloadNotStarted));
+ this.RaisePropertyChanged();
+ this.RaisePropertyChanged(nameof(this.InstallerDownloadDone));
+ this.RaisePropertyChanged(nameof(this.InstallerDownloadNotStarted));
}
}
@@ -71,9 +77,9 @@ namespace FileConverter
set
{
this.installerDownloadProgress = value;
- this.OnPropertyChanged();
- this.OnPropertyChanged(nameof(this.InstallerDownloadDone));
- this.OnPropertyChanged(nameof(this.InstallerDownloadNotStarted));
+ this.RaisePropertyChanged();
+ this.RaisePropertyChanged(nameof(this.InstallerDownloadDone));
+ this.RaisePropertyChanged(nameof(this.InstallerDownloadNotStarted));
}
}
@@ -101,11 +107,5 @@ namespace FileConverter
get;
set;
}
-
- [NotifyPropertyChangedInvocator]
- protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
- {
- this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
}
}
\ No newline at end of file
diff --git a/Application/FileConverter/Upgrade/Helpers.cs b/Application/FileConverter/Upgrade/Helpers.cs
deleted file mode 100644
index 00a322c..0000000
--- a/Application/FileConverter/Upgrade/Helpers.cs
+++ /dev/null
@@ -1,176 +0,0 @@
-// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
-
-namespace FileConverter.Upgrade
-{
- using System;
- using System.ComponentModel;
- using System.IO;
- using System.Net;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using System.Xml;
- using System.Xml.Serialization;
-
- using FileConverter.Diagnostics;
-
- public static class Helpers
- {
-#if DEBUG
- private const string BaseURI = "https://raw.githubusercontent.com/Tichau/FileConverter/integration/";
-#else
- private const string BaseURI = "https://raw.githubusercontent.com/Tichau/FileConverter/master/";
-#endif
-
- private static WebClient webClient = new WebClient();
- private static UpgradeVersionDescription currentlyDownloadedVersionDescription;
-
- public delegate void OnUpgradeOperationCompletedEventHandler(UpgradeVersionDescription upgradeVersionDescription);
-
- public static async Task GetLatestVersionDescriptionAsync(OnUpgradeOperationCompletedEventHandler onGetCompleteDelegate = null)
- {
-#if BUILD32
- Uri uri = new Uri(Helpers.BaseURI + "version (x86).xml");
-#else
- Uri uri = new Uri(Helpers.BaseURI + "version.xml");
-#endif
-
- Stream stream = await Helpers.webClient.OpenReadTaskAsync(uri);
-
- UpgradeVersionDescription upgradeVersionDescription = null;
- try
- {
- XmlRootAttribute xmlRoot = new XmlRootAttribute
- {
- ElementName = "Version"
- };
-
- XmlSerializer serializer = new XmlSerializer(typeof(UpgradeVersionDescription), xmlRoot);
-
- XmlReaderSettings xmlReaderSettings = new XmlReaderSettings
- {
- IgnoreWhitespace = true,
- IgnoreComments = true
- };
-
- using (XmlReader xmlReader = XmlReader.Create(stream, xmlReaderSettings))
- {
- upgradeVersionDescription = (UpgradeVersionDescription)serializer.Deserialize(xmlReader);
- }
- }
- catch (Exception)
- {
- Diagnostics.Debug.LogError("Error while retrieving change log.");
- return null;
- }
-
- onGetCompleteDelegate?.Invoke(upgradeVersionDescription);
-
- return upgradeVersionDescription;
- }
-
- public static async Task GetChangeLogAsync(UpgradeVersionDescription upgradeVersionDescription, OnUpgradeOperationCompletedEventHandler onGetCompleteDelegate = null)
- {
- if (upgradeVersionDescription == null)
- {
- throw new ArgumentNullException(nameof(upgradeVersionDescription));
- }
-
- Uri uri = new Uri(Helpers.BaseURI + "CHANGELOG.md");
- Stream stream = await Helpers.webClient.OpenReadTaskAsync(uri);
- try
- {
- using (StreamReader reader = new StreamReader(stream))
- {
- upgradeVersionDescription.ChangeLog = reader.ReadToEnd();
- }
- }
- catch (Exception)
- {
- Diagnostics.Debug.LogError("Error while retrieving change log.");
- return null;
- }
-
- onGetCompleteDelegate?.Invoke(upgradeVersionDescription);
-
- return upgradeVersionDescription.ChangeLog;
- }
-
- public static async Task DownloadInstallerAsync(UpgradeVersionDescription upgradeVersionDescription)
- {
- if (upgradeVersionDescription == null)
- {
- throw new ArgumentNullException(nameof(upgradeVersionDescription));
- }
-
- if (Helpers.currentlyDownloadedVersionDescription != null)
- {
- throw new Exception("The installer download is currently in progress.");
- }
-
- Uri uri = new Uri(upgradeVersionDescription.InstallerURL);
-
- string fileName = "FileConverter-setup.msi";
- Regex retrieveFileNameRegex = new Regex("/([^/]*)");
- MatchCollection matchCollection = retrieveFileNameRegex.Matches(upgradeVersionDescription.InstallerURL);
- if (matchCollection.Count > 0)
- {
- Match match = matchCollection[matchCollection.Count - 1];
- if (match.Groups.Count > 1)
- {
- fileName = match.Groups[1].Value;
- }
- }
-
- string tempPath = System.IO.Path.GetTempPath();
- string installerPath = System.IO.Path.Combine(tempPath, fileName);
-
- upgradeVersionDescription.InstallerPath = installerPath;
- upgradeVersionDescription.InstallerDownloadInProgress = true;
- upgradeVersionDescription.InstallerDownloadProgress = 0;
-
- Helpers.currentlyDownloadedVersionDescription = upgradeVersionDescription;
-
- // Source: https://stackoverflow.com/questions/2859790/the-request-was-aborted-could-not-create-ssl-tls-secure-channel#2904963
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
-
- Helpers.webClient.DownloadProgressChanged += Helpers.WebClient_DownloadProgressChanged;
- Helpers.webClient.DownloadFileCompleted += Helpers.WebClient_DownloadFileCompleted;
- Task downloadTask = Helpers.webClient.DownloadFileTaskAsync(uri, installerPath);
- if (downloadTask != null)
- {
- await downloadTask;
- }
- }
-
- private static void WebClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
- {
- Helpers.webClient.DownloadProgressChanged -= WebClient_DownloadProgressChanged;
- Helpers.webClient.DownloadFileCompleted -= WebClient_DownloadFileCompleted;
-
- if (e.Error != null)
- {
- Debug.LogError("Failed to download the new File Converter upgrade. You should try again or download it manually.");
- Debug.Log(e.Error.ToString());
- if (Helpers.currentlyDownloadedVersionDescription != null)
- {
- Helpers.currentlyDownloadedVersionDescription.NeedToUpgrade = false;
- }
- }
-
- if (Helpers.currentlyDownloadedVersionDescription != null)
- {
- Helpers.currentlyDownloadedVersionDescription.InstallerDownloadProgress = 100;
- Helpers.currentlyDownloadedVersionDescription.InstallerDownloadInProgress = false;
- Helpers.currentlyDownloadedVersionDescription = null;
- }
- }
-
- private static void WebClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs eventArgs)
- {
- if (Helpers.currentlyDownloadedVersionDescription != null)
- {
- Helpers.currentlyDownloadedVersionDescription.InstallerDownloadProgress = eventArgs.ProgressPercentage;
- }
- }
- }
-}
diff --git a/Application/FileConverter/ValueConverters/ChangelogConverter.cs b/Application/FileConverter/ValueConverters/ChangelogConverter.cs
new file mode 100644
index 0000000..2b49938
--- /dev/null
+++ b/Application/FileConverter/ValueConverters/ChangelogConverter.cs
@@ -0,0 +1,59 @@
+// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
+
+namespace FileConverter.ValueConverters
+{
+ using System;
+ using System.Globalization;
+ using System.Windows.Data;
+
+ using FileConverter.Diagnostics;
+
+ public class ChangelogConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ bool header = false;
+ if (parameter != null)
+ {
+ switch (parameter)
+ {
+ case string s:
+ {
+ if (!bool.TryParse(s, out header))
+ {
+ Debug.LogError($"Invalid parameter {s}");
+ }
+
+ break;
+ }
+
+ case bool b:
+ header = b;
+ break;
+
+ default:
+ Debug.LogError($"Invalid parameter {parameter}");
+ break;
+ }
+ }
+
+ string content = string.Empty;
+ if (header)
+ {
+ content += Properties.Resources.LicenceHeader1 + "\n";
+ content += Properties.Resources.LicenceHeader2 + "\n\n";
+ content += Properties.Resources.LicenceHeader3 + "\n\n";
+ }
+
+ string changelog = (string)value;
+ content += changelog;
+
+ return content;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Application/FileConverter/ViewModels/SettingsViewModel.cs b/Application/FileConverter/ViewModels/SettingsViewModel.cs
index c291da5..cb0b045 100644
--- a/Application/FileConverter/ViewModels/SettingsViewModel.cs
+++ b/Application/FileConverter/ViewModels/SettingsViewModel.cs
@@ -2,19 +2,15 @@
namespace FileConverter.ViewModels
{
- using System;
using System.Collections.Generic;
- using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Windows;
- using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
- using FileConverter.ConversionJobs;
using FileConverter.Services;
using GalaSoft.MvvmLight;
@@ -56,7 +52,6 @@ namespace FileConverter.ViewModels
private ListCollectionView outputTypes;
private CultureInfo[] supportedCultures;
-
///
/// Initializes a new instance of the SettingsViewModel class.
///
@@ -183,25 +178,6 @@ namespace FileConverter.ViewModels
}
}
- public string AboutSectionContent
- {
- get
- {
- string content = Properties.Resources.LicenceHeader1 + "\n";
- content += Properties.Resources.LicenceHeader2 + "\n\n";
- content += Properties.Resources.LicenceHeader3 + "\n\n";
- content += this.releaseNoteContent;
- return content;
- }
-
- set
- {
- this.releaseNoteContent = value;
-
- this.RaisePropertyChanged();
- }
- }
-
public bool DisplaySeeChangeLogLink
{
get
@@ -333,10 +309,8 @@ namespace FileConverter.ViewModels
private void DownloadChangeLogAction()
{
-#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
- Upgrade.Helpers.GetChangeLogAsync(new UpgradeVersionDescription(), description => this.AboutSectionContent = description.ChangeLog);
-#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
- this.AboutSectionContent = Properties.Resources.DownloadingChangeLog;
+ IUpgradeService upgradeService = SimpleIoc.Default.GetInstance();
+ upgradeService.GetChangeLogAsync();
this.DisplaySeeChangeLogLink = false;
}
diff --git a/Application/FileConverter/ViewModels/UpgradeViewModel.cs b/Application/FileConverter/ViewModels/UpgradeViewModel.cs
index a7acdb7..ad489f6 100644
--- a/Application/FileConverter/ViewModels/UpgradeViewModel.cs
+++ b/Application/FileConverter/ViewModels/UpgradeViewModel.cs
@@ -26,8 +26,7 @@ namespace FileConverter.ViewModels
///
public class UpgradeViewModel : ViewModelBase
{
- private UpgradeVersionDescription upgradeVersionDescription;
- private string releaseNoteContent;
+ private readonly IUpgradeService upgradeService;
private RelayCommand downloadInstallerCommand;
private RelayCommand launchInstallerCommand;
@@ -38,19 +37,8 @@ namespace FileConverter.ViewModels
///
public UpgradeViewModel()
{
- if (this.IsInDesignMode)
- {
- // Code runs in Blend --> create design time data.
- UpgradeVersionDescription versionDescription = new UpgradeVersionDescription();
- versionDescription.LatestVersion = new Version() { Major = 0, Minor = 1, Patch = 0, };
- this.VersionDescription = versionDescription;
- }
- else
- {
- IUpgradeService upgradeService = SimpleIoc.Default.GetInstance();
- this.VersionDescription = upgradeService.UpgradeVersionDescription;
- upgradeService.NewVersionAvailable += this.UpgradeService_NewVersionAvailable;
- }
+ this.upgradeService = SimpleIoc.Default.GetInstance();
+ this.upgradeService.GetChangeLogAsync();
}
public ICommand DownloadInstallerCommand
@@ -92,55 +80,9 @@ namespace FileConverter.ViewModels
}
}
- public UpgradeVersionDescription VersionDescription
- {
- get
- {
- return this.upgradeVersionDescription;
- }
-
- set
- {
- this.upgradeVersionDescription = value;
-
- Task task = Upgrade.Helpers.GetChangeLogAsync(this.upgradeVersionDescription, this.OnChangeLogRetrieved);
- this.RaisePropertyChanged();
- }
- }
-
- public string ReleaseNote
- {
- get
- {
- if (string.IsNullOrEmpty(this.releaseNoteContent))
- {
- return Properties.Resources.DownloadingChangeLog;
- }
-
- return this.releaseNoteContent;
- }
-
- set
- {
- this.releaseNoteContent = value;
- this.RaisePropertyChanged();
- }
- }
-
- private void UpgradeService_NewVersionAvailable(object sender, UpgradeVersionDescription newVersion)
- {
- this.VersionDescription = newVersion;
- }
-
- private void OnChangeLogRetrieved(UpgradeVersionDescription versionDescription)
- {
- this.ReleaseNote = versionDescription.ChangeLog;
- }
-
private void ExecuteDownloadInstallerCommand()
{
- IUpgradeService upgradeService = SimpleIoc.Default.GetInstance();
- upgradeService.StartUpgrade();
+ this.upgradeService.StartUpgrade();
INavigationService navigationService = SimpleIoc.Default.GetInstance();
navigationService.Close(Pages.Upgrade, false);
diff --git a/Application/FileConverter/Views/SettingsWindow.xaml b/Application/FileConverter/Views/SettingsWindow.xaml
index 344eada..7140b9f 100644
--- a/Application/FileConverter/Views/SettingsWindow.xaml
+++ b/Application/FileConverter/Views/SettingsWindow.xaml
@@ -308,8 +308,8 @@
-
+
diff --git a/Application/FileConverter/Views/UpgradeWindow.xaml b/Application/FileConverter/Views/UpgradeWindow.xaml
index 57af1da..41c0b4c 100644
--- a/Application/FileConverter/Views/UpgradeWindow.xaml
+++ b/Application/FileConverter/Views/UpgradeWindow.xaml
@@ -31,12 +31,12 @@
-
+