Esempio n. 1
0
        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;
            }
        }