/// <summary> /// Convert the named property value to the appropriate selection state /// </summary> /// <param name="configuration">The configuration file from which to obtain the property value</param> /// <param name="propertyName">The name of the property to get</param> /// <returns>The selection state based on the specified property's value</returns> public static PropertyState ToPropertyState(this SpellingConfigurationFile configuration, string propertyName) { return(!configuration.HasProperty(propertyName) && configuration.ConfigurationType != ConfigurationType.Global ? PropertyState.Inherited : configuration.ToBoolean(propertyName) ? PropertyState.Yes : PropertyState.No); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { var dataSource = new List<PropertyState>(); if(configuration.ConfigurationType != ConfigurationType.Global) dataSource.AddRange(new[] { PropertyState.Inherited, PropertyState.Yes, PropertyState.No }); else dataSource.AddRange(new[] { PropertyState.Yes, PropertyState.No }); cboSpellCheckAsYouType.ItemsSource = cboIncludeInProjectSpellCheck.ItemsSource = cboDetectDoubledWords.ItemsSource = cboIgnoreWordsWithDigits.ItemsSource = cboIgnoreAllUppercase.ItemsSource = cboIgnoreFormatSpecifiers.ItemsSource = cboIgnoreFilenamesAndEMail.ItemsSource = cboIgnoreXmlInText.ItemsSource = cboTreatUnderscoresAsSeparators.ItemsSource = dataSource; cboSpellCheckAsYouType.SelectedValue = configuration.ToPropertyState( PropertyNames.SpellCheckAsYouType); cboIncludeInProjectSpellCheck.SelectedValue = configuration.ToPropertyState( PropertyNames.IncludeInProjectSpellCheck); cboDetectDoubledWords.SelectedValue = configuration.ToPropertyState( PropertyNames.DetectDoubledWords); cboIgnoreWordsWithDigits.SelectedValue = configuration.ToPropertyState( PropertyNames.IgnoreWordsWithDigits); cboIgnoreAllUppercase.SelectedValue = configuration.ToPropertyState( PropertyNames.IgnoreWordsInAllUppercase); cboIgnoreFormatSpecifiers.SelectedValue = configuration.ToPropertyState( PropertyNames.IgnoreFormatSpecifiers); cboIgnoreFilenamesAndEMail.SelectedValue = configuration.ToPropertyState( PropertyNames.IgnoreFilenamesAndEMailAddresses); cboIgnoreXmlInText.SelectedValue = configuration.ToPropertyState( PropertyNames.IgnoreXmlElementsInText); cboTreatUnderscoresAsSeparators.SelectedValue = configuration.ToPropertyState( PropertyNames.TreatUnderscoreAsSeparator); if(configuration.ConfigurationType != ConfigurationType.Global) spIncludeInProjectSpellCheck.Visibility = rbInheritIgnoredCharClass.Visibility = Visibility.Visible; else spIncludeInProjectSpellCheck.Visibility = rbInheritIgnoredCharClass.Visibility = Visibility.Collapsed; if(!configuration.HasProperty(PropertyNames.IgnoreCharacterClass) && configuration.ConfigurationType != ConfigurationType.Global) { rbInheritIgnoredCharClass.IsChecked = true; } else switch(configuration.ToEnum<IgnoredCharacterClass>(PropertyNames.IgnoreCharacterClass)) { case IgnoredCharacterClass.NonAscii: rbIgnoreNonAscii.IsChecked = true; break; case IgnoredCharacterClass.NonLatin: rbIgnoreNonLatin.IsChecked = true; break; default: rbIncludeAll.IsChecked = true; break; } }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet <string> newList = null; configuration.StoreProperty(PropertyNames.DetermineResourceFileLanguageFromName, ((PropertyState)cboDetermineResxLang.SelectedValue).ToPropertyValue()); configFilePath = Path.GetDirectoryName(configuration.Filename); isGlobal = configuration.ConfigurationType == ConfigurationType.Global; if (lbAdditionalFolders.Items.Count != 0) { newList = new HashSet <string>(lbAdditionalFolders.Items.OfType <string>(), StringComparer.OrdinalIgnoreCase); } if (!isGlobal) { configuration.StoreProperty(PropertyNames.InheritAdditionalDictionaryFolders, chkInheritAdditionalFolders.IsChecked); } configuration.StoreValues(PropertyNames.AdditionalDictionaryFolders, PropertyNames.AdditionalDictionaryFoldersItem, newList); if (cboDefaultLanguage.SelectedIndex == 0 && !isGlobal) { configuration.StoreProperty(PropertyNames.DefaultLanguage, null); } else { configuration.StoreProperty(PropertyNames.DefaultLanguage, ((SpellCheckerDictionary)cboDefaultLanguage.SelectedItem).Culture.Name); } }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { string displayText; lbExclusionExpressions.Items.Clear(); if(configuration.ConfigurationType == ConfigurationType.Global) { chkInheritExclusionExpressions.IsChecked = false; chkInheritExclusionExpressions.Visibility = Visibility.Collapsed; } else chkInheritExclusionExpressions.IsChecked = configuration.ToBoolean(PropertyNames.InheritExclusionExpressions); if(configuration.HasProperty(PropertyNames.ExclusionExpressions)) { expressions = configuration.ToRegexes(PropertyNames.ExclusionExpressions, PropertyNames.ExclusionExpressionItem).OrderBy(exp => exp.ToString()).ToList(); } else expressions = new List<Regex>(); foreach(var exp in expressions) { displayText = exp.ToString(); if(exp.Options != RegexOptions.None) displayText += " (" + exp.Options.ToString() + ")"; lbExclusionExpressions.Items.Add(displayText); } btnEditExpression.IsEnabled = btnRemoveExpression.IsEnabled = (expressions.Count != 0); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { configuration.StoreProperty(PropertyNames.SpellCheckAsYouType, ((PropertyState)cboSpellCheckAsYouType.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreWordsWithDigits, ((PropertyState)cboIgnoreWordsWithDigits.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreWordsInAllUppercase, ((PropertyState)cboIgnoreAllUppercase.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreFormatSpecifiers, ((PropertyState)cboIgnoreFormatSpecifiers.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreFilenamesAndEMailAddresses, ((PropertyState)cboIgnoreFilenamesAndEMail.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreXmlElementsInText, ((PropertyState)cboIgnoreXmlInText.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.TreatUnderscoreAsSeparator, ((PropertyState)cboTreatUnderscoresAsSeparators.SelectedValue).ToPropertyValue()); if (rbInheritIgnoredCharClass.IsChecked.Value) { configuration.StoreProperty(PropertyNames.IgnoreCharacterClass, null); } else { configuration.StoreProperty(PropertyNames.IgnoreCharacterClass, rbIncludeAll.IsChecked.Value ? IgnoredCharacterClass.None : rbIgnoreNonLatin.IsChecked.Value ? IgnoredCharacterClass.NonLatin : IgnoredCharacterClass.NonAscii); } }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { IEnumerable<string> words; lbIgnoredWords.Items.Clear(); if(configuration.ConfigurationType == ConfigurationType.Global) { chkInheritIgnoredWords.IsChecked = false; chkInheritIgnoredWords.Visibility = Visibility.Collapsed; } else chkInheritIgnoredWords.IsChecked = configuration.ToBoolean(PropertyNames.InheritIgnoredWords); if(configuration.HasProperty(PropertyNames.IgnoredWords)) words = configuration.ToValues(PropertyNames.IgnoredWords, PropertyNames.IgnoredWordsItem); else if(!chkInheritIgnoredWords.IsChecked.Value && configuration.ConfigurationType == ConfigurationType.Global) words = SpellCheckerConfiguration.DefaultIgnoredWords; else words = Enumerable.Empty<string>(); foreach(string el in words) lbIgnoredWords.Items.Add(el); var sd = new SortDescription { Direction = ListSortDirection.Ascending }; lbIgnoredWords.Items.SortDescriptions.Add(sd); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { configuration.StoreProperty(PropertyNames.CadOptionsImportCodeAnalysisDictionaries, ((PropertyState)cboImportCADictionaries.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatUnrecognizedWordsAsMisspelled, ((PropertyState)cboUnrecognizedWords.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatDeprecatedTermsAsMisspelled, ((PropertyState)cboDeprecatedTerms.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatCompoundTermsAsMisspelled, ((PropertyState)cboCompoundTerms.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatCasingExceptionsAsIgnoredWords, ((PropertyState)cboCasingExceptions.SelectedValue).ToPropertyValue()); if (rbInheritRecWordHandling.IsChecked.Value) { configuration.StoreProperty(PropertyNames.CadOptionsRecognizedWordHandling, null); } else { configuration.StoreProperty(PropertyNames.CadOptionsRecognizedWordHandling, rbNone.IsChecked.Value ? RecognizedWordHandling.None : rbIgnoreAll.IsChecked.Value ? RecognizedWordHandling.IgnoreAllWords : rbAddToDictionary.IsChecked.Value ? RecognizedWordHandling.AddAllWords : RecognizedWordHandling.AttributeDeterminesUsage); } }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet <string> newList = null; configFilePath = Path.GetDirectoryName(configuration.Filename); if (lbIgnoredWords.Items.Count != 0 || !chkInheritIgnoredWords.IsChecked.Value) { newList = new HashSet <string>(lbIgnoredWords.Items.Cast <string>(), StringComparer.OrdinalIgnoreCase); if (configuration.ConfigurationType == ConfigurationType.Global && newList.SetEquals(SpellCheckerConfiguration.DefaultIgnoredWords)) { newList = null; } } if (configuration.ConfigurationType != ConfigurationType.Global) { configuration.StoreProperty(PropertyNames.InheritIgnoredWords, chkInheritIgnoredWords.IsChecked); } configuration.StoreValues(PropertyNames.IgnoredWords, PropertyNames.IgnoredWordsItem, newList); configuration.StoreProperty(PropertyNames.IgnoredWordsFile, txtIgnoredWordsFile.Text.Trim()); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { var dataSource = new List<PropertyState>(); if(configuration.ConfigurationType != ConfigurationType.Global) dataSource.AddRange(new[] { PropertyState.Inherited, PropertyState.Yes, PropertyState.No }); else dataSource.AddRange(new[] { PropertyState.Yes, PropertyState.No }); cboIgnoreXmlDocComments.ItemsSource = cboIgnoreDelimitedComments.ItemsSource = cboIgnoreStandardSingleLineComments.ItemsSource = cboIgnoreQuadrupleSlashComments.ItemsSource = cboIgnoreNormalStrings.ItemsSource = cboIgnoreVerbatimStrings.ItemsSource = cboIgnoreInterpolatedStrings.ItemsSource = cboApplyToAllCStyleLanguages.ItemsSource = dataSource; cboIgnoreXmlDocComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreXmlDocComments); cboIgnoreDelimitedComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreDelimitedComments); cboIgnoreStandardSingleLineComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreStandardSingleLineComments); cboIgnoreQuadrupleSlashComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreQuadrupleSlashComments); cboIgnoreNormalStrings.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreNormalStrings); cboIgnoreVerbatimStrings.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreVerbatimStrings); cboIgnoreInterpolatedStrings.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreInterpolatedStrings); cboApplyToAllCStyleLanguages.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsApplyToAllCStyleLanguages); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet <string> newList = null; configuration.StoreProperty(PropertyNames.DetermineResourceFileLanguageFromName, ((PropertyState)cboDetermineResxLang.SelectedValue).ToPropertyValue()); relatedFilename = Path.GetFileNameWithoutExtension(configuration.Filename); configFilePath = Path.GetDirectoryName(configuration.Filename); isGlobal = configuration.ConfigurationType == ConfigurationType.Global; if (lbAdditionalFolders.Items.Count != 0) { newList = new HashSet <string>(lbAdditionalFolders.Items.Cast <string>(), StringComparer.OrdinalIgnoreCase); } if (!isGlobal) { configuration.StoreProperty(PropertyNames.InheritAdditionalDictionaryFolders, chkInheritAdditionalFolders.IsChecked); } configuration.StoreValues(PropertyNames.AdditionalDictionaryFolders, PropertyNames.AdditionalDictionaryFoldersItem, newList); configuration.StoreValues(PropertyNames.SelectedLanguages, PropertyNames.SelectedLanguagesItem, lbSelectedLanguages.Items.Cast <SpellCheckerDictionary>().Select(d => d.Culture.Name)); }
/// <summary> /// This is used to edit the global configuration file /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void SpellCheckerConfigurationExecuteHandler(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); string configFile = SpellingConfigurationFile.GlobalConfigurationFilename; // Convert the legacy configuration? if (Path.GetFileName(configFile).Equals("SpellChecker.config")) { string newConfigFile = Path.Combine(SpellingConfigurationFile.GlobalConfigurationFilePath, "VSSpellChecker.vsspell"); File.Copy(configFile, newConfigFile, true); File.Delete(configFile); configFile = newConfigFile; } // If it doesn't exist, create an empty file so that the editor can find it if (!File.Exists(configFile)) { var file = new SpellingConfigurationFile(configFile, null); file.Save(); } if (this.GetService(typeof(SDTE)) is DTE dte) { var doc = dte.ItemOperations.OpenFile(configFile, EnvDTE.Constants.vsViewKindPrimary); if (doc != null) { doc.Activate(); } } }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { var dataSource = new List <PropertyState>(); if (configuration.ConfigurationType != ConfigurationType.Global) { dataSource.AddRange(new[] { PropertyState.Inherited, PropertyState.Yes, PropertyState.No }); } else { dataSource.AddRange(new[] { PropertyState.Yes, PropertyState.No }); } cboIgnoreXmlDocComments.ItemsSource = cboIgnoreDelimitedComments.ItemsSource = cboIgnoreStandardSingleLineComments.ItemsSource = cboIgnoreQuadrupleSlashComments.ItemsSource = cboIgnoreNormalStrings.ItemsSource = cboIgnoreVerbatimStrings.ItemsSource = dataSource; cboIgnoreXmlDocComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreXmlDocComments); cboIgnoreDelimitedComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreDelimitedComments); cboIgnoreStandardSingleLineComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreStandardSingleLineComments); cboIgnoreQuadrupleSlashComments.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreQuadrupleSlashComments); cboIgnoreNormalStrings.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreNormalStrings); cboIgnoreVerbatimStrings.SelectedValue = configuration.ToPropertyState( PropertyNames.CSharpOptionsIgnoreVerbatimStrings); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { if (configuration.ConfigurationType != ConfigurationType.Global) { configuration.StoreProperty(PropertyNames.InheritExclusionExpressions, chkInheritExclusionExpressions.IsChecked); } configuration.StoreRegexes(PropertyNames.ExclusionExpressions, PropertyNames.ExclusionExpressionItem, expressions.Count == 0 ? null : expressions); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { isGlobal = configuration.ConfigurationType == ConfigurationType.Global; configFilePath = Path.GetDirectoryName(configuration.Filename); tbGlobal.Visibility = isGlobal ? Visibility.Visible : Visibility.Collapsed; tbOther.Visibility = !isGlobal ? Visibility.Visible : Visibility.Collapsed; txtImportSettingsFile.Text = configuration.ToString(PropertyNames.ImportSettingsFile); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { var dataSource = new List<PropertyState>(); if(configuration.ConfigurationType != ConfigurationType.Global) dataSource.AddRange(new[] { PropertyState.Inherited, PropertyState.Yes, PropertyState.No }); else dataSource.AddRange(new[] { PropertyState.Yes, PropertyState.No }); cboImportCADictionaries.ItemsSource = cboUnrecognizedWords.ItemsSource = cboDeprecatedTerms.ItemsSource = cboCompoundTerms.ItemsSource = cboCasingExceptions.ItemsSource = dataSource; cboImportCADictionaries.SelectedValue = configuration.ToPropertyState( PropertyNames.CadOptionsImportCodeAnalysisDictionaries); cboUnrecognizedWords.SelectedValue = configuration.ToPropertyState( PropertyNames.CadOptionsTreatUnrecognizedWordsAsMisspelled); cboDeprecatedTerms.SelectedValue = configuration.ToPropertyState( PropertyNames.CadOptionsTreatDeprecatedTermsAsMisspelled); cboCompoundTerms.SelectedValue = configuration.ToPropertyState( PropertyNames.CadOptionsTreatCompoundTermsAsMisspelled); cboCasingExceptions.SelectedValue = configuration.ToPropertyState( PropertyNames.CadOptionsTreatCasingExceptionsAsIgnoredWords); if(configuration.ConfigurationType != ConfigurationType.Global) rbInheritRecWordHandling.Visibility = Visibility.Visible; else rbInheritRecWordHandling.Visibility = Visibility.Collapsed; if(!configuration.HasProperty(PropertyNames.CadOptionsRecognizedWordHandling) && configuration.ConfigurationType != ConfigurationType.Global) { rbInheritRecWordHandling.IsChecked = true; } else switch(configuration.ToEnum<RecognizedWordHandling>(PropertyNames.CadOptionsRecognizedWordHandling)) { case RecognizedWordHandling.IgnoreAllWords: rbIgnoreAll.IsChecked = true; break; case RecognizedWordHandling.AddAllWords: rbAddToDictionary.IsChecked = true; break; case RecognizedWordHandling.AttributeDeterminesUsage: rbAttributeDetermines.IsChecked = true; break; default: rbNone.IsChecked = true; break; } }
//===================================================================== /// <summary> /// This is used to load the configuration file to edit /// </summary> /// <param name="configurationFile">The configuration filename</param> public void LoadConfiguration(string configurationFile) { configFile = new SpellingConfigurationFile(configurationFile, null); this.SetTitle(); foreach (TreeViewItem item in tvPages.Items) { ((ISpellCheckerConfiguration)item.Tag).LoadConfiguration(configFile); } }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { tbGlobal.Visibility = fdvAddConfigs.Visibility = (configuration.ConfigurationType == ConfigurationType.Global) ? Visibility.Visible : Visibility.Collapsed; tbSolution.Visibility = (configuration.ConfigurationType == ConfigurationType.Solution) ? Visibility.Visible : Visibility.Collapsed; tbProject.Visibility = (configuration.ConfigurationType == ConfigurationType.Project) ? Visibility.Visible : Visibility.Collapsed; tbFolder.Visibility = (configuration.ConfigurationType == ConfigurationType.Folder) ? Visibility.Visible : Visibility.Collapsed; tbFile.Visibility = (configuration.ConfigurationType == ConfigurationType.File) ? Visibility.Visible : Visibility.Collapsed; }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { configFilePath = Path.GetDirectoryName(configuration.Filename); string filename = txtImportSettingsFile.Text.Trim(); if (filename.Length == 0) { filename = null; } configuration.StoreProperty(PropertyNames.ImportSettingsFile, filename); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { IEnumerable <string> words; lbIgnoredWords.Items.Clear(); configFilePath = Path.GetDirectoryName(configuration.Filename); if (configuration.ConfigurationType == ConfigurationType.Global) { chkInheritIgnoredWords.IsChecked = false; chkInheritIgnoredWords.Visibility = Visibility.Collapsed; } else { chkInheritIgnoredWords.IsChecked = configuration.ToBoolean(PropertyNames.InheritIgnoredWords); } txtIgnoredWordsFile.Text = configuration.ToString(PropertyNames.IgnoredWordsFile); if (String.IsNullOrWhiteSpace(txtIgnoredWordsFile.Text) && configuration.ConfigurationType == ConfigurationType.Global) { txtIgnoredWordsFile.Text = "IgnoredWords.dic"; } if (configuration.HasProperty(PropertyNames.IgnoredWords)) { words = configuration.ToValues(PropertyNames.IgnoredWords, PropertyNames.IgnoredWordsItem); } else if (!chkInheritIgnoredWords.IsChecked.Value && configuration.ConfigurationType == ConfigurationType.Global) { words = SpellCheckerConfiguration.DefaultIgnoredWords; } else { words = Enumerable.Empty <string>(); } foreach (string el in words) { lbIgnoredWords.Items.Add(el); } var sd = new SortDescription { Direction = ListSortDirection.Ascending }; lbIgnoredWords.Items.SortDescriptions.Add(sd); }
/// <summary> /// Reset the configuration for the current page or the whole file to the default settings excluding the /// user dictionary. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnReset_Click(object sender, RoutedEventArgs e) { var result = MessageBox.Show("Do you want to reset the entire configuration or just this page? " + "Click YES to reset the whole configuration, NO to reset just this page, or CANCEL to do neither.", PackageResources.PackageTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); if (result == MessageBoxResult.Cancel) { return; } // Pass a dummy filename to create a new configuration and then set the filename so that the pages // know the type of configuration file in use. var newConfigFile = new SpellingConfigurationFile("__ResetTemp__", new SpellCheckerConfiguration()) { Filename = configFile.Filename }; if (result == MessageBoxResult.Yes) { if (MessageBox.Show("Are you sure you want to reset the configuration to its default settings " + "(excluding the user dictionary)?", PackageResources.PackageTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { foreach (TreeViewItem item in tvPages.Items) { ISpellCheckerConfiguration page = (ISpellCheckerConfiguration)item.Tag; if (page.AppliesTo(configFile.ConfigurationType)) { page.LoadConfiguration(newConfigFile); } } this.OnConfigurationChanged(sender, e); } } else { TreeViewItem item = (TreeViewItem)tvPages.SelectedItem; if (item != null) { ((ISpellCheckerConfiguration)item.Tag).LoadConfiguration(newConfigFile); this.OnConfigurationChanged(sender, e); } } }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreXmlDocComments, ((PropertyState)cboIgnoreXmlDocComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreDelimitedComments, ((PropertyState)cboIgnoreDelimitedComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreStandardSingleLineComments, ((PropertyState)cboIgnoreStandardSingleLineComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreQuadrupleSlashComments, ((PropertyState)cboIgnoreQuadrupleSlashComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreNormalStrings, ((PropertyState)cboIgnoreNormalStrings.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreVerbatimStrings, ((PropertyState)cboIgnoreVerbatimStrings.SelectedValue).ToPropertyValue()); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet <string> newList = null; if (lbExcludedExtensions.Items.Count != 0) { newList = new HashSet <string>(lbExcludedExtensions.Items.OfType <string>(), StringComparer.OrdinalIgnoreCase); } if (configuration.ConfigurationType != ConfigurationType.Global) { configuration.StoreProperty(PropertyNames.InheritExcludedExtensions, chkInheritExcludedExtensions.IsChecked); } configuration.StoreValues(PropertyNames.ExcludedExtensions, PropertyNames.ExcludedExtensionsItem, newList); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { string displayText; lbExclusionExpressions.Items.Clear(); // Will be null if resetting to default ID list if (configuration != null) { if (!this.AppliesTo(configuration.ConfigurationType)) { return; } chkEnableWpfTextBoxSpellChecking.IsChecked = configuration.ToBoolean(PropertyNames.EnableWpfTextBoxSpellChecking); if (configuration.HasProperty(PropertyNames.VisualStudioIdExclusions)) { expressions = configuration.ToRegexes(PropertyNames.VisualStudioIdExclusions, PropertyNames.VisualStudioIdExclusionItem).OrderBy(exp => exp.ToString()).ToList(); } else { expressions = new List <Regex>(SpellCheckerConfiguration.DefaultVisualStudioExclusions.Select( p => new Regex(p))); } } foreach (var exp in expressions) { displayText = exp.ToString(); if (exp.Options != RegexOptions.None) { displayText += " (" + exp.Options.ToString() + ")"; } lbExclusionExpressions.Items.Add(displayText); } btnEditExpression.IsEnabled = btnRemoveExpression.IsEnabled = (expressions.Count != 0); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { if (configuration.ConfigurationType != ConfigurationType.Global) { configuration.StoreProperty(PropertyNames.InheritIgnoredClassifications, chkInheritIgnoredClassifications.IsChecked); } var ignoredClassifications = new XElement(PropertyNames.IgnoredClassifications); foreach (var g in visualStudioItems.Where(v => v.IsSelected).Concat(solutionSpellCheckItems.Where( s => s.IsSelected)).GroupBy(c => c.ContentType)) { ignoredClassifications.Add( new XElement(PropertyNames.ContentType, new XAttribute(PropertyNames.ContentTypeName, g.Key), g.Select(c => new XElement(PropertyNames.Classification, c.Classification)))); } configuration.StoreElement(ignoredClassifications); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet <string> newElementList = null, newAttributeList = null; if (lbIgnoredXmlElements.Items.Count != 0 || !chkInheritXmlSettings.IsChecked.Value) { newElementList = new HashSet <string>(lbIgnoredXmlElements.Items.Cast <string>()); if (configuration.ConfigurationType == ConfigurationType.Global && newElementList.SetEquals(SpellCheckerConfiguration.DefaultIgnoredXmlElements)) { newElementList = null; } } if (lbSpellCheckedAttributes.Items.Count != 0 || !chkInheritXmlSettings.IsChecked.Value) { newAttributeList = new HashSet <string>(lbSpellCheckedAttributes.Items.Cast <string>()); if (configuration.ConfigurationType == ConfigurationType.Global && newAttributeList.SetEquals(SpellCheckerConfiguration.DefaultSpellCheckedAttributes)) { newAttributeList = null; } } if (configuration.ConfigurationType != ConfigurationType.Global) { configuration.StoreProperty(PropertyNames.InheritXmlSettings, chkInheritXmlSettings.IsChecked); } configuration.StoreValues(PropertyNames.IgnoredXmlElements, PropertyNames.IgnoredXmlElementsItem, newElementList); configuration.StoreValues(PropertyNames.SpellCheckedXmlAttributes, PropertyNames.SpellCheckedXmlAttributesItem, newAttributeList); configuration.StoreProperty(PropertyNames.IgnoreHtmlComments, ((PropertyState)cboIgnoreHtmlComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreXmlComments, ((PropertyState)cboIgnoreXmlComments.SelectedValue).ToPropertyValue()); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { IEnumerable <string> patterns; lbIgnoredFilePatterns.Items.Clear(); if (configuration.ConfigurationType == ConfigurationType.Global) { chkInheritIgnoredFilePatterns.IsChecked = false; chkInheritIgnoredFilePatterns.Visibility = Visibility.Collapsed; } else { chkInheritIgnoredFilePatterns.IsChecked = configuration.ToBoolean(PropertyNames.InheritIgnoredFilePatterns); } if (configuration.HasProperty(PropertyNames.IgnoredFilePatterns)) { patterns = configuration.ToValues(PropertyNames.IgnoredFilePatterns, PropertyNames.IgnoredFilePatternItem); } else if (!chkInheritIgnoredFilePatterns.IsChecked.Value && configuration.ConfigurationType == ConfigurationType.Global) { patterns = SpellCheckerConfiguration.DefaultIgnoredFilePatterns; } else { patterns = Enumerable.Empty <string>(); } foreach (string el in patterns) { lbIgnoredFilePatterns.Items.Add(el); } var sd = new SortDescription { Direction = ListSortDirection.Ascending }; lbIgnoredFilePatterns.Items.SortDescriptions.Add(sd); }
//===================================================================== /// <summary> /// This is used to load the configuration file to edit /// </summary> /// <param name="configurationFile">The configuration filename</param> public void LoadConfiguration(string configurationFile) { configFile = new SpellingConfigurationFile(configurationFile, null); this.SetTitle(); foreach (TreeViewItem item in tvPages.Items) { ISpellCheckerConfiguration page = ((ISpellCheckerConfiguration)item.Tag); if (page.AppliesTo(configFile.ConfigurationType)) { item.Visibility = Visibility.Visible; page.LoadConfiguration(configFile); } else { item.Visibility = Visibility.Collapsed; } } }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { if (this.AppliesTo(configuration.ConfigurationType)) { configuration.StoreProperty(PropertyNames.EnableWpfTextBoxSpellChecking, chkEnableWpfTextBoxSpellChecking.IsChecked); var newList = new HashSet <string>(lbExclusionExpressions.Items.Cast <string>(), StringComparer.OrdinalIgnoreCase); if (newList.SetEquals(SpellCheckerConfiguration.DefaultVisualStudioExclusions)) { configuration.StoreRegexes(PropertyNames.VisualStudioIdExclusions, PropertyNames.VisualStudioIdExclusionItem, null); } else { configuration.StoreRegexes(PropertyNames.VisualStudioIdExclusions, PropertyNames.VisualStudioIdExclusionItem, expressions.Count == 0 ? null : expressions); } } }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { string displayText; lbExclusionExpressions.Items.Clear(); if (configuration.ConfigurationType == ConfigurationType.Global) { chkInheritExclusionExpressions.IsChecked = false; chkInheritExclusionExpressions.Visibility = Visibility.Collapsed; } else { chkInheritExclusionExpressions.IsChecked = configuration.ToBoolean(PropertyNames.InheritExclusionExpressions); } if (configuration.HasProperty(PropertyNames.ExclusionExpressions)) { expressions = configuration.ToRegexes(PropertyNames.ExclusionExpressions, PropertyNames.ExclusionExpressionItem).OrderBy(exp => exp.ToString()).ToList(); } else { expressions = new List <Regex>(); } foreach (var exp in expressions) { displayText = exp.ToString(); if (exp.Options != RegexOptions.None) { displayText += " (" + exp.Options.ToString() + ")"; } lbExclusionExpressions.Items.Add(displayText); } btnEditExpression.IsEnabled = btnRemoveExpression.IsEnabled = (expressions.Count != 0); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet <string> newList = null; if (lbIgnoredFilePatterns.Items.Count != 0 || !chkInheritIgnoredFilePatterns.IsChecked.Value) { newList = new HashSet <string>(lbIgnoredFilePatterns.Items.Cast <string>(), StringComparer.OrdinalIgnoreCase); if (configuration.ConfigurationType == ConfigurationType.Global && newList.SetEquals(SpellCheckerConfiguration.DefaultIgnoredFilePatterns)) { newList = null; } } if (configuration.ConfigurationType != ConfigurationType.Global) { configuration.StoreProperty(PropertyNames.InheritIgnoredFilePatterns, chkInheritIgnoredFilePatterns.IsChecked); } configuration.StoreValues(PropertyNames.IgnoredFilePatterns, PropertyNames.IgnoredFilePatternItem, newList); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { IEnumerable <string> words; lbExcludedExtensions.Items.Clear(); if (configuration.ConfigurationType == ConfigurationType.Global) { chkInheritExcludedExtensions.IsChecked = false; chkInheritExcludedExtensions.Visibility = Visibility.Collapsed; } else { chkInheritExcludedExtensions.IsChecked = configuration.ToBoolean(PropertyNames.InheritExcludedExtensions); } if (configuration.HasProperty(PropertyNames.ExcludedExtensions)) { words = configuration.ToValues(PropertyNames.ExcludedExtensions, PropertyNames.ExcludedExtensionsItem); } else { words = Enumerable.Empty <string>(); } foreach (string el in words) { lbExcludedExtensions.Items.Add(el); } var sd = new SortDescription { Direction = ListSortDirection.Ascending }; lbExcludedExtensions.Items.SortDescriptions.Add(sd); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet<string> newList = null; if(lbIgnoredWords.Items.Count != 0 || !chkInheritIgnoredWords.IsChecked.Value) { newList = new HashSet<string>(lbIgnoredWords.Items.OfType<string>(), StringComparer.OrdinalIgnoreCase); if(configuration.ConfigurationType == ConfigurationType.Global && newList.SetEquals(SpellCheckerConfiguration.DefaultIgnoredWords)) newList = null; } if(configuration.ConfigurationType != ConfigurationType.Global) configuration.StoreProperty(PropertyNames.InheritIgnoredWords, chkInheritIgnoredWords.IsChecked); configuration.StoreValues(PropertyNames.IgnoredWords, PropertyNames.IgnoredWordsItem, newList); }
/// <summary> /// Add a spell checker configuration file based on the currently selected solution/project item /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void AddSpellCheckerConfigExecuteHandler(object sender, EventArgs e) { Project containingProject; string settingsFilename; try { if (DetermineContainingProjectAndSettingsFile(out containingProject, out settingsFilename)) { var dte2 = Utility.GetServiceFromPackage <DTE2, SDTE>(true); if (dte2 != null) { // Don't add it again if it's already there, just open it var existingItem = dte2.Solution.FindProjectItem(settingsFilename); if (existingItem == null) { var newConfigFile = new SpellingConfigurationFile(settingsFilename, null); newConfigFile.Save(); if (containingProject != null) { // If file settings, add them as a dependency if possible if (!settingsFilename.StartsWith(containingProject.FullName, StringComparison.OrdinalIgnoreCase)) { existingItem = dte2.Solution.FindProjectItem(Path.GetFileNameWithoutExtension(settingsFilename)); if (existingItem != null && existingItem.ProjectItems != null) { existingItem = existingItem.ProjectItems.AddFromFile(settingsFilename); } else { existingItem = containingProject.ProjectItems.AddFromFile(settingsFilename); } } else { existingItem = containingProject.ProjectItems.AddFromFile(settingsFilename); } } else { // Add solution settings file var siProject = dte2.Solution.Projects.Cast <Project>().FirstOrDefault( p => p.Name == "Solution Items"); if (siProject == null) { siProject = ((Solution2)dte2.Solution).AddSolutionFolder("Solution Items"); } existingItem = siProject.ProjectItems.AddFromFile(settingsFilename); } } if (existingItem != null) { var window = existingItem.Open(); if (window != null) { window.Activate(); } } } } } catch (Exception ex) { // Ignore on error but report it Utility.ShowMessageBox(OLEMSGICON.OLEMSGICON_CRITICAL, "Unable to add spell checker " + "configuration file. Reason: {0}", ex.Message); } }
//===================================================================== /// <summary> /// Load the configuration from the given file /// </summary> /// <param name="filename">The configuration file to load</param> /// <remarks>Any properties not in the configuration file retain their current values. If the file does /// not exist, the configuration will remain unchanged.</remarks> public void Load(string filename) { HashSet<string> tempHashSet; try { // Nothing to do if the file doesn't exist if(!File.Exists(filename)) return; var configuration = new SpellingConfigurationFile(filename, this); this.DefaultLanguage = configuration.ToCultureInfo(PropertyNames.DefaultLanguage); this.SpellCheckAsYouType = configuration.ToBoolean(PropertyNames.SpellCheckAsYouType); this.IgnoreWordsWithDigits = configuration.ToBoolean(PropertyNames.IgnoreWordsWithDigits); this.IgnoreWordsInAllUppercase = configuration.ToBoolean(PropertyNames.IgnoreWordsInAllUppercase); this.IgnoreFormatSpecifiers = configuration.ToBoolean(PropertyNames.IgnoreFormatSpecifiers); this.IgnoreFilenamesAndEMailAddresses = configuration.ToBoolean( PropertyNames.IgnoreFilenamesAndEMailAddresses); this.IgnoreXmlElementsInText = configuration.ToBoolean(PropertyNames.IgnoreXmlElementsInText); this.TreatUnderscoreAsSeparator = configuration.ToBoolean(PropertyNames.TreatUnderscoreAsSeparator); this.IgnoreCharacterClass = configuration.ToEnum<IgnoredCharacterClass>( PropertyNames.IgnoreCharacterClass); this.DetermineResourceFileLanguageFromName = configuration.ToBoolean( PropertyNames.DetermineResourceFileLanguageFromName); csharpOptions.IgnoreXmlDocComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreXmlDocComments); csharpOptions.IgnoreDelimitedComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreDelimitedComments); csharpOptions.IgnoreStandardSingleLineComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreStandardSingleLineComments); csharpOptions.IgnoreQuadrupleSlashComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreQuadrupleSlashComments); csharpOptions.IgnoreNormalStrings = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreNormalStrings); csharpOptions.IgnoreVerbatimStrings = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreVerbatimStrings); csharpOptions.IgnoreInterpolatedStrings = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreInterpolatedStrings); cadOptions.ImportCodeAnalysisDictionaries = configuration.ToBoolean( PropertyNames.CadOptionsImportCodeAnalysisDictionaries); cadOptions.RecognizedWordHandling = configuration.ToEnum<RecognizedWordHandling>( PropertyNames.CadOptionsRecognizedWordHandling); cadOptions.TreatUnrecognizedWordsAsMisspelled = configuration.ToBoolean( PropertyNames.CadOptionsTreatUnrecognizedWordsAsMisspelled); cadOptions.TreatDeprecatedTermsAsMisspelled = configuration.ToBoolean( PropertyNames.CadOptionsTreatDeprecatedTermsAsMisspelled); cadOptions.TreatCompoundTermsAsMisspelled = configuration.ToBoolean( PropertyNames.CadOptionsTreatCompoundTermsAsMisspelled); cadOptions.TreatCasingExceptionsAsIgnoredWords = configuration.ToBoolean( PropertyNames.CadOptionsTreatCasingExceptionsAsIgnoredWords); this.InheritExcludedExtensions = configuration.ToBoolean(PropertyNames.InheritExcludedExtensions); if(configuration.HasProperty(PropertyNames.ExcludedExtensions)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.ExcludedExtensions, PropertyNames.ExcludedExtensionsItem), StringComparer.OrdinalIgnoreCase); if(this.InheritExcludedExtensions) { if(tempHashSet.Count != 0) foreach(string ext in tempHashSet) excludedExtensions.Add(ext); } else excludedExtensions = tempHashSet; } this.InheritAdditionalDictionaryFolders = configuration.ToBoolean( PropertyNames.InheritAdditionalDictionaryFolders); if(configuration.HasProperty(PropertyNames.AdditionalDictionaryFolders)) { tempHashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach(string folder in configuration.ToValues(PropertyNames.AdditionalDictionaryFolders, PropertyNames.AdditionalDictionaryFoldersItem)) { // Fully qualify relative paths with the configuration file path if(Path.IsPathRooted(folder)) tempHashSet.Add(folder); else tempHashSet.Add(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(filename), folder))); } if(this.InheritAdditionalDictionaryFolders) { if(tempHashSet.Count != 0) foreach(string folder in tempHashSet) additionalDictionaryFolders.Add(folder); } else additionalDictionaryFolders = tempHashSet.ToList(); } this.InheritIgnoredWords = configuration.ToBoolean(PropertyNames.InheritIgnoredWords); if(configuration.HasProperty(PropertyNames.IgnoredWords)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.IgnoredWords, PropertyNames.IgnoredWordsItem), StringComparer.OrdinalIgnoreCase); if(this.InheritIgnoredWords) { if(tempHashSet.Count != 0) foreach(string word in tempHashSet) ignoredWords.Add(word); } else ignoredWords = tempHashSet; } this.InheritXmlSettings = configuration.ToBoolean(PropertyNames.InheritXmlSettings); if(configuration.HasProperty(PropertyNames.IgnoredXmlElements)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.IgnoredXmlElements, PropertyNames.IgnoredXmlElementsItem)); if(this.InheritXmlSettings) { if(tempHashSet.Count != 0) foreach(string element in tempHashSet) ignoredXmlElements.Add(element); } else ignoredXmlElements = tempHashSet; } if(configuration.HasProperty(PropertyNames.SpellCheckedXmlAttributes)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.SpellCheckedXmlAttributes, PropertyNames.SpellCheckedXmlAttributesItem)); if(this.InheritXmlSettings) { if(tempHashSet.Count != 0) foreach(string attr in tempHashSet) spellCheckedXmlAttributes.Add(attr); } else spellCheckedXmlAttributes = tempHashSet; } } catch(Exception ex) { // Ignore errors and just use the defaults System.Diagnostics.Debug.WriteLine(ex); } }
/// <summary> /// Reset the configuration for the current page or the whole file to the default settings excluding the /// user dictionary. /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnReset_Click(object sender, RoutedEventArgs e) { var result = MessageBox.Show("Do you want to reset the entire configuration or just this page? " + "Click YES to reset the whole configuration, NO to reset just this page, or CANCEL to do neither.", PackageResources.PackageTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Question, MessageBoxResult.Cancel); if(result == MessageBoxResult.Cancel) return; // Pass a dummy filename to create a new configuration and then set the filename so that the pages // know the type of configuration file in use. var newConfigFile = new SpellingConfigurationFile("__ResetTemp__", new SpellCheckerConfiguration()); newConfigFile.Filename = configFile.Filename; if(result == MessageBoxResult.Yes) { if(MessageBox.Show("Are you sure you want to reset the configuration to its default settings " + "(excluding the user dictionary)?", PackageResources.PackageTitle, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { foreach(TreeViewItem item in tvPages.Items) ((ISpellCheckerConfiguration)item.Tag).LoadConfiguration(newConfigFile); this.OnConfigurationChanged(sender, e); } } else { TreeViewItem item = (TreeViewItem)tvPages.SelectedItem; if(item != null) { ((ISpellCheckerConfiguration)item.Tag).LoadConfiguration(newConfigFile); this.OnConfigurationChanged(sender, e); } } }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { IEnumerable<string> folders; cboAvailableLanguages.ItemsSource = null; lbAdditionalFolders.Items.Clear(); lbSelectedLanguages.Items.Clear(); var dataSource = new List<PropertyState>(); if(configuration.ConfigurationType != ConfigurationType.Global) dataSource.AddRange(new[] { PropertyState.Inherited, PropertyState.Yes, PropertyState.No }); else dataSource.AddRange(new[] { PropertyState.Yes, PropertyState.No }); cboDetermineResxLang.ItemsSource = dataSource; cboDetermineResxLang.SelectedValue = configuration.ToPropertyState( PropertyNames.DetermineResourceFileLanguageFromName); configType = configuration.ConfigurationType; relatedFilename = Path.GetFileNameWithoutExtension(configuration.Filename); configFilePath = Path.GetDirectoryName(configuration.Filename); isGlobal = configuration.ConfigurationType == ConfigurationType.Global; if(isGlobal) { chkInheritAdditionalFolders.IsChecked = false; chkInheritAdditionalFolders.Visibility = Visibility.Collapsed; } else chkInheritAdditionalFolders.IsChecked = configuration.ToBoolean( PropertyNames.InheritAdditionalDictionaryFolders); if(configuration.HasProperty(PropertyNames.AdditionalDictionaryFolders)) { folders = configuration.ToValues(PropertyNames.AdditionalDictionaryFolders, PropertyNames.AdditionalDictionaryFoldersItem); } else folders = Enumerable.Empty<string>(); foreach(string f in folders) lbAdditionalFolders.Items.Add(f); var sd = new SortDescription { Direction = ListSortDirection.Ascending }; lbAdditionalFolders.Items.SortDescriptions.Add(sd); selectedLanguages.Clear(); selectedLanguages.AddRange(configuration.ToValues(PropertyNames.SelectedLanguages, PropertyNames.SelectedLanguagesItem, true).Distinct(StringComparer.OrdinalIgnoreCase)); this.LoadAvailableLanguages(); }
//===================================================================== /// <summary> /// Load the configuration from the given file /// </summary> /// <param name="filename">The configuration file to load</param> /// <remarks>Any properties not in the configuration file retain their current values. If the file does /// not exist, the configuration will remain unchanged.</remarks> public void Load(string filename) { HashSet<string> tempHashSet; try { // Nothing to do if the file doesn't exist if(!File.Exists(filename)) return; var configuration = new SpellingConfigurationFile(filename, this); this.SpellCheckAsYouType = configuration.ToBoolean(PropertyNames.SpellCheckAsYouType); // This option is always true for the global configuration if(configuration.ConfigurationType != ConfigurationType.Global) this.IncludeInProjectSpellCheck = configuration.ToBoolean(PropertyNames.IncludeInProjectSpellCheck); this.DetectDoubledWords = configuration.ToBoolean(PropertyNames.DetectDoubledWords); this.IgnoreWordsWithDigits = configuration.ToBoolean(PropertyNames.IgnoreWordsWithDigits); this.IgnoreWordsInAllUppercase = configuration.ToBoolean(PropertyNames.IgnoreWordsInAllUppercase); this.IgnoreFormatSpecifiers = configuration.ToBoolean(PropertyNames.IgnoreFormatSpecifiers); this.IgnoreFilenamesAndEMailAddresses = configuration.ToBoolean( PropertyNames.IgnoreFilenamesAndEMailAddresses); this.IgnoreXmlElementsInText = configuration.ToBoolean(PropertyNames.IgnoreXmlElementsInText); this.TreatUnderscoreAsSeparator = configuration.ToBoolean(PropertyNames.TreatUnderscoreAsSeparator); this.IgnoreMnemonics = configuration.ToBoolean(PropertyNames.IgnoreMnemonics); this.IgnoreCharacterClass = configuration.ToEnum<IgnoredCharacterClass>( PropertyNames.IgnoreCharacterClass); this.DetermineResourceFileLanguageFromName = configuration.ToBoolean( PropertyNames.DetermineResourceFileLanguageFromName); csharpOptions.IgnoreXmlDocComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreXmlDocComments); csharpOptions.IgnoreDelimitedComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreDelimitedComments); csharpOptions.IgnoreStandardSingleLineComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreStandardSingleLineComments); csharpOptions.IgnoreQuadrupleSlashComments = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreQuadrupleSlashComments); csharpOptions.IgnoreNormalStrings = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreNormalStrings); csharpOptions.IgnoreVerbatimStrings = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreVerbatimStrings); csharpOptions.IgnoreInterpolatedStrings = configuration.ToBoolean( PropertyNames.CSharpOptionsIgnoreInterpolatedStrings); csharpOptions.ApplyToAllCStyleLanguages = configuration.ToBoolean( PropertyNames.CSharpOptionsApplyToAllCStyleLanguages); cadOptions.ImportCodeAnalysisDictionaries = configuration.ToBoolean( PropertyNames.CadOptionsImportCodeAnalysisDictionaries); cadOptions.RecognizedWordHandling = configuration.ToEnum<RecognizedWordHandling>( PropertyNames.CadOptionsRecognizedWordHandling); cadOptions.TreatUnrecognizedWordsAsMisspelled = configuration.ToBoolean( PropertyNames.CadOptionsTreatUnrecognizedWordsAsMisspelled); cadOptions.TreatDeprecatedTermsAsMisspelled = configuration.ToBoolean( PropertyNames.CadOptionsTreatDeprecatedTermsAsMisspelled); cadOptions.TreatCompoundTermsAsMisspelled = configuration.ToBoolean( PropertyNames.CadOptionsTreatCompoundTermsAsMisspelled); cadOptions.TreatCasingExceptionsAsIgnoredWords = configuration.ToBoolean( PropertyNames.CadOptionsTreatCasingExceptionsAsIgnoredWords); this.InheritExcludedExtensions = configuration.ToBoolean(PropertyNames.InheritExcludedExtensions); if(configuration.HasProperty(PropertyNames.ExcludedExtensions)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.ExcludedExtensions, PropertyNames.ExcludedExtensionsItem), StringComparer.OrdinalIgnoreCase); if(this.InheritExcludedExtensions) { if(tempHashSet.Count != 0) foreach(string ext in tempHashSet) excludedExtensions.Add(ext); } else excludedExtensions = tempHashSet; } this.InheritAdditionalDictionaryFolders = configuration.ToBoolean( PropertyNames.InheritAdditionalDictionaryFolders); if(configuration.HasProperty(PropertyNames.AdditionalDictionaryFolders)) { tempHashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach(string folder in configuration.ToValues(PropertyNames.AdditionalDictionaryFolders, PropertyNames.AdditionalDictionaryFoldersItem)) { // Fully qualify relative paths with the configuration file path if(folder.IndexOf('%') != -1 || Path.IsPathRooted(folder)) tempHashSet.Add(folder); else tempHashSet.Add(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(filename), folder))); } if(this.InheritAdditionalDictionaryFolders) { if(tempHashSet.Count != 0) foreach(string folder in tempHashSet) additionalDictionaryFolders.Add(folder); } else additionalDictionaryFolders = tempHashSet.ToList(); } this.InheritIgnoredWords = configuration.ToBoolean(PropertyNames.InheritIgnoredWords); if(configuration.HasProperty(PropertyNames.IgnoredWords)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.IgnoredWords, PropertyNames.IgnoredWordsItem), StringComparer.OrdinalIgnoreCase); if(this.InheritIgnoredWords) { if(tempHashSet.Count != 0) foreach(string word in tempHashSet) ignoredWords.Add(word); } else ignoredWords = tempHashSet; } this.InheritExclusionExpressions = configuration.ToBoolean(PropertyNames.InheritExclusionExpressions); if(configuration.HasProperty(PropertyNames.ExclusionExpressions)) { var tempList = new List<Regex>(configuration.ToRegexes(PropertyNames.ExclusionExpressions, PropertyNames.ExclusionExpressionItem)); if(this.InheritExclusionExpressions) { if(tempList.Count != 0) { tempHashSet = new HashSet<string>(exclusionExpressions.Select(r => r.ToString())); foreach(Regex exp in tempList) if(!tempHashSet.Contains(exp.ToString())) { exclusionExpressions.Add(exp); tempHashSet.Add(exp.ToString()); } } } else exclusionExpressions = tempList; } this.InheritXmlSettings = configuration.ToBoolean(PropertyNames.InheritXmlSettings); if(configuration.HasProperty(PropertyNames.IgnoredXmlElements)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.IgnoredXmlElements, PropertyNames.IgnoredXmlElementsItem)); if(this.InheritXmlSettings) { if(tempHashSet.Count != 0) foreach(string element in tempHashSet) ignoredXmlElements.Add(element); } else ignoredXmlElements = tempHashSet; } if(configuration.HasProperty(PropertyNames.SpellCheckedXmlAttributes)) { tempHashSet = new HashSet<string>(configuration.ToValues(PropertyNames.SpellCheckedXmlAttributes, PropertyNames.SpellCheckedXmlAttributesItem)); if(this.InheritXmlSettings) { if(tempHashSet.Count != 0) foreach(string attr in tempHashSet) spellCheckedXmlAttributes.Add(attr); } else spellCheckedXmlAttributes = tempHashSet; } // Load the dictionary languages and, if merging settings, handle inheritance if(configuration.HasProperty(PropertyNames.SelectedLanguages)) { var languages = configuration.ToValues(PropertyNames.SelectedLanguages, PropertyNames.SelectedLanguagesItem, true).Distinct(StringComparer.OrdinalIgnoreCase).ToList(); // Is there a blank entry that marks the inherited languages placeholder? int idx = languages.IndexOf(String.Empty); if(idx != -1) { languages.RemoveAt(idx); // If there are other languages, insert the inherited languages at the desired location. // If an inherited language matches a language in the configuration file, it is left at // its new location this overriding the inherited language location. if(languages.Count != 0) foreach(var lang in dictionaryLanguages) if(!languages.Contains(lang.Name)) { languages.Insert(idx, lang.Name); idx++; } } if(languages.Count != 0) dictionaryLanguages = languages.Select(l => new CultureInfo(l)).ToList(); } } catch(Exception ex) { // Ignore errors and just use the defaults System.Diagnostics.Debug.WriteLine(ex); } finally { // Always ensure we have at least the default language if none are specified in the global // configuration file. if(dictionaryLanguages.Count == 0) dictionaryLanguages.Add(new CultureInfo("en-US")); } }
//===================================================================== /// <summary> /// This is used to load the configuration file to edit /// </summary> /// <param name="configurationFile">The configuration filename</param> public void LoadConfiguration(string configurationFile) { configFile = new SpellingConfigurationFile(configurationFile, null); this.SetTitle(); foreach(TreeViewItem item in tvPages.Items) ((ISpellCheckerConfiguration)item.Tag).LoadConfiguration(configFile); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet<string> newElementList = null, newAttributeList = null; if(lbIgnoredXmlElements.Items.Count != 0 || !chkInheritXmlSettings.IsChecked.Value) { newElementList = new HashSet<string>(lbIgnoredXmlElements.Items.OfType<string>()); if(configuration.ConfigurationType == ConfigurationType.Global && newElementList.SetEquals(SpellCheckerConfiguration.DefaultIgnoredXmlElements)) newElementList = null; } if(lbSpellCheckedAttributes.Items.Count != 0 || !chkInheritXmlSettings.IsChecked.Value) { newAttributeList = new HashSet<string>(lbSpellCheckedAttributes.Items.OfType<string>()); if(configuration.ConfigurationType == ConfigurationType.Global && newAttributeList.SetEquals(SpellCheckerConfiguration.DefaultSpellCheckedAttributes)) newAttributeList = null; } if(configuration.ConfigurationType != ConfigurationType.Global) configuration.StoreProperty(PropertyNames.InheritXmlSettings, chkInheritXmlSettings.IsChecked); configuration.StoreValues(PropertyNames.IgnoredXmlElements, PropertyNames.IgnoredXmlElementsItem, newElementList); configuration.StoreValues(PropertyNames.SpellCheckedXmlAttributes, PropertyNames.SpellCheckedXmlAttributesItem, newAttributeList); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { IEnumerable <string> folders; cboAvailableLanguages.ItemsSource = null; lbAdditionalFolders.Items.Clear(); lbSelectedLanguages.Items.Clear(); var dataSource = new List <PropertyState>(); if (configuration.ConfigurationType != ConfigurationType.Global) { dataSource.AddRange(new[] { PropertyState.Inherited, PropertyState.Yes, PropertyState.No }); } else { dataSource.AddRange(new[] { PropertyState.Yes, PropertyState.No }); } cboDetermineResxLang.ItemsSource = dataSource; cboDetermineResxLang.SelectedValue = configuration.ToPropertyState( PropertyNames.DetermineResourceFileLanguageFromName); configType = configuration.ConfigurationType; relatedFilename = Path.GetFileNameWithoutExtension(configuration.Filename); configFilePath = Path.GetDirectoryName(configuration.Filename); isGlobal = configuration.ConfigurationType == ConfigurationType.Global; if (isGlobal) { chkInheritAdditionalFolders.IsChecked = false; chkInheritAdditionalFolders.Visibility = Visibility.Collapsed; } else { chkInheritAdditionalFolders.IsChecked = configuration.ToBoolean( PropertyNames.InheritAdditionalDictionaryFolders); } if (configuration.HasProperty(PropertyNames.AdditionalDictionaryFolders)) { folders = configuration.ToValues(PropertyNames.AdditionalDictionaryFolders, PropertyNames.AdditionalDictionaryFoldersItem); } else { folders = Enumerable.Empty <string>(); } foreach (string f in folders) { lbAdditionalFolders.Items.Add(f); } var sd = new SortDescription { Direction = ListSortDirection.Ascending }; lbAdditionalFolders.Items.SortDescriptions.Add(sd); selectedLanguages.Clear(); selectedLanguages.AddRange(configuration.ToValues(PropertyNames.SelectedLanguages, PropertyNames.SelectedLanguagesItem, true).Distinct(StringComparer.OrdinalIgnoreCase)); #pragma warning disable VSTHRD010 this.LoadAvailableLanguages(); #pragma warning restore VSTHRD010 }
/// <summary> /// Add a spell checker configuration file based on the currently selected solution/project item /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void AddSpellCheckerConfigExecuteHandler(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); try { if (DetermineContainingProjectAndSettingsFile(out Project containingProject, out string settingsFilename)) { if (this.GetService(typeof(SDTE)) is DTE2 dte2) { // Don't add it again if it's already there, just open it var existingItem = dte2.Solution.FindProjectItemForFile(settingsFilename); if (existingItem == null) { var newConfigFile = new SpellingConfigurationFile(settingsFilename, null); newConfigFile.Save(); if (containingProject != null) { // If file settings, add them as a dependency if possible if (!settingsFilename.StartsWith(containingProject.FullName, StringComparison.OrdinalIgnoreCase)) { existingItem = dte2.Solution.FindProjectItemForFile( Path.GetFileNameWithoutExtension(settingsFilename)); if (existingItem != null && existingItem.ProjectItems != null) { existingItem = existingItem.ProjectItems.AddFromFile(settingsFilename); } else { existingItem = containingProject.ProjectItems.AddFromFile(settingsFilename); } } else { existingItem = containingProject.ProjectItems.AddFromFile(settingsFilename); } } else { #pragma warning disable VSTHRD010 // Add solution settings file. Don't enumerate projects to find an existing copy // of the folder. It's not a project so it won't be found that way. Just search // the project collection. It'll be at the root level if it exists. var siProject = dte2.Solution.Projects.Cast <Project>().FirstOrDefault( p => p.Name == "Solution Items"); #pragma warning restore VSTHRD010 if (siProject == null) { siProject = ((Solution2)dte2.Solution).AddSolutionFolder("Solution Items"); } existingItem = siProject.ProjectItems.AddFromFile(settingsFilename); } } if (existingItem != null) { try { var window = existingItem.Open(); if (window != null) { window.Activate(); } } catch (Exception ex) { // Sometimes this isn't implemented for some reason. The file does get added and // can be opened manually. if (ex.HResult != VSConstants.E_NOTIMPL) { throw; } } } } } } catch (Exception ex) { // Ignore on error but report it System.Diagnostics.Debug.WriteLine(ex); VsShellUtilities.ShowMessageBox(this, $"Unable to add spell checker configuration file: {ex.Message}", Resources.PackageTitle, OLEMSGICON.OLEMSGICON_CRITICAL, OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); } }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { configuration.StoreProperty(PropertyNames.CadOptionsImportCodeAnalysisDictionaries, ((PropertyState)cboImportCADictionaries.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatUnrecognizedWordsAsMisspelled, ((PropertyState)cboUnrecognizedWords.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatDeprecatedTermsAsMisspelled, ((PropertyState)cboDeprecatedTerms.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatCompoundTermsAsMisspelled, ((PropertyState)cboCompoundTerms.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CadOptionsTreatCasingExceptionsAsIgnoredWords, ((PropertyState)cboCasingExceptions.SelectedValue).ToPropertyValue()); if(rbInheritRecWordHandling.IsChecked.Value) configuration.StoreProperty(PropertyNames.CadOptionsRecognizedWordHandling, null); else configuration.StoreProperty(PropertyNames.CadOptionsRecognizedWordHandling, rbNone.IsChecked.Value ? RecognizedWordHandling.None : rbIgnoreAll.IsChecked.Value ? RecognizedWordHandling.IgnoreAllWords : rbAddToDictionary.IsChecked.Value ? RecognizedWordHandling.AddAllWords : RecognizedWordHandling.AttributeDeterminesUsage); }
/// <summary> /// Add a spell checker configuration file based on the currently selected solution/project item /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void AddSpellCheckerConfigExecuteHandler(object sender, EventArgs e) { Project containingProject; string settingsFilename; try { if(DetermineContainingProjectAndSettingsFile(out containingProject, out settingsFilename)) { var dte2 = Utility.GetServiceFromPackage<DTE2, SDTE>(true); if(dte2 != null) { // Don't add it again if it's already there, just open it var existingItem = dte2.Solution.FindProjectItem(settingsFilename); if(existingItem == null) { var newConfigFile = new SpellingConfigurationFile(settingsFilename, null); newConfigFile.Save(); if(containingProject != null) { // If file settings, add them as a dependency if possible if(!settingsFilename.StartsWith(containingProject.FullName, StringComparison.OrdinalIgnoreCase)) { existingItem = dte2.Solution.FindProjectItem(Path.GetFileNameWithoutExtension(settingsFilename)); if(existingItem != null && existingItem.ProjectItems != null) existingItem = existingItem.ProjectItems.AddFromFile(settingsFilename); else existingItem = containingProject.ProjectItems.AddFromFile(settingsFilename); } else existingItem = containingProject.ProjectItems.AddFromFile(settingsFilename); } else { // Add solution settings file. Don't enumerate projects to find an existing copy // of the folder. It's not a project so it won't be found that way. Just search // the project collection. It'll be at the root level if it exists. var siProject = dte2.Solution.Projects.Cast<Project>().FirstOrDefault( p => p.Name == "Solution Items"); if(siProject == null) siProject = ((Solution2)dte2.Solution).AddSolutionFolder("Solution Items"); existingItem = siProject.ProjectItems.AddFromFile(settingsFilename); } } if(existingItem != null) { var window = existingItem.Open(); if(window != null) window.Activate(); } } } } catch(Exception ex) { // Ignore on error but report it Utility.ShowMessageBox(OLEMSGICON.OLEMSGICON_CRITICAL, "Unable to add spell checker " + "configuration file. Reason: {0}", ex.Message); } }
/// <summary> /// This is used to edit the global configuration file /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void SpellCheckerConfigurationExecuteHandler(object sender, EventArgs e) { string configFile = SpellingConfigurationFile.GlobalConfigurationFilename; // Convert the legacy configuration? if(Path.GetFileName(configFile).Equals("SpellChecker.config")) { string newConfigFile = Path.Combine(SpellingConfigurationFile.GlobalConfigurationFilePath, "VSSpellChecker.vsspell"); File.Copy(configFile, newConfigFile, true); File.Delete(configFile); configFile = newConfigFile; } // If it doesn't exist, create an empty file so that the editor can find it if(!File.Exists(configFile)) { var file = new SpellingConfigurationFile(configFile, null); file.Save(); } var dte = Utility.GetServiceFromPackage<DTE, SDTE>(true); if(dte != null) { var doc = dte.ItemOperations.OpenFile(configFile, EnvDTE.Constants.vsViewKindPrimary); if(doc != null) doc.Activate(); } }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { // Nothing to save here, just refresh the information this.LoadConfiguration(configuration); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreXmlDocComments, ((PropertyState)cboIgnoreXmlDocComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreDelimitedComments, ((PropertyState)cboIgnoreDelimitedComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreStandardSingleLineComments, ((PropertyState)cboIgnoreStandardSingleLineComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreQuadrupleSlashComments, ((PropertyState)cboIgnoreQuadrupleSlashComments.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreNormalStrings, ((PropertyState)cboIgnoreNormalStrings.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreVerbatimStrings, ((PropertyState)cboIgnoreVerbatimStrings.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsIgnoreInterpolatedStrings, ((PropertyState)cboIgnoreInterpolatedStrings.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.CSharpOptionsApplyToAllCStyleLanguages, ((PropertyState)cboApplyToAllCStyleLanguages.SelectedValue).ToPropertyValue()); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { configuration.StoreProperty(PropertyNames.SpellCheckAsYouType, ((PropertyState)cboSpellCheckAsYouType.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IncludeInProjectSpellCheck, ((PropertyState)cboIncludeInProjectSpellCheck.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.DetectDoubledWords, ((PropertyState)cboDetectDoubledWords.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreWordsWithDigits, ((PropertyState)cboIgnoreWordsWithDigits.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreWordsInAllUppercase, ((PropertyState)cboIgnoreAllUppercase.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreFormatSpecifiers, ((PropertyState)cboIgnoreFormatSpecifiers.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreFilenamesAndEMailAddresses, ((PropertyState)cboIgnoreFilenamesAndEMail.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreXmlElementsInText, ((PropertyState)cboIgnoreXmlInText.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.TreatUnderscoreAsSeparator, ((PropertyState)cboTreatUnderscoresAsSeparators.SelectedValue).ToPropertyValue()); configuration.StoreProperty(PropertyNames.IgnoreMnemonics, ((PropertyState)cboIgnoreMnemonics.SelectedValue).ToPropertyValue()); if(rbInheritIgnoredCharClass.IsChecked.Value) configuration.StoreProperty(PropertyNames.IgnoreCharacterClass, null); else configuration.StoreProperty(PropertyNames.IgnoreCharacterClass, rbIncludeAll.IsChecked.Value ? IgnoredCharacterClass.None : rbIgnoreNonLatin.IsChecked.Value ? IgnoredCharacterClass.NonLatin : IgnoredCharacterClass.NonAscii); }
/// <inheritdoc /> public void LoadConfiguration(SpellingConfigurationFile configuration) { IEnumerable <string> words; lbIgnoredXmlElements.Items.Clear(); lbSpellCheckedAttributes.Items.Clear(); if (configuration.ConfigurationType == ConfigurationType.Global) { chkInheritXmlSettings.IsChecked = false; chkInheritXmlSettings.Visibility = Visibility.Collapsed; } else { chkInheritXmlSettings.IsChecked = configuration.ToBoolean(PropertyNames.InheritXmlSettings); } if (configuration.HasProperty(PropertyNames.IgnoredXmlElements)) { words = configuration.ToValues(PropertyNames.IgnoredXmlElements, PropertyNames.IgnoredXmlElementsItem); } else if (!chkInheritXmlSettings.IsChecked.Value && configuration.ConfigurationType == ConfigurationType.Global) { words = SpellCheckerConfiguration.DefaultIgnoredXmlElements; } else { words = Enumerable.Empty <string>(); } foreach (string el in words) { lbIgnoredXmlElements.Items.Add(el); } if (configuration.HasProperty(PropertyNames.SpellCheckedXmlAttributes)) { words = configuration.ToValues(PropertyNames.SpellCheckedXmlAttributes, PropertyNames.SpellCheckedXmlAttributesItem); } else if (!chkInheritXmlSettings.IsChecked.Value && configuration.ConfigurationType == ConfigurationType.Global) { words = SpellCheckerConfiguration.DefaultSpellCheckedAttributes; } else { words = Enumerable.Empty <string>(); } foreach (string el in words) { lbSpellCheckedAttributes.Items.Add(el); } var sd = new SortDescription { Direction = ListSortDirection.Ascending }; lbIgnoredXmlElements.Items.SortDescriptions.Add(sd); lbSpellCheckedAttributes.Items.SortDescriptions.Add(sd); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet<string> newList = null; if(lbExcludedExtensions.Items.Count != 0) newList = new HashSet<string>(lbExcludedExtensions.Items.OfType<string>(), StringComparer.OrdinalIgnoreCase); if(configuration.ConfigurationType != ConfigurationType.Global) configuration.StoreProperty(PropertyNames.InheritExcludedExtensions, chkInheritExcludedExtensions.IsChecked); configuration.StoreValues(PropertyNames.ExcludedExtensions, PropertyNames.ExcludedExtensionsItem, newList); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { if(configuration.ConfigurationType != ConfigurationType.Global) configuration.StoreProperty(PropertyNames.InheritExclusionExpressions, chkInheritExclusionExpressions.IsChecked); configuration.StoreRegexes(PropertyNames.ExclusionExpressions, PropertyNames.ExclusionExpressionItem, expressions.Count == 0 ? null : expressions); }
/// <inheritdoc /> public void SaveConfiguration(SpellingConfigurationFile configuration) { HashSet<string> newList = null; configuration.StoreProperty(PropertyNames.DetermineResourceFileLanguageFromName, ((PropertyState)cboDetermineResxLang.SelectedValue).ToPropertyValue()); relatedFilename = Path.GetFileNameWithoutExtension(configuration.Filename); configFilePath = Path.GetDirectoryName(configuration.Filename); isGlobal = configuration.ConfigurationType == ConfigurationType.Global; if(lbAdditionalFolders.Items.Count != 0) newList = new HashSet<string>(lbAdditionalFolders.Items.OfType<string>(), StringComparer.OrdinalIgnoreCase); if(!isGlobal) configuration.StoreProperty(PropertyNames.InheritAdditionalDictionaryFolders, chkInheritAdditionalFolders.IsChecked); configuration.StoreValues(PropertyNames.AdditionalDictionaryFolders, PropertyNames.AdditionalDictionaryFoldersItem, newList); configuration.StoreValues(PropertyNames.SelectedLanguages, PropertyNames.SelectedLanguagesItem, lbSelectedLanguages.Items.OfType<SpellCheckerDictionary>().Select(d => d.Culture.Name)); }