Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / SpellCheck.cs / 1305600 / SpellCheck.cs
//---------------------------------------------------------------------------- // // File: SpellCheck.cs // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: Speller properties for TextBoxBase. // //--------------------------------------------------------------------------- namespace System.Windows.Controls { using System.Threading; using System.Windows.Documents; using System.Windows.Controls.Primitives; using System.ComponentModel; using System.Collections.Generic; using System.Collections; using System.Windows.Markup; ////// Speller properties for TextBoxBase. /// public sealed class SpellCheck { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors // Ctor. internal SpellCheck(TextBoxBase owner) { _owner = owner; } #endregion Constructors //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- #region Public Properties ////// Enables and disables spell checking within the associated TextBoxBase. /// ////// Defaults to false. /// public bool IsEnabled { get { return (bool)_owner.GetValue(IsEnabledProperty); } set { _owner.SetValue(IsEnabledProperty, value); } } ////// Enables and disables spell checking within a TextBoxBase. /// public static void SetIsEnabled(TextBoxBase textBoxBase, bool value) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } textBoxBase.SetValue(IsEnabledProperty, value); } ////// Gets if spell checking is enabled within a TextBoxBase. /// public static bool GetIsEnabled(TextBoxBase textBoxBase) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } return (bool)textBoxBase.GetValue(IsEnabledProperty); } ////// Enables and disables spell checking within the associated TextBoxBase. /// ////// Defaults to false. /// public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached( "IsEnabled", typeof(bool), typeof(SpellCheck), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnIsEnabledChanged))); ////// The spelling reform mode for the associated TextBoxBase. /// ////// In languages with reformed spelling rules (such as German or French), /// this property specifies whether to apply old (prereform) or new /// (postreform) spelling rules to examined text. /// public SpellingReform SpellingReform { get { return (SpellingReform)_owner.GetValue(SpellingReformProperty); } set { _owner.SetValue(SpellingReformProperty, value); } } ////// Sets the spelling reform mode for a TextBoxBase. /// public static void SetSpellingReform(TextBoxBase textBoxBase, SpellingReform value) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } textBoxBase.SetValue(SpellingReformProperty, value); } ////// The spelling reform mode for the associated TextBoxBase. /// ////// In languages with reformed spelling rules (such as German or French), /// this property specifies whether to apply old (prereform) or new /// (postreform) spelling rules to examined text. /// public static readonly DependencyProperty SpellingReformProperty = DependencyProperty.RegisterAttached( "SpellingReform", typeof(SpellingReform), typeof(SpellCheck), new FrameworkPropertyMetadata(Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName == "de" ? SpellingReform.Postreform : SpellingReform.PreAndPostreform, new PropertyChangedCallback(OnSpellingReformChanged))); ////// Custom dictionary locations /// public IList CustomDictionaries { get { return (IList)_owner.GetValue(CustomDictionariesProperty); } } ////// Gets the collection of custom dictionaries used for spell checking of custom words. /// /// ///public static IList GetCustomDictionaries(TextBoxBase textBoxBase) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } return (IList)textBoxBase.GetValue(CustomDictionariesProperty); } private static readonly DependencyPropertyKey CustomDictionariesPropertyKey = DependencyProperty.RegisterAttachedReadOnly( "CustomDictionaries", typeof(IList), typeof(SpellCheck), new FrameworkPropertyMetadata(new DictionaryCollectionFactory())); /// /// Attached property representing location of custom dicitonaries for given public static readonly DependencyProperty CustomDictionariesProperty = CustomDictionariesPropertyKey.DependencyProperty; #endregion Public Properties //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods // Callback for changes to the IsEnabled property. private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TextBoxBase textBoxBase = d as TextBoxBase; if (textBoxBase != null) { TextEditor textEditor = TextEditor._GetTextEditor(textBoxBase); if (textEditor != null) { textEditor.SetSpellCheckEnabled((bool)e.NewValue); if ((bool)e.NewValue != (bool)e.OldValue) { textEditor.SetCustomDictionaries((bool)e.NewValue); } } } } // SpellingReformProperty change callback. private static void OnSpellingReformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TextBoxBase textBoxBase = d as TextBoxBase; if (textBoxBase != null) { TextEditor textEditor = TextEditor._GetTextEditor(textBoxBase); if (textEditor != null) { textEditor.SetSpellingReform((SpellingReform)e.NewValue); } } } #endregion Private Methods //----------------------------------------------------- // // Internal Types // //------------------------------------------------------ internal class DictionaryCollectionFactory : MS.Internal.DefaultValueFactory { internal DictionaryCollectionFactory() { } internal override object DefaultValue { get { return null; } } internal override object CreateDefaultValue(DependencyObject owner, DependencyProperty property) { return new CustomDictionarySources(owner as TextBoxBase); } } //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Fields // TextBoxBase mapped to this object. private readonly TextBoxBase _owner; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // File: SpellCheck.cs // // Copyright (C) Microsoft Corporation. All rights reserved. // // Description: Speller properties for TextBoxBase. // //--------------------------------------------------------------------------- namespace System.Windows.Controls { using System.Threading; using System.Windows.Documents; using System.Windows.Controls.Primitives; using System.ComponentModel; using System.Collections.Generic; using System.Collections; using System.Windows.Markup; ////// /// Speller properties for TextBoxBase. /// public sealed class SpellCheck { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors // Ctor. internal SpellCheck(TextBoxBase owner) { _owner = owner; } #endregion Constructors //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- #region Public Properties ////// Enables and disables spell checking within the associated TextBoxBase. /// ////// Defaults to false. /// public bool IsEnabled { get { return (bool)_owner.GetValue(IsEnabledProperty); } set { _owner.SetValue(IsEnabledProperty, value); } } ////// Enables and disables spell checking within a TextBoxBase. /// public static void SetIsEnabled(TextBoxBase textBoxBase, bool value) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } textBoxBase.SetValue(IsEnabledProperty, value); } ////// Gets if spell checking is enabled within a TextBoxBase. /// public static bool GetIsEnabled(TextBoxBase textBoxBase) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } return (bool)textBoxBase.GetValue(IsEnabledProperty); } ////// Enables and disables spell checking within the associated TextBoxBase. /// ////// Defaults to false. /// public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached( "IsEnabled", typeof(bool), typeof(SpellCheck), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnIsEnabledChanged))); ////// The spelling reform mode for the associated TextBoxBase. /// ////// In languages with reformed spelling rules (such as German or French), /// this property specifies whether to apply old (prereform) or new /// (postreform) spelling rules to examined text. /// public SpellingReform SpellingReform { get { return (SpellingReform)_owner.GetValue(SpellingReformProperty); } set { _owner.SetValue(SpellingReformProperty, value); } } ////// Sets the spelling reform mode for a TextBoxBase. /// public static void SetSpellingReform(TextBoxBase textBoxBase, SpellingReform value) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } textBoxBase.SetValue(SpellingReformProperty, value); } ////// The spelling reform mode for the associated TextBoxBase. /// ////// In languages with reformed spelling rules (such as German or French), /// this property specifies whether to apply old (prereform) or new /// (postreform) spelling rules to examined text. /// public static readonly DependencyProperty SpellingReformProperty = DependencyProperty.RegisterAttached( "SpellingReform", typeof(SpellingReform), typeof(SpellCheck), new FrameworkPropertyMetadata(Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName == "de" ? SpellingReform.Postreform : SpellingReform.PreAndPostreform, new PropertyChangedCallback(OnSpellingReformChanged))); ////// Custom dictionary locations /// public IList CustomDictionaries { get { return (IList)_owner.GetValue(CustomDictionariesProperty); } } ////// Gets the collection of custom dictionaries used for spell checking of custom words. /// /// ///public static IList GetCustomDictionaries(TextBoxBase textBoxBase) { if (textBoxBase == null) { throw new ArgumentNullException("textBoxBase"); } return (IList)textBoxBase.GetValue(CustomDictionariesProperty); } private static readonly DependencyPropertyKey CustomDictionariesPropertyKey = DependencyProperty.RegisterAttachedReadOnly( "CustomDictionaries", typeof(IList), typeof(SpellCheck), new FrameworkPropertyMetadata(new DictionaryCollectionFactory())); /// /// Attached property representing location of custom dicitonaries for given public static readonly DependencyProperty CustomDictionariesProperty = CustomDictionariesPropertyKey.DependencyProperty; #endregion Public Properties //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods // Callback for changes to the IsEnabled property. private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TextBoxBase textBoxBase = d as TextBoxBase; if (textBoxBase != null) { TextEditor textEditor = TextEditor._GetTextEditor(textBoxBase); if (textEditor != null) { textEditor.SetSpellCheckEnabled((bool)e.NewValue); if ((bool)e.NewValue != (bool)e.OldValue) { textEditor.SetCustomDictionaries((bool)e.NewValue); } } } } // SpellingReformProperty change callback. private static void OnSpellingReformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { TextBoxBase textBoxBase = d as TextBoxBase; if (textBoxBase != null) { TextEditor textEditor = TextEditor._GetTextEditor(textBoxBase); if (textEditor != null) { textEditor.SetSpellingReform((SpellingReform)e.NewValue); } } } #endregion Private Methods //----------------------------------------------------- // // Internal Types // //------------------------------------------------------ internal class DictionaryCollectionFactory : MS.Internal.DefaultValueFactory { internal DictionaryCollectionFactory() { } internal override object DefaultValue { get { return null; } } internal override object CreateDefaultValue(DependencyObject owner, DependencyProperty property) { return new CustomDictionarySources(owner as TextBoxBase); } } //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Fields // TextBoxBase mapped to this object. private readonly TextBoxBase _owner; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CounterCreationData.cs
- ImportOptions.cs
- IPPacketInformation.cs
- TransformCryptoHandle.cs
- DesignTimeTemplateParser.cs
- XMLDiffLoader.cs
- SpeechEvent.cs
- MasterPageCodeDomTreeGenerator.cs
- GradientStopCollection.cs
- ToolboxItemWrapper.cs
- IOException.cs
- ObjectResult.cs
- MarkerProperties.cs
- WindowsImpersonationContext.cs
- ClassHandlersStore.cs
- SafeThemeHandle.cs
- SpecularMaterial.cs
- IisTraceWebEventProvider.cs
- ADMembershipUser.cs
- HtmlInputRadioButton.cs
- PersistencePipeline.cs
- ControllableStoryboardAction.cs
- oledbmetadatacolumnnames.cs
- CreateUserErrorEventArgs.cs
- InternalConfigRoot.cs
- UndoManager.cs
- Range.cs
- Keywords.cs
- RowVisual.cs
- PiiTraceSource.cs
- DataGridViewCellStyleChangedEventArgs.cs
- WebPart.cs
- AuthenticationManager.cs
- GridViewUpdateEventArgs.cs
- EventMappingSettingsCollection.cs
- ListViewItem.cs
- Opcode.cs
- BrowserDefinition.cs
- HtmlWindow.cs
- FileDialogCustomPlacesCollection.cs
- UTF32Encoding.cs
- MultiTouchSystemGestureLogic.cs
- InternalBase.cs
- SchemaNames.cs
- CssTextWriter.cs
- DataPointer.cs
- CharacterMetrics.cs
- BindingExpression.cs
- SearchExpression.cs
- RegexStringValidator.cs
- WebHttpBehavior.cs
- InternalEnumValidator.cs
- IdlingCommunicationPool.cs
- DataExpression.cs
- BrushMappingModeValidation.cs
- ListViewInsertionMark.cs
- RtfToken.cs
- UrlPath.cs
- DetailsViewModeEventArgs.cs
- RangeValueProviderWrapper.cs
- ReadOnlyTernaryTree.cs
- AppLevelCompilationSectionCache.cs
- CompoundFileDeflateTransform.cs
- DialogResultConverter.cs
- UIElement3D.cs
- InvalidFilterCriteriaException.cs
- _HelperAsyncResults.cs
- CheckBoxField.cs
- ConfigurationProperty.cs
- RectValueSerializer.cs
- HttpServerUtilityWrapper.cs
- PathSegmentCollection.cs
- UnsafeNativeMethods.cs
- ToolBarButton.cs
- DrawingContextDrawingContextWalker.cs
- FormViewCommandEventArgs.cs
- RuntimeHandles.cs
- SmiEventSink.cs
- KerberosSecurityTokenAuthenticator.cs
- ToolStripPanel.cs
- XPathException.cs
- sqlmetadatafactory.cs
- ReadOnlyNameValueCollection.cs
- OdbcReferenceCollection.cs
- XmlObjectSerializerContext.cs
- VirtualizingPanel.cs
- AdapterDictionary.cs
- AsyncParams.cs
- PerformanceCountersElement.cs
- FindCriteria11.cs
- DataGridViewLayoutData.cs
- TabControl.cs
- TextEditorContextMenu.cs
- DockAndAnchorLayout.cs
- DataList.cs
- ResumeStoryboard.cs
- ParameterElement.cs
- ContractMapping.cs
- InstanceLockLostException.cs
- SettingsSavedEventArgs.cs