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); }
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)); } } }