Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ButtonInternal / CheckableControlBaseAdapter.cs / 1305376 / 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; } internal static float GetDpiScaleRatio(Graphics g) { if (g == null) return 1.0F; return g.DpiX / 96; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// 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; } internal static float GetDpiScaleRatio(Graphics g) { if (g == null) return 1.0F; return g.DpiX / 96; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PropertyDescriptorComparer.cs
- PartitionResolver.cs
- ObjectDataSourceDisposingEventArgs.cs
- Vector3dCollection.cs
- FieldTemplateUserControl.cs
- NodeLabelEditEvent.cs
- CellLabel.cs
- PathGradientBrush.cs
- HttpPostedFile.cs
- EdmComplexTypeAttribute.cs
- ExpressionBuilderCollection.cs
- SoapExtension.cs
- IncrementalCompileAnalyzer.cs
- DeobfuscatingStream.cs
- MetadataSerializer.cs
- PropertyRef.cs
- PropVariant.cs
- LexicalChunk.cs
- XmlSchemaAnnotated.cs
- CoTaskMemHandle.cs
- BamlResourceContent.cs
- OperatingSystem.cs
- OpacityConverter.cs
- ParentQuery.cs
- Pkcs9Attribute.cs
- PersonalizationProviderCollection.cs
- DatagridviewDisplayedBandsData.cs
- MetadataArtifactLoaderResource.cs
- EraserBehavior.cs
- SettingsContext.cs
- WebPartEditorOkVerb.cs
- SQLInt32.cs
- BinaryReader.cs
- MenuBase.cs
- Expression.cs
- SafeViewOfFileHandle.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- AutoResizedEvent.cs
- TemplatedWizardStep.cs
- coordinatorfactory.cs
- DefaultBinder.cs
- BitmapEffect.cs
- SystemPens.cs
- HashCodeCombiner.cs
- DisableDpiAwarenessAttribute.cs
- LayoutSettings.cs
- DBAsyncResult.cs
- DoubleCollectionValueSerializer.cs
- ServerIdentity.cs
- IPHostEntry.cs
- TypeSystemProvider.cs
- DiscoveryDocumentReference.cs
- ValueConversionAttribute.cs
- WSFederationHttpBindingCollectionElement.cs
- NullReferenceException.cs
- ManagementClass.cs
- GridItemPattern.cs
- CloudCollection.cs
- NavigatorInput.cs
- XPathArrayIterator.cs
- MultiSelector.cs
- CryptoKeySecurity.cs
- SqlConnectionFactory.cs
- InlineUIContainer.cs
- ComponentDispatcher.cs
- OracleBinary.cs
- SignatureDescription.cs
- PanelStyle.cs
- PropertyEmitterBase.cs
- ViewDesigner.cs
- Tracking.cs
- EnumMemberAttribute.cs
- CollectionView.cs
- XPathDocumentIterator.cs
- MultipartContentParser.cs
- AuthStoreRoleProvider.cs
- ErrorWrapper.cs
- PropertyManager.cs
- MailDefinition.cs
- IfAction.cs
- Nullable.cs
- PseudoWebRequest.cs
- IisNotInstalledException.cs
- BindingGroup.cs
- GridViewPageEventArgs.cs
- DetailsView.cs
- Int32Storage.cs
- ModelTreeManager.cs
- SizeValueSerializer.cs
- TrustManagerMoreInformation.cs
- COM2Enum.cs
- ExecutionEngineException.cs
- FileReader.cs
- GlyphRunDrawing.cs
- InternalBase.cs
- ThousandthOfEmRealDoubles.cs
- CodeCompiler.cs
- CellTreeNode.cs
- InputProcessorProfiles.cs
- MulticastDelegate.cs