/// <summary> /// Checks if folder paths exist /// </summary> /// <returns>Return a boolean to determine if folder paths exist</returns> private bool FolderCheck() { bool rightFolderExists = synchronizer.CheckFolderExists("right"); bool leftFolderExists = synchronizer.CheckFolderExists("left"); if (!rightFolderExists && !leftFolderExists) { helper.Show(nsync.Properties.Resources.bothFoldersNotExist, 5, HelperWindow.windowStartPosition.windowTop); LeftIcon.Source = RightIcon.Source = new BitmapImage(new Uri(ICON_LINK_FOLDER_MISSING)); return(false); } else if (!rightFolderExists) { helper.Show(nsync.Properties.Resources.rightFolderNotExist, 5, HelperWindow.windowStartPosition.windowTop); RightIcon.Source = new BitmapImage(new Uri(ICON_LINK_FOLDER_MISSING)); LeftIcon.Source = new BitmapImage(new Uri(ICON_LINK_FOLDER)); return(false); } else if (!leftFolderExists) { helper.Show(nsync.Properties.Resources.leftFolderNotExist, 5, HelperWindow.windowStartPosition.windowTop); RightIcon.Source = new BitmapImage(new Uri(ICON_LINK_FOLDER)); LeftIcon.Source = new BitmapImage(new Uri(ICON_LINK_FOLDER_MISSING)); return(false); } else { RightIcon.Source = LeftIcon.Source = new BitmapImage(new Uri(ICON_LINK_FOLDER)); return(true); } }
/// <summary> /// This method is called when user clicks on the Restore button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonRestore_Click(object sender, RoutedEventArgs e) { debugLogger.LogMessage(actualLeftFolderPath, actualRightFolderPath, "TrackBackPage.xaml.cs - ButtonRestore_Click()", "Trying to restore folders"); try { if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualLeftFolderPath && !trackback.hasEnoughDiskSpaceInLeftFolder()) { DisplayErrorInterface(); helper.Show(Properties.Resources.leftFolderInsufficientDiskSpace, HELPER_WINDOW_HIGH_PRIORITY, HelperWindow.windowStartPosition.windowTop); debugLogger.LogMessage(actualLeftFolderPath, actualRightFolderPath, "TrackBackPage.xaml.cs - ButtonRestore_Click()", nsync.Properties.Resources.leftFolderInsufficientDiskSpace); } else if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualRightFolderPath && !trackback.hasEnoughDiskSpaceInRightFolder()) { DisplayErrorInterface(); helper.Show(Properties.Resources.rightFolderInsufficientDiskSpace, HELPER_WINDOW_HIGH_PRIORITY, HelperWindow.windowStartPosition.windowTop); debugLogger.LogMessage(actualLeftFolderPath, actualRightFolderPath, "TrackBackPage.xaml.cs - ButtonRestore_Click()", nsync.Properties.Resources.rightFolderInsufficientDiskSpace); } else { EnableInterface(false); LabelProgress.Visibility = Visibility.Visible; LabelProgress.Content = MESSAGE_RESTORING_FOLDERS; if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualLeftFolderPath) { trackback.StartRestore(actualLeftFolderPath, GetSelectedListViewItem(ListViewForLeftFolder)); debugLogger.LogMessage(actualLeftFolderPath, actualRightFolderPath, "TrackBackPage.xaml.cs - ButtonRestore_Click()", "Restoring left folder in progress"); } else if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualRightFolderPath) { trackback.StartRestore(actualRightFolderPath, GetSelectedListViewItem(ListViewForRightFolder)); debugLogger.LogMessage(actualLeftFolderPath, actualRightFolderPath, "TrackBackPage.xaml.cs - ButtonRestore_Click()", "Restoring right folder in progress"); } } } catch (UnauthorizedAccessException) { DisplayErrorInterface(); helper.Show(Properties.Resources.accessRightsInsufficient, HELPER_WINDOW_HIGH_PRIORITY, HelperWindow.windowStartPosition.windowTop); debugLogger.LogMessage(actualLeftFolderPath, actualRightFolderPath, "TrackBackPage.xaml.cs - ButtonRestore_Click()", nsync.Properties.Resources.accessRightsInsufficient); return; } catch (FileNotFoundException fileNotFoundException) { DisplayErrorInterface(); helper.Show(fileNotFoundException.Message, HELPER_WINDOW_HIGH_PRIORITY, HelperWindow.windowStartPosition.windowTop); debugLogger.LogMessage(actualLeftFolderPath, actualRightFolderPath, "TrackBackPage.xaml.cs - ButtonRestore_Click()", fileNotFoundException.Message); return; } }