private void tabControl1_Selected(object sender, TabControlEventArgs e) { if (e.TabPage == RecoveryOperations) { WindowState = FormWindowState.Maximized; webBrowser1.Url = new Uri("http://snapraid.sourceforge.net/manual.html#9", UriKind.Absolute); } else if (e.TabPage == coveragePage) { if (Properties.Settings.Default.ConfigFileIsValid) { try { ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation); cfg.Read(); List <string> displayLines = cfg.SnapShotSources; // Add the Parity lines to show the amount of drive space currently occupied by SnapRaid displayLines.Add(new FileInfo(cfg.ParityFile).DirectoryName); if (!string.IsNullOrEmpty(cfg.QParityFile)) { displayLines.Add(new FileInfo(cfg.QParityFile).DirectoryName); } driveSpace.StartProcessing(displayLines); } catch { } } } }
private void btnSave_Click(object sender, EventArgs e) { ConfigFileHelper cfg = new ConfigFileHelper(configFileLocation.Text) { IncludePatterns = IncludePatterns, BlockSizeKB = (uint)numBlockSizeKB.Value, Nohidden = advSettingsList[3].CheckState, AutoSaveGB = (uint)numAutoSaveGB.Value }; foreach (DataGridViewRow row in exludedFilesView.Rows) { string value = string.Format("{0}", row.Cells[0].Value); if (!string.IsNullOrWhiteSpace(value)) { cfg.ExcludePatterns.Add(value); } } foreach (string text in snapShotSourcesTreeView.Nodes.Cast <TreeNode>().Select(node => node.Text).Where(text => !string.IsNullOrWhiteSpace(text))) { cfg.SnapShotSources.Add(text); cfg.ContentFiles.Add(text); } string trim5 = raid5Location.Text.Trim(); if (!string.IsNullOrEmpty(trim5)) { cfg.ParityFile = trim5; FileInfo fi = new FileInfo(trim5); cfg.ContentFiles.Add(fi.DirectoryName); string trim6 = raid6Location.Text.Trim(); if (!string.IsNullOrEmpty(trim6)) { cfg.QParityFile = trim6; fi = new FileInfo(trim6); cfg.ContentFiles.Add(fi.DirectoryName); } } string writeResult; if (!string.IsNullOrEmpty(writeResult = cfg.Write())) { MessageBoxExt.Show(this, writeResult, "Config Write Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Properties.Settings.Default.ConfigFileIsValid = ValidateData(); Properties.Settings.Default.SnapRAIDFileLocation = snapRAIDFileLocation.Text; Properties.Settings.Default.ConfigFileLocation = configFileLocation.Text; Properties.Settings.Default.UseVerboseMode = advSettingsList[1].CheckState; Properties.Settings.Default.UseGUIMode = advSettingsList[2].CheckState; Properties.Settings.Default.FindByNameInSync = advSettingsList[3].CheckState; // http://elucidate.codeplex.com/workitem/10114 Properties.Settings.Default.HiddenFilesExcluded = advSettingsList[4].CheckState; Properties.Settings.Default.RunWithoutCapture = advSettingsList[0].CheckState; Properties.Settings.Default.Save(); UnsavedChangesMade = false; } }
//private void tabControl_Selected(object sender, TabControlEventArgs e) //{ // else if (e.TabPage == tabCoveragePage) // { // if (!Properties.Settings.Default.ConfigFileIsValid) return; // try // { // ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation); // cfg.Read(); // List<string> displayLines = cfg.SnapShotSources; // // Add the Parity lines to show the amount of drive space currently occupied by SnapRaid // displayLines.Add(new FileInfo(cfg.ParityFile1).DirectoryName); // if (!string.IsNullOrEmpty(cfg.ParityFile2)) // { // displayLines.Add(new FileInfo(cfg.ParityFile2).DirectoryName); // } // driveSpace.StartProcessing(displayLines); // } // catch // { // // ignored // } // } //} //private void tabControl_Deselected(object sender, TabControlEventArgs e) //{ // if (e.TabPage != RecoveryOperations) return; // if (WindowState == FormWindowState.Maximized) // { // WindowState = FormWindowState.Normal; // } //} private void btnRemoveOutput_Click(object sender, EventArgs e) { if (DialogResult.Yes != MessageBoxExt.Show(this, @"Are you sure you want to perform this task ?", "Remove SnapRAID Output files.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { return; } try { ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation); if (!cfg.Read()) { MessageBoxExt.Show(this, "Failed to read the config file.", "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FileInfo fi; if (!string.IsNullOrEmpty(cfg.ParityFile1)) { fi = new FileInfo(cfg.ParityFile1); if (fi.Exists) { fi.Delete(); } } if (!string.IsNullOrEmpty(cfg.ParityFile2)) { fi = new FileInfo(cfg.ParityFile2); if (fi.Exists) { fi.Delete(); } } if (cfg.ContentFiles == null) { return; } foreach (string contentFile in cfg.ContentFiles.Where(contentFile => !string.IsNullOrEmpty(contentFile))) { fi = new FileInfo(contentFile); if (fi.Exists) { fi.Delete(); } } } catch (Exception ex) { //ExceptionHandler.ReportException(ex, "btnRemoveOutput_Click has thrown: "); KryptonMessageBox.Show(this, ex.Message, @"Remove SnapRAID Output files."); } }
private void btnRemoveOutput_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBoxExt.Show(this, "Are you sure you want to perform this task ?", "Remove SnapRAID Output files.", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { try { ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation); string readResult; if (!string.IsNullOrEmpty(readResult = cfg.Read())) { MessageBoxExt.Show(this, readResult, "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { FileInfo fi; if (!string.IsNullOrEmpty(cfg.ParityFile)) { fi = new FileInfo(cfg.ParityFile); if (fi.Exists) { fi.Delete(); } } if (!string.IsNullOrEmpty(cfg.QParityFile)) { fi = new FileInfo(cfg.QParityFile); if (fi.Exists) { fi.Delete(); } } if (cfg.ContentFiles != null) { foreach (string contentFile in cfg.ContentFiles.Where(contentFile => !string.IsNullOrEmpty(contentFile))) { fi = new FileInfo(contentFile); if (fi.Exists) { fi.Delete(); } } } } } catch (Exception ex) { Log.Error(ex, "btnRemoveOutput_Click has thrown: "); MessageBox.Show(this, ex.Message, "Remove SnapRAID Output files."); } } }
private void ReadConfigDetails() { exludedFilesView.Rows.Clear(); snapShotSourcesTreeView.Nodes.Clear(); if (!File.Exists(configFileLocation.Text)) { if (Properties.Settings.Default.UseWindowsSettings) { exludedFilesView.Rows.Add(@"\$RECYCLE.BIN\"); exludedFilesView.Rows.Add(@"\System Volume Information\"); exludedFilesView.Rows.Add(@"*.bak"); exludedFilesView.Rows.Add(@"Thumbs.db"); } else { exludedFilesView.Rows.Add(@"*.bak"); exludedFilesView.Rows.Add(@"/lost+found/"); exludedFilesView.Rows.Add(@"/tmp/"); } } else { ConfigFileHelper cfg = new ConfigFileHelper(configFileLocation.Text); string readResult; if (!string.IsNullOrEmpty(readResult = cfg.Read())) { MessageBoxExt.Show(this, readResult, "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); } IncludePatterns = cfg.IncludePatterns; numBlockSizeKB.Value = cfg.BlockSizeKB; advSettingsList[3].CheckState = cfg.Nohidden; numAutoSaveGB.Value = cfg.AutoSaveGB; foreach (string excludePattern in cfg.ExcludePatterns.Where(excludePattern => !string.IsNullOrWhiteSpace(excludePattern))) { exludedFilesView.Rows.Add(excludePattern); } foreach (string source in cfg.SnapShotSources.Where(source => !string.IsNullOrWhiteSpace(source))) { snapShotSourcesTreeView.Nodes.Add(new TreeNode(source, 7, 7)); } raid5Location.Text = cfg.ParityFile; raid6Location.Text = cfg.QParityFile; } UnsavedChangesMade = false; driveSpace.StartProcessing((from TreeNode node in snapShotSourcesTreeView.Nodes select node.Text).ToList()); }
private void ElucidateForm_Shown(object sender, EventArgs e) { ConfigFileHelper cfg = new ConfigFileHelper(Properties.Settings.Default.ConfigFileLocation); if (!cfg.Read()) { MessageBoxExt.Show(this, "Failed to read the config file.", "Config Read Error:", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Properties.Settings.Default.ConfigFileIsValid = cfg.ConfigFileExists; EnableIfValid(Properties.Settings.Default.ConfigFileIsValid); if (!Properties.Settings.Default.ConfigFileIsValid) { // open the settings form since the config is not valid settingsToolStripMenuItem_Click(sender, e); } }