Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / ButtonInternal / CheckableControlBaseAdapter.cs / 1 / CheckableControlBaseAdapter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Windows.Forms.ButtonInternal { using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Drawing.Text; using System.Windows.Forms; ////// Common class for RadioButtonBaseAdapter and CheckBoxBaseAdapter /// internal abstract class CheckableControlBaseAdapter : ButtonBaseAdapter { private const int standardCheckSize = 13; private ButtonBaseAdapter buttonAdapter; internal CheckableControlBaseAdapter(ButtonBase control) : base(control) {} protected ButtonBaseAdapter ButtonAdapter { get { if (buttonAdapter == null) { buttonAdapter = CreateButtonAdapter(); } return buttonAdapter; } } internal override Size GetPreferredSizeCore(Size proposedSize) { if (Appearance == Appearance.Button) { return ButtonAdapter.GetPreferredSizeCore(proposedSize); } using (Graphics measurementGraphics = WindowsFormsUtils.CreateMeasurementGraphics()) { using (PaintEventArgs pe = new PaintEventArgs(measurementGraphics, new Rectangle())) { LayoutOptions options = Layout(pe); return options.GetPreferredSizeCore(proposedSize); } } } protected abstract ButtonBaseAdapter CreateButtonAdapter(); private Appearance Appearance { get { CheckBox checkBox = Control as CheckBox; if(checkBox != null) { return checkBox.Appearance; } RadioButton radioButton = Control as RadioButton; if(radioButton != null) { return radioButton.Appearance; } Debug.Fail("Unexpected control type '" + Control.GetType().FullName + "'"); return Appearance.Normal; } } internal override LayoutOptions CommonLayout() { LayoutOptions layout = base.CommonLayout(); layout.growBorderBy1PxWhenDefault = false; layout.borderSize = 0; layout.paddingSize = 0; layout.maxFocus = false; layout.focusOddEvenFixup = true; layout.checkSize = standardCheckSize; return layout; } } } // 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
- RegistryPermission.cs
- Root.cs
- ActivityStatusChangeEventArgs.cs
- StorageRoot.cs
- ProxyWebPart.cs
- ListBoxAutomationPeer.cs
- RelatedView.cs
- Events.cs
- HitTestDrawingContextWalker.cs
- SystemBrushes.cs
- EntityDataSourceViewSchema.cs
- MulticastOption.cs
- CryptoHelper.cs
- Int64AnimationBase.cs
- PresentationTraceSources.cs
- DataGridViewComboBoxEditingControl.cs
- HttpResponseInternalWrapper.cs
- ObjectStateEntryDbDataRecord.cs
- BackgroundFormatInfo.cs
- Converter.cs
- ComponentSerializationService.cs
- ReadOnlyDataSource.cs
- FormsAuthenticationCredentials.cs
- IntegerFacetDescriptionElement.cs
- StringDictionaryWithComparer.cs
- BamlLocalizationDictionary.cs
- DataGridTextBox.cs
- FaultContractAttribute.cs
- URIFormatException.cs
- CodeDomConfigurationHandler.cs
- AutomationElementCollection.cs
- SQLRoleProvider.cs
- TypeElement.cs
- RtType.cs
- MessageQueuePermissionEntry.cs
- XmlCountingReader.cs
- FixedSOMTableCell.cs
- SHA256Managed.cs
- TripleDES.cs
- JapaneseLunisolarCalendar.cs
- FirstMatchCodeGroup.cs
- FormatSelectingMessageInspector.cs
- Trigger.cs
- HttpPostProtocolImporter.cs
- ProcessStartInfo.cs
- DataViewManager.cs
- Camera.cs
- XmlILIndex.cs
- DataGridViewCellEventArgs.cs
- PeerName.cs
- PageContent.cs
- FormViewUpdatedEventArgs.cs
- CheckBox.cs
- LinkedResource.cs
- ManagementObject.cs
- ConfigurationStrings.cs
- EditorZone.cs
- OledbConnectionStringbuilder.cs
- MethodBuilderInstantiation.cs
- SequentialOutput.cs
- TaskHelper.cs
- WebServiceErrorEvent.cs
- DictionaryEntry.cs
- MSG.cs
- CodeSnippetExpression.cs
- LinkedDataMemberFieldEditor.cs
- NavigationProgressEventArgs.cs
- ListItemCollection.cs
- TextEndOfParagraph.cs
- WorkflowApplicationCompletedException.cs
- HostingEnvironment.cs
- XamlPoint3DCollectionSerializer.cs
- SizeConverter.cs
- EdmItemCollection.OcAssemblyCache.cs
- EntityAdapter.cs
- itemelement.cs
- TemplatedWizardStep.cs
- HtmlEmptyTagControlBuilder.cs
- XmlAttributeProperties.cs
- Point3D.cs
- FixedNode.cs
- assemblycache.cs
- EntryPointNotFoundException.cs
- XPathNodePointer.cs
- SubclassTypeValidatorAttribute.cs
- SerializationInfo.cs
- TextElement.cs
- ExpressionLink.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- XmlConvert.cs
- QilSortKey.cs
- FactoryMaker.cs
- RadioButtonBaseAdapter.cs
- SiteMapNodeCollection.cs
- TextRangeEditTables.cs
- ServiceInfoCollection.cs
- HttpResponse.cs
- ModelItemCollectionImpl.cs
- ContentFileHelper.cs
- XmlSchemaSearchPattern.cs