/// <summary>
        /// This method is called when user click on the sync button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonSync_Click(object sender, RoutedEventArgs e)
        {
            debugLogger.LogMessage(actualLeftPath, actualRightPath, "ButtonSync_Click()", "Sync button clicked");

            // do a check one more time
            // handle the situation when after a sync job is setup,
            // user deletes the 2 folders n click sync again
            if (!ShowSync())
                return;

            bool leftDirectoryAccessible = IsDirectoryAccessible(actualLeftPath);
            bool rightDirectoryAccessible = IsDirectoryAccessible(actualRightPath);
            if (leftDirectoryAccessible && rightDirectoryAccessible)
            {

                // Check if exclude window is enabled in settings
                int excludeWindowStatus = settingsManager.GetExcludeWindowStatus(); // 0 for disabled, 1 for enabled, -1 for error
                if (excludeWindowStatus == 1)
                {
                    debugLogger.LogMessage(actualLeftPath, actualRightPath, "ButtonSync_Click()", "Opening Exclude Window");

                    EnableInterface(false);
                    excludeWindow = new ExcludeWindow();
                    excludeWindow.Closing += new CancelEventHandler(excludeWindow_Closing);
                    excludeWindow.LeftPath = actualLeftPath;
                    excludeWindow.RightPath = actualRightPath;
                    excludeWindow.Owner = mainWindow;
                    excludeWindow.LoadExcludeData();
                    excludeWindow.LogError += new ExcludeWindow.LogHandler(excludeWindow_LogError);
                    mainWindow.Opacity = 0.2;
                    excludeWindow.ShowDialog();
                }
                else if (excludeWindowStatus == 0)
                {
                    // Make necessary changes to UI to prepare for sync
                    LeftListBox.Visibility = Visibility.Hidden;
                    RightListBox.Visibility = Visibility.Hidden;
                    LabelProgress.Visibility = Visibility.Visible;
                    LabelProgress.Content = MESSAGE_PREPARING_FOLDERS;
                    EnableInterface(false);

                    // Feed the actualleftpath and actualrightpath into SyncEngine again
                    // Safety precaution
                    synchronizer.LeftPath = actualLeftPath;
                    synchronizer.RightPath = actualRightPath;

                    // Do PreSync Calculations: count how many changes need to be done
                    // If not enough disk space, return
                    // If enough, continue to start the real sync
                    excludeData = new ExcludeData();
                    synchronizer.ExcludeData = excludeData;
                    synchronizer.PreSync();
                }
                else
                {
                    //Do nothing if -1
                }
            }
            else
            {
                string rightsString = nsync.Properties.Resources.accessRightsInsufficient;
                if (!leftDirectoryAccessible)
                    rightsString += "\n" + ShortenPath(actualLeftPath, 50);
                if (!rightDirectoryAccessible)
                    rightsString += "\n" + ShortenPath(actualRightPath, 50);
                helper.Show(rightsString, HELPER_WINDOW_HIGH_PRIORITY, HelperWindow.windowStartPosition.windowTop);
                LabelProgress.Content = MESSAGE_ERROR_DETECTED;
                LabelProgress.Visibility = Visibility.Visible;
            }
        }
コード例 #2
0
 /// <summary>
 /// References ExcludeWindow (Overloaded Method) 
 /// </summary>
 public void SetOwnerWindow(ExcludeWindow excludeWindow)
 {
     this.excludeWindow = excludeWindow;
 }