Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Controls / CheckBox.cs / 1458001 / 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); SetCurrentValueInternal(IsCheckedProperty, BooleanBoxes.TrueBox); } else if (e.Key == Key.OemMinus || e.Key == Key.Subtract) { e.Handled = true; ClearValue(IsPressedPropertyKey); SetCurrentValueInternal(IsCheckedProperty, BooleanBoxes.FalseBox); } } } ////// 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); SetCurrentValueInternal(IsCheckedProperty, BooleanBoxes.TrueBox); } else if (e.Key == Key.OemMinus || e.Key == Key.Subtract) { e.Handled = true; ClearValue(IsPressedPropertyKey); SetCurrentValueInternal(IsCheckedProperty, BooleanBoxes.FalseBox); } } } ////// 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
- ThreadStateException.cs
- DynamicDataManager.cs
- UpdateCommand.cs
- RPIdentityRequirement.cs
- RepeatBehavior.cs
- SystemSounds.cs
- PackageStore.cs
- EventDescriptorCollection.cs
- Control.cs
- RuntimeConfig.cs
- SystemUnicastIPAddressInformation.cs
- BindUriHelper.cs
- UnknownWrapper.cs
- SmiMetaDataProperty.cs
- ResolveCriteriaApril2005.cs
- DataGridViewMethods.cs
- PropertyIDSet.cs
- HttpResponseHeader.cs
- _CacheStreams.cs
- MenuItemStyle.cs
- MsmqAuthenticationMode.cs
- ApplicationServiceManager.cs
- SafeCryptoHandles.cs
- ObservableDictionary.cs
- CqlQuery.cs
- EdmMember.cs
- FixedStringLookup.cs
- ModulesEntry.cs
- ListViewItemEventArgs.cs
- SiteMapPathDesigner.cs
- SqlDataSourceSelectingEventArgs.cs
- ConfigurationException.cs
- ThreadStateException.cs
- SqlConnectionStringBuilder.cs
- IPHostEntry.cs
- ValueOfAction.cs
- XPathNodeInfoAtom.cs
- ListMarkerLine.cs
- DataSourceControl.cs
- SimpleLine.cs
- wgx_sdk_version.cs
- LinqToSqlWrapper.cs
- CngProperty.cs
- ImageMap.cs
- SlotInfo.cs
- VariantWrapper.cs
- BaseTemplateBuildProvider.cs
- UriWriter.cs
- assertwrapper.cs
- HttpCacheVaryByContentEncodings.cs
- HuffModule.cs
- NegatedConstant.cs
- TransportSecurityHelpers.cs
- KerberosTicketHashIdentifierClause.cs
- SharedPerformanceCounter.cs
- CombinedTcpChannel.cs
- ProviderSettings.cs
- GenericAuthenticationEventArgs.cs
- Identifier.cs
- NamespaceImport.cs
- ToolStripItemEventArgs.cs
- SubpageParaClient.cs
- UIElementCollection.cs
- RuleConditionDialog.cs
- RoleManagerEventArgs.cs
- ColumnCollection.cs
- Timer.cs
- ListBindingConverter.cs
- UrlMapping.cs
- ConfigurationElementProperty.cs
- BitmapEffect.cs
- SafeEventLogWriteHandle.cs
- ProviderConnectionPointCollection.cs
- RtfControlWordInfo.cs
- Paragraph.cs
- Executor.cs
- SuppressIldasmAttribute.cs
- XPathPatternParser.cs
- DaylightTime.cs
- Base64WriteStateInfo.cs
- XmlSchemaAttribute.cs
- GridViewColumnHeader.cs
- SaveFileDialog.cs
- NameScopePropertyAttribute.cs
- SortableBindingList.cs
- DataGridViewImageColumn.cs
- UpdateTracker.cs
- DataGridTablesFactory.cs
- HighlightVisual.cs
- PageBreakRecord.cs
- RC2CryptoServiceProvider.cs
- WindowsSolidBrush.cs
- ResetableIterator.cs
- GZipStream.cs
- Popup.cs
- CodeAttributeDeclaration.cs
- SerializationSectionGroup.cs
- ModelProperty.cs
- RelatedView.cs
- PropertyEmitterBase.cs