aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.BackupRestore/ViewModels/RestoreCompletedViewVM.cs
blob: d773aa5d4b32f6d7557ca4c36a70dc03aa4f9fb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.Core.Helpers;
using Tango.PPC.Common;
using Tango.PPC.Common.BackupRestore;
using Tango.PPC.Common.Navigation;

namespace Tango.PPC.BackupRestore.ViewModels
{
    public class RestoreCompletedViewVM : PPCViewModel, INavigationObjectReceiver<RestoreResult>
    {
        private RestoreResult _restoreResult;

        public RelayCommand RestartCommand { get; set; }

        public RestoreCompletedViewVM()
        {
            RestartCommand = new RelayCommand(Restart);
        }

        private void Restart()
        {
            if (_restoreResult.BackupFile.Settings.Mode == BackupMode.Jobs)
            {
                //Perform normal restart.
                ApplicationManager.Restart();
            }
            else
            {
                //Perform update restart using the result path.
                String updater_exe = Path.Combine(_restoreResult.FolderPath, "Tango.PPC.Updater.exe");
                ApplicationManager.UpdateApplication(updater_exe, PathHelper.GetStartupPath());
            }
        }

        public override void OnApplicationStarted()
        {

        }

        public void OnNavigatedToWithObject(RestoreResult restoreResult)
        {
            _restoreResult = restoreResult;
        }
    }
}