void ViewModel_NavigationHandler(object sender, MainViewModel.PageNavigationEventArgs e)
        {
            if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.Back)
            {
                e.Processed = true;

            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.Forward)
            {
                e.Processed = true;
                ViewModel.Navigate(new pageWelcome(ViewModel));

            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetBackButtonVisibleState)
            {
                e.Processed = true;
                e.Result = false;
            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetForwardButtonVisibleState)
            {
                e.Processed = true;
                e.Result = true;
            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetForwardButtonText)
            {
                e.Processed = true;
                e.Result = LocalizedResources.MainMenu;
            }
        }
        public pageRestoration(MainViewModel viewModel)
        {
            ViewModel = viewModel;
            InitializeComponent();

            MyThread = new Thread(RestoreThread);
            MyThread.Start(ViewModel);
        }
Exemple #3
0
 void ViewModel_NavigationHandler(object sender, MainViewModel.PageNavigationEventArgs e)
 {
     if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.Back)
     {
         e.Processed = true;
         var pg = new pageWelcome(ViewModel);
         ViewModel.Navigate(pg);
     }
     else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetBackButtonVisibleState)
     {
         e.Processed = true;
         e.Result = true;
     }
 }
        public static pageSelectApps GetBackupList(MainViewModel ViewModel)
        {
            var page = new pageSelectApps(ViewModel);
            page.IsBackupMode = true;
            page.LoadAppsIntoView(BackupProcessor.AppInfoRepositoryPath, new Action<List<ApplicationInfo>>(delegate(List<ApplicationInfo> list)
            {
                foreach (var info in list)
                {
                    try
                    {
                        DebugShow("---app: " + info.Title + " " + info.Guid);

                        /* we must copy only External (sideloaded) apps as we won't be able to restore all the rest */
                        info.IsDistributivePresent = true;
                        info.IsDataPresent = info.RealIsDataPresent();

                        info.IsDataChecked = true;
                        info.IsDistributiveChecked = true;

                        string path = BackupProcessor.AppInfoRepositoryPath + "\\Icons\\" + info.Guid;
                        if (System.IO.File.Exists(path + ".png"))
                            path += ".png";
                        else if (System.IO.File.Exists(path + ".gif"))
                            path += ".gif";
                        else if (System.IO.File.Exists(path + ".jpg"))
                            path += ".jpg";
                        else if (System.IO.File.Exists(path + ".jpeg"))
                            path += ".jpeg";
                        else if (System.IO.File.Exists(path + ".bmp"))
                            path += ".bmp";

                        if (System.IO.File.Exists(path))
                        {
                            DebugShow("Load Image " + path);

                            info.Icon = BitmapUtils.LoadImage(path);
                        }
                        else
                        {
                            info.Icon = null;
                            DebugShow("No Image");
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }));
            return page;
        }
 public pageRestoreSelectFile(MainViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
     if (ViewModel.TempFile != null)
     {
         txtComment.Text = ViewModel.TempFile.File.Comment;
         txtFilePath.Text = ViewModel.TempFilePath;
     }
     else
     {
         txtComment.Text = "";
         txtFilePath.Text = "";
     }
     Refresh();
 }
Exemple #6
0
 public static Page Create(string uriOrName, MainViewModel viewModel)
 {
     if (uriOrName.Contains("pageBackupList"))
         return new pageBackupList(viewModel);
     else if (uriOrName.Contains("pageRestoreList"))
         return new pageRestoreList(viewModel);
     else if (uriOrName.Contains("pageWelcome"))
         return new pageWelcome(viewModel);
     else if (uriOrName.Contains("pageRestoreSelectFile"))
         return new pageRestoreSelectFile(viewModel);
     else if (uriOrName.Contains("pageBackupCreation"))
         return new pageBackupCreation(viewModel);
     else if (uriOrName.Contains("pageRestoration"))
         return new pageBackupCreation(viewModel);
     return null;
 }
 void ViewModel_NavigationHandler(object sender, MainViewModel.PageNavigationEventArgs e)
 {
     e.Processed = true;
     switch (e.Type)
     {
         case MainViewModel.PageNavigationEventArgs.EventType.GetForwardButtonVisibleState:
             e.Result = false;
             break;
         case MainViewModel.PageNavigationEventArgs.EventType.Back:
             if (MessageBox.Show(LocalizedResources.CancelRestoreText, "WPBackup", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
             {
                 lock (CancellationPendingLock)
                 {
                     CancellationPending = true;
                 }
                 ViewModel.IsOperationCancelled = true;
             }
             break;
         case MainViewModel.PageNavigationEventArgs.EventType.GetBackButtonVisibleState:
             e.Result = true;
             break;
         case MainViewModel.PageNavigationEventArgs.EventType.GetBackButtonText:
             e.Result = LocalizedResources.Cancel;
             break;
         default:
             e.Processed = false;
             break;
     }
 }
        void ViewModel_NavigationHandler(object sender, MainViewModel.PageNavigationEventArgs e)
        {
            if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.Forward && ViewModel.TempFile != null)
            {
                ViewModel.CurrentFile = ViewModel.TempFile;
                ViewModel.CurrentFilePath = ViewModel.TempFilePath;

                e.Processed = true;

                var actions = new Dictionary<string, BackupProcessor.ActionSetting>();
                foreach (var key in BackupProcessor.RestoreTestActions.Keys)
                {
                    var val = BackupProcessor.RestoreTestActions[key];
                    var param = new BackupProcessor.TestActionParameter();
                    param.File = ViewModel.CurrentFile;
                    val(param);
                    actions.Add(key, new BackupProcessor.ActionSetting(param.IsAvailable, param.IsAvailable));
                }
                ViewModel.ActionSettings = actions;
                var page = new pageRestoreList(ViewModel);
                ViewModel.Navigate(page);
            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetForwardButtonVisibleState)
            {
                e.Processed = true;
                if (System.IO.File.Exists(txtFilePath.Text) && ViewModel.TempFile != null && RapiComm.IsConnected)
                    e.Result = true;
                else
                    e.Result = false;
            }
        }
 public pageWelcome(MainViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
 }
        private void ViewModel_NavigationHandler(object sender, MainViewModel.PageNavigationEventArgs e)
        {
            if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetForwardButtonVisibleState)
            {
                e.Processed = true;
                e.Result = ViewModel.IsConnected && IsAnyChecked();
            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.Forward)
            {
                e.Processed = true;
                var dict = new Dictionary<string, BackupProcessor.ActionSetting>();
                AddToDict(dict, chkApplications);
                AddToDict(dict, chkBingMapsCache);
                AddToDict(dict, chkDocuments);
                AddToDict(dict, chkContactsSmsMmsSchedule);
                AddToDict(dict, chkUserDict);
                AddToDict(dict, chkWifiNetworks);
                AddToDict(dict, chkAlarms);
                AddToDict(dict, chkCameraSequenceNumber);
                AddToDict(dict, chkLockscreenTimeout);
                ViewModel.ActionSettings = dict;

                if (chkApplications.IsChecked == true)
                {
                    try
                    {
                        if (System.IO.Directory.Exists(BackupProcessor.AppInfoRepositoryPath))
                            System.IO.Directory.Delete(BackupProcessor.AppInfoRepositoryPath, true);
                    }
                    catch (Exception ex)
                    {
                    }
                    System.IO.Directory.CreateDirectory(BackupProcessor.AppInfoRepositoryPath);
                    if (ViewModel.CurrentFile.Contains("\\AppInfo\\ApplicationInfo.txt"))
                    {
                        ViewModel.CurrentFile.ExtractFolder("\\AppInfo", BackupProcessor.AppInfoRepositoryPath);

                    }
                    /*
                    foreach (var entry in ViewModel.CurrentFile.List)
                    {

                        if (entry.FileName.StartsWith("AppInfo/"))
                        {
                            if (!entry.IsDirectory)
                            {
                                string fileName = BackupProcessor.AppInfoRepositoryPath + "\\";
                                fileName += entry.FileName.Replace("AppInfo/", "").Replace("/", "\\");

                                string folderPath = fileName.Substring(0, fileName.LastIndexOf("\\"));
                                if (System.IO.Directory.Exists(folderPath) == false)
                                    System.IO.Directory.CreateDirectory(folderPath);
                                entry.Extract(BackupProcessor.AppInfoRepositoryPath + "\\..", Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
                            }
                        }
                    }
                    */

                    var page = new pageSelectApps(ViewModel);
                    page.IsBackupMode = false;
                    page.LoadAppsIntoView(BackupProcessor.AppInfoRepositoryPath, new Action<List<ApplicationInfo>>(delegate(List<ApplicationInfo> list)
                    {
                        foreach (var info in list)
                        {
                            /* we must copy only External (sideloaded) apps as we won't be able to restore all the rest */
                            info.IsDistributivePresent = info.RealIsDistributivePresent(ViewModel);
                            info.IsDataPresent = info.RealIsDataPresent(ViewModel);

                            info.IsDataChecked = info.IsDataPresent;
                            info.IsDistributiveChecked = info.IsDistributivePresent;
                            string path = BackupProcessor.AppInfoRepositoryPath + "\\Icons\\" + info.Guid;
                            if (System.IO.File.Exists(path + ".png"))
                                path += ".png";
                            else if (System.IO.File.Exists(path + ".gif"))
                                path += ".gif";
                            else if (System.IO.File.Exists(path + ".jpg"))
                                path += ".jpg";
                            else if (System.IO.File.Exists(path + ".jpeg"))
                                path += ".jpeg";
                            else if (System.IO.File.Exists(path + ".bmp"))
                                path += ".bmp";
                            if (System.IO.File.Exists(path))
                            {
                                info.Icon = BitmapUtils.LoadImage(path);
                            }
                            else
                            {
                                info.Icon = null;
                            }
                        }
                    }));
                    ViewModel.Navigate(page);
                }
                else
                {
                    ViewModel.Navigate(new pageRestoration(ViewModel));
                }
            }
        }
 public pageSelectApps(MainViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
     progressBar1.Visibility = Visibility.Collapsed;
 }
 internal pageSuccess(MainViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
 }
Exemple #13
0
 public pageAbout(MainViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
 }
Exemple #14
0
 public pageError(MainViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
 }
Exemple #15
0
 private void viewModel_OnNavigate(object sender, MainViewModel.NavigateEventArgs e)
 {
     if (e.Page.GetType().ToString().Contains("Welcome"))
         lblAbout.Visibility = Visibility.Visible;
     else
         lblAbout.Visibility = Visibility.Collapsed;
     MainFrame.Navigate(e.Page);
 }
 public pageRestoreList(MainViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
 }
        void ViewModel_NavigationHandler(object sender, MainViewModel.PageNavigationEventArgs e)
        {
            if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.Back)
            {
                e.Processed = true;

                if (IsBackupMode)
                    ViewModel.Navigate(new pageBackupList(ViewModel));
                else
                    ViewModel.Navigate(new pageRestoreList(ViewModel));
            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.Forward)
            {
                e.Processed = true;
                if (ViewModel.ActionSettings != null)
                {
                    if (ViewModel.ActionSettings.ContainsKey("Applications"))
                        ViewModel.ActionSettings["Applications"].UserParam = listApplications.ItemsSource as List<ApplicationInfo>;
                }
                if (IsBackupMode)
                    ViewModel.Navigate(new pageBackupComment(ViewModel));
                else
                    ViewModel.Navigate(new pageRestoration(ViewModel));

            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetBackButtonVisibleState)
            {
                e.Processed = true;
                e.Result = true;
            }
            else if (e.Type == MainViewModel.PageNavigationEventArgs.EventType.GetForwardButtonVisibleState)
            {
                e.Processed = true;
                e.Result = !IsWorking;
            }
        }