/// <summary> /// /// </summary> /// <returns></returns> internal FileBackup.FileBackupConfig Save() { FileBackup.FileBackupConfig config = new FileBackup.FileBackupConfig(); if (string.IsNullOrEmpty(tbDirectory.Text)) { throw new Exception("You must specify a directory to backup"); } config.Directory = tbDirectory.Text; config.BackupType = (BackupTypes)cbBackupType.SelectedItem; foreach (ListViewItem li in lvFileTypes.Items) { config.Filetypes.Add(li.Text); } config.CompressFiles = cbCompress.Checked; if (config.CompressFiles) { if (string.IsNullOrEmpty(tbZipFilename.Text)) { throw new Exception("You have to specify a name for the zip-file"); } if (string.IsNullOrEmpty(tbLocalTempDir.Text)) { throw new Exception("You have to specify a local temp-directory"); } config.LocalTempDirectory = tbLocalTempDir.Text; config.ZipFilename = tbZipFilename.Text; config.AddDateToFilename = cbAddDateToZip.Checked; } return(config); }
/// <summary> /// Initializes a new instance of the <b>FileBackupConfigGUI</b> class. /// </summary> /// <param name="config"></param> public FileBackupConfigGUI(FileBackup.FileBackupConfig config) { InitializeComponent(); conf = config ?? new FileBackup.FileBackupConfig(); tbDirectory.Text = conf.Directory; cbCompress.Checked = conf.CompressFiles; tbZipFilename.Visible = cbCompress.Checked; cbAddDateToZip.Visible = cbCompress.Checked; label6.Visible = cbCompress.Checked; label7.Visible = cbCompress.Checked; label5.Visible = cbCompress.Checked; tbLocalTempDir.Visible = cbCompress.Checked; btnBrowseForLocalTemp.Visible = cbCompress.Checked; if (cbCompress.Checked) { tbZipFilename.Text = conf.ZipFilename; cbAddDateToZip.Checked = conf.AddDateToFilename; tbLocalTempDir.Text = conf.LocalTempDirectory; } cbBackupType.Items.Add(BackupTypes.ModifiedOnly); cbBackupType.Items.Add(BackupTypes.All); cbBackupType.SelectedIndex = conf.BackupType == BackupTypes.All ? 1 : 0; foreach (string ft in conf.Filetypes) { lvFileTypes.Items.Add(ft); } lvFileTypes.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); }