Пример #1
0
 /// <summary>
 /// Handles the Click event of the restoreBackupFileToolStripMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void restoreBackupFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.backupFilesList.SelectedItems.Count > 0)
     {
         if (_loadedConfigFile == null)
         {
             SaveFileDialog sfd = new SaveFileDialog();
             sfd.Title    = "Restore backup to file...";
             sfd.FileName = "ccnet.config";
             sfd.Filter   = Properties.Strings.OpenSaveFilter;
             if (sfd.ShowDialog(this) == DialogResult.OK)
             {
                 _loadedConfigFile = new FileInfo(sfd.FileName);
             }
         }
         BackupFileListViewItem bflvi     = this.backupFilesList.SelectedItems[0] as BackupFileListViewItem;
         FileInfo            backupFile   = bflvi.FileInfo;
         FileInfo            restoredFile = _loadedConfigFile;
         BackupFileEventArgs be           = new BackupFileEventArgs(backupFile, restoredFile);
         OnBeforeRestoreConfigurationFromBackup(be);
         bflvi.RestoreBackup(restoredFile);
         OnAfterRestoreConfigurationFromBackup(be);
         Thread threadLoadBackupFiles = new Thread(new ThreadStart(LoadBackupsToListView));
         threadLoadBackupFiles.Start();
     }
 }
Пример #2
0
 /// <summary>
 /// Handles the Click event of the viewBackupFileToolStripMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void viewBackupFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.backupFilesList.SelectedItems.Count > 0)
     {
         BackupFileListViewItem bflvi = this.backupFilesList.SelectedItems[0] as BackupFileListViewItem;
         Process          proc        = new Process();
         ProcessStartInfo psi         = new ProcessStartInfo(CCNetConfig.Core.Util.UserSettings.ExternalViewer, string.Format(CCNetConfig.Core.Util.UserSettings.ExternalViewerArguments, bflvi.FileInfo.FullName));
         proc.StartInfo = psi;
         proc.Start();
     }
 }
Пример #3
0
 /// <summary>
 /// Handles the Click event of the deleteBackupFileToolStripMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 private void deleteBackupFileToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (backupFilesList.SelectedItems.Count > 0)
     {
         if (MessageBox.Show(this, Properties.Strings.ConfirmDeleteSelectedBackupsMessage, Properties.Strings.ConfirmDeleteBackupsTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             for (int x = 0; x < backupFilesList.SelectedItems.Count; x++)
             {
                 BackupFileListViewItem lvi = backupFilesList.SelectedItems[x] as BackupFileListViewItem;
                 try {
                     lvi.FileInfo.Delete();
                     this.backupFilesList.Items.Remove(lvi);
                 } catch { }
             }
         }
     }
 }