Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Framework / System / Windows / Controls / CheckBox.cs / 1 / CheckBox.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.Windows.Threading; using System.Windows.Automation; using System.Windows.Controls.Primitives; using System.Windows; using System.Windows.Input; using System.Windows.Media; using MS.Utility; using MS.Internal.KnownBoxes; // Disable CS3001: Warning as Error: not CLS-compliant #pragma warning disable 3001 namespace System.Windows.Controls { #region CheckBox class ////// Use a CheckBox to give the user an option, such as true/false. /// CheckBox allow the user to choose from a list of options. /// CheckBox controls let the user pick a combination of options. /// [DefaultEvent("CheckStateChanged")] [Localizability(LocalizationCategory.CheckBox)] public class CheckBox : ToggleButton { #region Constructors static CheckBox() { // Set the default Style DefaultStyleKeyProperty.OverrideMetadata(typeof(CheckBox), new FrameworkPropertyMetadata(typeof(CheckBox))); _dType = DependencyObjectType.FromSystemTypeInternal(typeof(CheckBox)); KeyboardNavigation.AcceptsReturnProperty.OverrideMetadata(typeof(CheckBox), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox)); } ////// Default CheckBox constructor /// ////// Automatic determination of current Dispatcher. Use alternative constructor /// that accepts a Dispatcher for best performance. /// public CheckBox() : base() { } #endregion #region Override methods ////// Creates AutomationPeer ( protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer() { return new System.Windows.Automation.Peers.CheckBoxAutomationPeer(this); } ///) /// /// This is the method that responds to the KeyDown event. /// /// protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); // Add aditional keys "+" and "-" when we are not in IsThreeState mode if (!IsThreeState) { if (e.Key == Key.OemPlus || e.Key == Key.Add) { e.Handled = true; ClearValue(IsPressedPropertyKey); IsChecked = true; } else if (e.Key == Key.OemMinus || e.Key == Key.Subtract) { e.Handled = true; ClearValue(IsPressedPropertyKey); IsChecked = false; } } } ////// The Access key for this control was invoked. /// /// protected override void OnAccessKey(AccessKeyEventArgs e) { if (!IsKeyboardFocused) { Focus(); } base.OnAccessKey(e); } #endregion #region Data #endregion #region DTypeThemeStyleKey // Returns the DependencyObjectType for the registered ThemeStyleKey's default // value. Controls will override this method to return approriate types. internal override DependencyObjectType DTypeThemeStyleKey { get { return _dType; } } private static DependencyObjectType _dType; #endregion DTypeThemeStyleKey } #endregion CheckBox class } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Collections; using System.ComponentModel; using System.Windows.Threading; using System.Windows.Automation; using System.Windows.Controls.Primitives; using System.Windows; using System.Windows.Input; using System.Windows.Media; using MS.Utility; using MS.Internal.KnownBoxes; // Disable CS3001: Warning as Error: not CLS-compliant #pragma warning disable 3001 namespace System.Windows.Controls { #region CheckBox class ////// Use a CheckBox to give the user an option, such as true/false. /// CheckBox allow the user to choose from a list of options. /// CheckBox controls let the user pick a combination of options. /// [DefaultEvent("CheckStateChanged")] [Localizability(LocalizationCategory.CheckBox)] public class CheckBox : ToggleButton { #region Constructors static CheckBox() { // Set the default Style DefaultStyleKeyProperty.OverrideMetadata(typeof(CheckBox), new FrameworkPropertyMetadata(typeof(CheckBox))); _dType = DependencyObjectType.FromSystemTypeInternal(typeof(CheckBox)); KeyboardNavigation.AcceptsReturnProperty.OverrideMetadata(typeof(CheckBox), new FrameworkPropertyMetadata(BooleanBoxes.FalseBox)); } ////// Default CheckBox constructor /// ////// Automatic determination of current Dispatcher. Use alternative constructor /// that accepts a Dispatcher for best performance. /// public CheckBox() : base() { } #endregion #region Override methods ////// Creates AutomationPeer ( protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer() { return new System.Windows.Automation.Peers.CheckBoxAutomationPeer(this); } ///) /// /// This is the method that responds to the KeyDown event. /// /// protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); // Add aditional keys "+" and "-" when we are not in IsThreeState mode if (!IsThreeState) { if (e.Key == Key.OemPlus || e.Key == Key.Add) { e.Handled = true; ClearValue(IsPressedPropertyKey); IsChecked = true; } else if (e.Key == Key.OemMinus || e.Key == Key.Subtract) { e.Handled = true; ClearValue(IsPressedPropertyKey); IsChecked = false; } } } ////// The Access key for this control was invoked. /// /// protected override void OnAccessKey(AccessKeyEventArgs e) { if (!IsKeyboardFocused) { Focus(); } base.OnAccessKey(e); } #endregion #region Data #endregion #region DTypeThemeStyleKey // Returns the DependencyObjectType for the registered ThemeStyleKey's default // value. Controls will override this method to return approriate types. internal override DependencyObjectType DTypeThemeStyleKey { get { return _dType; } } private static DependencyObjectType _dType; #endregion DTypeThemeStyleKey } #endregion CheckBox class } // 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
- Invariant.cs
- SystemKeyConverter.cs
- RenameRuleObjectDialog.cs
- BuildProviderUtils.cs
- WebPartsPersonalization.cs
- XamlPathDataSerializer.cs
- DataGridTextBoxColumn.cs
- NullExtension.cs
- InheritanceAttribute.cs
- PlatformNotSupportedException.cs
- ImageSource.cs
- FileBasedResourceGroveler.cs
- DiscoveryReference.cs
- RadioButtonAutomationPeer.cs
- MessageFault.cs
- SubMenuStyle.cs
- RectConverter.cs
- ProtocolElementCollection.cs
- WebBrowserPermission.cs
- TranslateTransform3D.cs
- AmbientLight.cs
- ConfigXmlAttribute.cs
- ControlHelper.cs
- FocusTracker.cs
- ModifierKeysValueSerializer.cs
- XmlCDATASection.cs
- XmlSchemaImport.cs
- AttributeCollection.cs
- AutomationPropertyInfo.cs
- SyndicationContent.cs
- Literal.cs
- BindingContext.cs
- FixedSOMTableCell.cs
- WebPartZoneCollection.cs
- WebControlToolBoxItem.cs
- RecognizedPhrase.cs
- BinaryReader.cs
- ListBoxChrome.cs
- BaseInfoTable.cs
- BaseComponentEditor.cs
- EmptyStringExpandableObjectConverter.cs
- WindowsBrush.cs
- UTF8Encoding.cs
- SmiGettersStream.cs
- Rotation3DAnimationBase.cs
- MouseOverProperty.cs
- Inline.cs
- XamlVector3DCollectionSerializer.cs
- ParentQuery.cs
- SQLMoneyStorage.cs
- TableCellAutomationPeer.cs
- SpAudioStreamWrapper.cs
- DataContractSerializer.cs
- StateDesigner.Helpers.cs
- PointHitTestResult.cs
- exports.cs
- QueryLifecycle.cs
- MimePart.cs
- _ShellExpression.cs
- ToolboxSnapDragDropEventArgs.cs
- StringUtil.cs
- ShaderEffect.cs
- KerberosRequestorSecurityTokenAuthenticator.cs
- CodeCompiler.cs
- RequestResponse.cs
- AutomationPatternInfo.cs
- HtmlInputText.cs
- SqlClientWrapperSmiStream.cs
- CodeTypeReferenceCollection.cs
- SchemaTypeEmitter.cs
- LinearGradientBrush.cs
- ConstructorNeedsTagAttribute.cs
- COM2EnumConverter.cs
- SqlCachedBuffer.cs
- ipaddressinformationcollection.cs
- PerformanceCounterPermissionEntry.cs
- WebPartMenuStyle.cs
- WindowsListBox.cs
- MethodCallConverter.cs
- CriticalExceptions.cs
- Array.cs
- ScrollChrome.cs
- Converter.cs
- DynamicVirtualDiscoSearcher.cs
- StorageComplexPropertyMapping.cs
- _AcceptOverlappedAsyncResult.cs
- DataGridAddNewRow.cs
- DeploymentSection.cs
- BamlWriter.cs
- CompletedAsyncResult.cs
- FormatControl.cs
- Context.cs
- OdbcPermission.cs
- SqlClientMetaDataCollectionNames.cs
- BufferedWebEventProvider.cs
- Geometry.cs
- BinaryUtilClasses.cs
- ColorConvertedBitmap.cs
- InputLanguageSource.cs
- TrustExchangeException.cs