/// <summary>
        /// Save changes to the configuration
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            foreach (TreeViewItem item in tvPages.Items)
            {
                ISpellCheckerConfiguration page = (ISpellCheckerConfiguration)item.Tag;

                if (!page.SaveConfiguration())
                {
                    item.IsSelected = true;
                    return;
                }
            }

            if (!SpellCheckerConfiguration.SaveConfiguration())
            {
                MessageBox.Show("Unable to save spell checking configuration", PackageResources.PackageTitle,
                                MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }

            this.Close();
        }
Example #2
0
        //=====================================================================

        /// <summary>
        /// Validate the information and save the results if necessary when closing
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void UserPreferencesDlg_FormClosing(object sender, FormClosingEventArgs e)
        {
            ContentFileEditorCollection currentEditors;

            if (this.DialogResult == DialogResult.Cancel)
            {
                return;
            }

            string filePath = txtMSHelpViewerPath.Text.Trim();

            if (filePath.Length != 0)
            {
                txtMSHelpViewerPath.Text = filePath = Path.GetFullPath(filePath);

                if (!File.Exists(filePath))
                {
                    epErrors.SetError(btnSelectMSHCViewer, "The viewer application does not exist");
                    e.Cancel = true;
                }
            }

            if (!e.Cancel)
            {
                if (lblBuildExample.BackColor == lblBuildExample.ForeColor)
                {
                    lblBuildExample.BackColor = SystemColors.Window;
                    lblBuildExample.ForeColor = SystemColors.WindowText;
                }

                Settings.Default.MSHelpViewerPath      = txtMSHelpViewerPath.Text;
                Settings.Default.ASPNETDevServerPort   = (int)udcASPNetDevServerPort.Value;
                Settings.Default.PerUserProjectState   = chkPerUserProjectState.Checked;
                Settings.Default.BeforeBuild           = (BeforeBuildAction)cboBeforeBuildAction.SelectedIndex;
                Settings.Default.VerboseLogging        = chkVerboseLogging.Checked;
                Settings.Default.OpenHelpAfterBuild    = chkOpenHelp.Checked;
                Settings.Default.ShowLineNumbers       = chkShowLineNumbers.Checked;
                Settings.Default.EnterMatching         = chkEnterMatching.Checked;
                Settings.Default.BuildOutputBackground = lblBuildExample.BackColor;
                Settings.Default.BuildOutputForeground = lblBuildExample.ForeColor;
                Settings.Default.BuildOutputFont       = lblBuildExample.Font;
                Settings.Default.TextEditorFont        = lblEditorExample.Font;

                if (wasModified)
                {
                    currentEditors = Settings.Default.ContentFileEditors;
                    currentEditors.Clear();

                    for (int idx = 0; idx < lbContentEditors.Items.Count; idx++)
                    {
                        currentEditors.Add((ContentFileEditor)lbContentEditors.Items[idx]);
                    }

                    currentEditors.Sort();

                    ContentFileEditorCollection.GlobalEditors.Clear();
                    ContentFileEditorCollection.GlobalEditors.AddRange(currentEditors);
                }

                Settings.Default.Save();

                SpellCheckerConfiguration.DefaultLanguage = (CultureInfo)cboDefaultLanguage.SelectedItem;

                SpellCheckerConfiguration.IgnoreWordsWithDigits            = chkIgnoreWordsWithDigits.Checked;
                SpellCheckerConfiguration.IgnoreWordsInAllUppercase        = chkIgnoreAllUppercase.Checked;
                SpellCheckerConfiguration.IgnoreFilenamesAndEMailAddresses = chkIgnoreFilenamesAndEMail.Checked;
                SpellCheckerConfiguration.IgnoreXmlElementsInText          = chkIgnoreXmlInText.Checked;
                SpellCheckerConfiguration.TreatUnderscoreAsSeparator       = chkTreatUnderscoresAsSeparators.Checked;

                SpellCheckerConfiguration.SetIgnoredXmlElements(lbIgnoredXmlElements.Items.OfType <string>());
                SpellCheckerConfiguration.SetSpellCheckedXmlAttributes(lbSpellCheckedAttributes.Items.OfType <string>());

                if (!SpellCheckerConfiguration.SaveConfiguration())
                {
                    MessageBox.Show("Unable to save spell checking configuration", Constants.AppName,
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }