Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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. // //----------------------------------------------------------------------------- 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XhtmlStyleClass.cs
- ListViewGroup.cs
- SQLUtility.cs
- MetricEntry.cs
- InheritanceService.cs
- ConsoleTraceListener.cs
- RefreshPropertiesAttribute.cs
- Column.cs
- IdentitySection.cs
- ScriptingRoleServiceSection.cs
- TrackingMemoryStreamFactory.cs
- CacheMemory.cs
- ToolboxItemFilterAttribute.cs
- MetadataUtilsSmi.cs
- SchemaElementDecl.cs
- SiteIdentityPermission.cs
- XmlSchemaAny.cs
- HitTestParameters3D.cs
- RegexTypeEditor.cs
- WinEventTracker.cs
- XPathNavigatorReader.cs
- TransactionScope.cs
- ValidatingReaderNodeData.cs
- ManagementOperationWatcher.cs
- UnauthorizedWebPart.cs
- ParsedRoute.cs
- DefaultShape.cs
- externdll.cs
- ControlPaint.cs
- SmiGettersStream.cs
- OdbcParameter.cs
- ExtendedTransformFactory.cs
- SendDesigner.xaml.cs
- OwnerDrawPropertyBag.cs
- Serializer.cs
- SimpleRecyclingCache.cs
- TitleStyle.cs
- Light.cs
- SchemaElement.cs
- TypeUnloadedException.cs
- StringFunctions.cs
- TimeZoneNotFoundException.cs
- File.cs
- PixelShader.cs
- UInt64Storage.cs
- DrawingContextDrawingContextWalker.cs
- QueryAccessibilityHelpEvent.cs
- SymmetricAlgorithm.cs
- ToolStrip.cs
- BamlTreeNode.cs
- DataContractFormatAttribute.cs
- UriSection.cs
- XmlFormatWriterGenerator.cs
- WorkflowWebService.cs
- Matrix3D.cs
- TypeDelegator.cs
- SHA256.cs
- ComplexTypeEmitter.cs
- oledbmetadatacollectionnames.cs
- CollectionBuilder.cs
- IDispatchConstantAttribute.cs
- ScriptDescriptor.cs
- XPathScanner.cs
- GC.cs
- MeshGeometry3D.cs
- ColumnReorderedEventArgs.cs
- ZipIOLocalFileDataDescriptor.cs
- AttributedMetaModel.cs
- EnlistmentTraceIdentifier.cs
- AnimationClock.cs
- Monitor.cs
- AnimatedTypeHelpers.cs
- SQLInt32.cs
- DefaultParameterValueAttribute.cs
- SourceElementsCollection.cs
- QilXmlWriter.cs
- ScriptComponentDescriptor.cs
- Style.cs
- WindowsRegion.cs
- TextContainer.cs
- HostVisual.cs
- FullTextBreakpoint.cs
- PageScaling.cs
- TextElementEnumerator.cs
- TagElement.cs
- WebPartZoneBaseDesigner.cs
- RenderTargetBitmap.cs
- InputLanguageEventArgs.cs
- DocumentEventArgs.cs
- HostedAspNetEnvironment.cs
- GridPattern.cs
- _Win32.cs
- SmiTypedGetterSetter.cs
- IHttpResponseInternal.cs
- ParameterToken.cs
- HiddenField.cs
- WinCategoryAttribute.cs
- ToolStripDropDownItemDesigner.cs
- PropertyManager.cs
- XDRSchema.cs