// License: http://www.gnu.org/licenses/gpl.html GPL version 3.
namespace FileConverter.ViewModels
{
using System.ComponentModel;
using System.Windows.Input;
using FileConverter.Services;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Ioc;
///
/// This class contains properties that the main View can data bind to.
///
/// Use the mvvminpc snippet to add bindable properties to this ViewModel.
///
///
/// You can also use Blend to data bind with the tool's support.
///
///
/// See http://www.galasoft.ch/mvvm
///
///
public class UpgradeViewModel : ViewModelBase
{
private readonly IUpgradeService upgradeService;
private RelayCommand downloadInstallerCommand;
private RelayCommand launchInstallerCommand;
private RelayCommand closeCommand;
///
/// Initializes a new instance of the UpgradeViewModel class.
///
public UpgradeViewModel()
{
this.upgradeService = SimpleIoc.Default.GetInstance();
this.upgradeService.DownloadChangeLog();
}
public ICommand DownloadInstallerCommand
{
get
{
if (this.downloadInstallerCommand == null)
{
this.downloadInstallerCommand = new RelayCommand(this.ExecuteDownloadInstallerCommand);
}
return this.downloadInstallerCommand;
}
}
public ICommand LaunchInstallerCommand
{
get
{
if (this.launchInstallerCommand == null)
{
this.launchInstallerCommand = new RelayCommand(this.ExecuteLaunchInstallerCommand);
}
return this.launchInstallerCommand;
}
}
public ICommand CloseCommand
{
get
{
if (this.closeCommand == null)
{
this.closeCommand = new RelayCommand(this.Close);
}
return this.closeCommand;
}
}
private void ExecuteDownloadInstallerCommand()
{
this.upgradeService.StartUpgrade();
INavigationService navigationService = SimpleIoc.Default.GetInstance();
navigationService.Close(Pages.Upgrade, false);
}
private void ExecuteLaunchInstallerCommand()
{
INavigationService navigationService = SimpleIoc.Default.GetInstance();
navigationService.Close(Pages.Upgrade, false);
}
private void Close(CancelEventArgs args)
{
INavigationService navigationService = SimpleIoc.Default.GetInstance();
navigationService.Close(Pages.Upgrade, args != null);
}
}
}