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
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PerformanceCounterLib.cs
- CommandConverter.cs
- WindowsTreeView.cs
- EmptyQuery.cs
- WSHttpTransportSecurityElement.cs
- WindowsStartMenu.cs
- CompleteWizardStep.cs
- HandlerElement.cs
- MetadataItemEmitter.cs
- ProcessHostServerConfig.cs
- SystemFonts.cs
- EntityWrapper.cs
- RandomNumberGenerator.cs
- PathData.cs
- GroupBox.cs
- ListBox.cs
- Literal.cs
- HostingEnvironmentWrapper.cs
- EncryptedReference.cs
- ComNativeDescriptor.cs
- ThreadInterruptedException.cs
- ConstantExpression.cs
- WebPartTransformerAttribute.cs
- VScrollBar.cs
- SQLBytesStorage.cs
- PrintPreviewDialog.cs
- InputEventArgs.cs
- Transform.cs
- IsolatedStoragePermission.cs
- GridToolTip.cs
- UrlMappingsSection.cs
- VerificationException.cs
- ClusterSafeNativeMethods.cs
- SQlBooleanStorage.cs
- CellLabel.cs
- TemplateBindingExpression.cs
- SizeAnimationClockResource.cs
- HtmlGenericControl.cs
- DbgUtil.cs
- FixedLineResult.cs
- HierarchicalDataBoundControlAdapter.cs
- ResourceWriter.cs
- WinFormsSpinner.cs
- UserControlAutomationPeer.cs
- ServiceXNameTypeConverter.cs
- ReaderWriterLock.cs
- SQLDateTimeStorage.cs
- ManipulationDelta.cs
- HttpApplicationFactory.cs
- ToolboxComponentsCreatingEventArgs.cs
- IsolatedStorageFile.cs
- WebConfigurationHostFileChange.cs
- ToolStripOverflow.cs
- OracleSqlParser.cs
- AssemblyResourceLoader.cs
- InstanceStoreQueryResult.cs
- FormattedTextSymbols.cs
- BlurBitmapEffect.cs
- DrawingState.cs
- DeclarativeConditionsCollection.cs
- Object.cs
- ProfileModule.cs
- RelationshipConstraintValidator.cs
- FormatException.cs
- PackageStore.cs
- Int32RectConverter.cs
- LoginView.cs
- GeneralTransformGroup.cs
- SchemaInfo.cs
- WaitHandleCannotBeOpenedException.cs
- MultipleViewProviderWrapper.cs
- X509ThumbprintKeyIdentifierClause.cs
- CatalogPartChrome.cs
- LocationReferenceValue.cs
- XmlWrappingReader.cs
- EditorAttributeInfo.cs
- HtmlInputImage.cs
- _ListenerResponseStream.cs
- SqlReorderer.cs
- JavaScriptString.cs
- AlignmentXValidation.cs
- PageParser.cs
- CollectionContainer.cs
- TreeViewItemAutomationPeer.cs
- RequiredAttributeAttribute.cs
- WebSysDisplayNameAttribute.cs
- ExpressionBindings.cs
- DBConcurrencyException.cs
- SafeBitVector32.cs
- ContentPosition.cs
- Imaging.cs
- HostedElements.cs
- CookielessHelper.cs
- Paragraph.cs
- DataServiceEntityAttribute.cs
- SamlAttribute.cs
- PrinterSettings.cs
- AppSettingsReader.cs
- StreamResourceInfo.cs
- ModuleBuilderData.cs