/// <summary> /// TrackBackPage Contructor /// </summary> public TrackBackPage() { InitializeComponent(); settingsManager = Settings.Instance; // Get the debugLogger class instance debugLogger = DebugLogger.Instance; helper = new HelperManager(mainWindow); // Disables the TrackBackPage interface if no folder pairs are loaded in HomePage if (!File.Exists(SETTINGS_FILE_NAME) || settingsManager.LoadFolderPaths()[0] == "") { HideListViewForBothFolders(false); return; } else { LoadTrackBackXML(); trackback = new TrackBackEngine(); trackback.LeftFolderPath = actualLeftFolderPath; trackback.RightFolderPath = actualRightFolderPath; // Displays the message 'No TrackBack Data' if the folder does not have any previously backed up folders if (trackback.hasTrackBackData(actualLeftFolderPath) && trackback.hasTrackBackData(actualRightFolderPath)) { GridTrackBack.IsEnabled = true; } else if (trackback.hasTrackBackData(actualLeftFolderPath)) { DisplayListViewForLeftFolderOnly(true); } else if (trackback.hasTrackBackData(actualRightFolderPath)) { DisplayListViewForRightFolderOnly(true); } else { HideListViewForBothFolders(false); } // Adds the event handler for Restore trackback.backgroundWorkerForTrackBackRestore.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(backgroundWorkerForTrackBackRestore_RunWorkerCompleted); } }
/// <summary> /// Load folder paths from settings.xml /// </summary> private void LoadFolderPaths() { List <string> folderPaths = settingsManager.LoadFolderPaths(); int counter; if (folderPaths.Count == 0) { return; } //SQ LeftText.Text = folderPaths[0]; actualLeftPath = folderPaths[0]; //SQ LeftText.Text = ShortenText(actualLeftPath); //SQ //SQ synchronizer.LeftPath = LeftText.Text; synchronizer.LeftPath = actualLeftPath; //SQ //SQ RightText.Text = folderPaths[1]; actualRightPath = folderPaths[1]; //SQ RightText.Text = ShortenText(actualRightPath); //SQ //SQ synchronizer.RightPath = RightText.Text; synchronizer.RightPath = actualRightPath; //SQ if (actualLeftPath == NULL_STRING) //SQ (LeftText.Text == NULL_STRING) { //SQ LeftText.Text = nsync.Properties.Resources.panelText; actualLeftPath = nsync.Properties.Resources.panelText; //SQ LeftText.Text = nsync.Properties.Resources.panelText; //SQ hasLeftPath = false; } else { hasLeftPath = true; } if (actualRightPath == NULL_STRING) //SQ (RightText.Text == NULL_STRING) { //SQ RightText.Text = nsync.Properties.Resources.panelText; actualRightPath = nsync.Properties.Resources.panelText; //SQ RightText.Text = nsync.Properties.Resources.panelText; //SQ hasRightPath = false; } else { hasRightPath = true; } // If first pair of folder paths in settings.xml is already empty, it's guranteed settings.xml is empty. No point trying to load MRU if (LeftText.Text == nsync.Properties.Resources.panelText && RightText.Text == nsync.Properties.Resources.panelText) { return; } counter = 0; // Setup MRU listbox items for (int i = 1; i <= 5; i++) { ListBoxItem listBoxLeft = new ListBoxItem(); if (folderPaths[i + (i - 2)] == NULL_STRING) { continue; } listBoxLeft.Content = ShortenPath(folderPaths[i + (i - 2)]); listBoxLeft.ToolTip = folderPaths[i + (i - 2)]; originalFolderPaths[counter] = folderPaths[i + (i - 2)]; counter += 2; listBoxLeft.MouseUp += new MouseButtonEventHandler(ListBoxLeft_MouseUp); listBoxLeft.MouseEnter += new MouseEventHandler(listBoxLeft_MouseEnter); listBoxLeft.MouseLeave += new MouseEventHandler(listBoxLeft_MouseLeave); listBoxLeft.Tag = i; LeftListBox.Items.Add(listBoxLeft); } counter = 1; for (int i = 1; i <= 5; i++) { ListBoxItem listBoxRight = new ListBoxItem(); if (folderPaths[i + (i - 1)] == NULL_STRING) { continue; } listBoxRight.Content = ShortenPath(folderPaths[i + (i - 1)]); listBoxRight.ToolTip = folderPaths[i + (i - 1)]; originalFolderPaths[counter] = folderPaths[i + (i - 1)]; counter += 2; listBoxRight.MouseUp += new MouseButtonEventHandler(ListBoxRight_MouseUp); listBoxRight.MouseEnter += new MouseEventHandler(listBoxRight_MouseEnter); listBoxRight.MouseLeave += new MouseEventHandler(listBoxRight_MouseLeave); listBoxRight.Tag = i; RightListBox.Items.Add(listBoxRight); } ShowSync(); }
/// <summary> /// Page is loaded, initialise listview /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) { int trackbackStatus = settingsManager.GetTrackBackStatus(); // 0 for disabled, 1 for enabled, -1 is an error if (trackbackStatus != -1) { if (trackbackStatus == 0) { GridTrackBack.IsEnabled = false; GridTrackBack.Opacity = 0.5; LabelDisabled.Visibility = Visibility.Visible; } LabelProgress.Visibility = Visibility.Hidden; ButtonRestore.Visibility = Visibility.Hidden; if ((File.Exists(SETTINGS_FILE_NAME) && settingsManager.LoadFolderPaths()[0] != "") && trackback.hasTrackBackData(actualLeftFolderPath) && trackback.hasTrackBackData(actualRightFolderPath)) { LoadSourceFolders(); if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualLeftFolderPath) { LoadTrackBackEntriesForLeftFolder(); } else if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualRightFolderPath) { LoadTrackBackEntriesForRightFolder(); } //Sort left and right lists according to date/time SortList("dateItem", ListSortDirection.Descending, ListViewForLeftFolder); SortList("dateItem", ListSortDirection.Descending, ListViewForRightFolder); } else if ((File.Exists(SETTINGS_FILE_NAME) && settingsManager.LoadFolderPaths()[0] != "") && trackback.hasTrackBackData(actualLeftFolderPath)) { LoadSourceFolders(); if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualLeftFolderPath) { LoadTrackBackEntriesForLeftFolder(); } //Sort left lists according to date/time SortList("dateItem", ListSortDirection.Descending, ListViewForLeftFolder); } else if ((File.Exists(SETTINGS_FILE_NAME) && settingsManager.LoadFolderPaths()[0] != "") && trackback.hasTrackBackData(actualRightFolderPath)) { LoadSourceFolders(); if (GetOriginalFolderPath(GetSelectedComboBoxItem()) == actualRightFolderPath) { LoadTrackBackEntriesForRightFolder(); } //Sort right lists according to date/time SortList("dateItem", ListSortDirection.Descending, ListViewForRightFolder); } //Add event handler to check when main window is moved, move helper window too mainWindow.LocationChanged += new EventHandler(mainWindow_LocationChanged); } }