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
- ParameterEditorUserControl.cs
- WindowsStatusBar.cs
- EntityDataSourceSelectedEventArgs.cs
- SplineKeyFrames.cs
- ToolStripProgressBar.cs
- WindowsStatusBar.cs
- NativeCompoundFileAPIs.cs
- BitmapPalettes.cs
- RuleSetReference.cs
- Int32Animation.cs
- DataGridViewSortCompareEventArgs.cs
- Label.cs
- SizeF.cs
- ChannelSinkStacks.cs
- SecurityKeyIdentifier.cs
- SafeTokenHandle.cs
- SvcMapFileSerializer.cs
- ScriptingJsonSerializationSection.cs
- HttpListenerRequestUriBuilder.cs
- ScrollProviderWrapper.cs
- InheritanceAttribute.cs
- ReceiveErrorHandling.cs
- As.cs
- RijndaelManaged.cs
- OrderedEnumerableRowCollection.cs
- WebPartsPersonalizationAuthorization.cs
- StylusDevice.cs
- MenuItemStyle.cs
- RowCache.cs
- GlyphTypeface.cs
- PriorityQueue.cs
- AdornerLayer.cs
- RelationshipConverter.cs
- WriteableBitmap.cs
- Transactions.cs
- PrintPreviewGraphics.cs
- nulltextcontainer.cs
- QueueNameHelper.cs
- TextParagraphCache.cs
- StoreItemCollection.cs
- COM2FontConverter.cs
- OutOfProcStateClientManager.cs
- DeviceSpecificChoice.cs
- FileStream.cs
- ButtonFlatAdapter.cs
- CultureInfoConverter.cs
- DynamicILGenerator.cs
- AutomationProperty.cs
- Int32RectValueSerializer.cs
- StrokeSerializer.cs
- NavigationWindow.cs
- InputScopeConverter.cs
- RefreshPropertiesAttribute.cs
- HwndAppCommandInputProvider.cs
- ConstraintStruct.cs
- EventToken.cs
- BmpBitmapEncoder.cs
- DataTableNewRowEvent.cs
- DesignerSerializerAttribute.cs
- ScrollChangedEventArgs.cs
- WebBrowserBase.cs
- Authorization.cs
- DataListItemCollection.cs
- ConnectionProviderAttribute.cs
- NotifyIcon.cs
- XmlToDatasetMap.cs
- DataGridLinkButton.cs
- PropertyInfoSet.cs
- XmlSerializerOperationBehavior.cs
- FileDialogCustomPlacesCollection.cs
- SoapDocumentServiceAttribute.cs
- DiscoveryDocumentSearchPattern.cs
- XmlILConstructAnalyzer.cs
- KeyTimeConverter.cs
- WebPartTracker.cs
- FixedSOMSemanticBox.cs
- ComboBoxAutomationPeer.cs
- FormsIdentity.cs
- FormClosedEvent.cs
- MessageSecurityProtocolFactory.cs
- SafeNativeMethods.cs
- LinkConverter.cs
- sqlpipe.cs
- TypeLibraryHelper.cs
- DefaultHttpHandler.cs
- BinaryObjectWriter.cs
- SerializationException.cs
- _ShellExpression.cs
- AppDomainManager.cs
- ToolStripDropTargetManager.cs
- ReflectPropertyDescriptor.cs
- EndpointDiscoveryMetadataCD1.cs
- XmlWrappingReader.cs
- SettingsPropertyValue.cs
- DrawingContextDrawingContextWalker.cs
- DataGridBoolColumn.cs
- SyntaxCheck.cs
- HebrewCalendar.cs
- DbDataSourceEnumerator.cs
- MessageSecurityOverHttpElement.cs