Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- InteropEnvironment.cs
- RsaKeyGen.cs
- BinaryReader.cs
- PolicyValidationException.cs
- PrivilegeNotHeldException.cs
- OleDbPropertySetGuid.cs
- CreateWorkflowOwnerCommand.cs
- AffineTransform3D.cs
- Number.cs
- PointAnimationUsingKeyFrames.cs
- ButtonPopupAdapter.cs
- ToolStripSplitStackLayout.cs
- TraceHandler.cs
- NavigationCommands.cs
- BatchWriter.cs
- XmlWellformedWriter.cs
- ComboBoxRenderer.cs
- XmlSchemaDatatype.cs
- InputLangChangeRequestEvent.cs
- ResXResourceReader.cs
- CustomErrorCollection.cs
- FixUpCollection.cs
- TrustSection.cs
- Roles.cs
- HtmlTable.cs
- ConsoleEntryPoint.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- OTFRasterizer.cs
- PowerModeChangedEventArgs.cs
- TypeBuilder.cs
- FormatterConverter.cs
- WebDisplayNameAttribute.cs
- SoundPlayerAction.cs
- TabPage.cs
- XmlIncludeAttribute.cs
- WindowsAuthenticationModule.cs
- EntityDataSourceWizardForm.cs
- DefaultClaimSet.cs
- ChineseLunisolarCalendar.cs
- DataGridViewComboBoxColumn.cs
- NullableFloatAverageAggregationOperator.cs
- FormViewDeletedEventArgs.cs
- ClientRolePrincipal.cs
- HWStack.cs
- ListViewSortEventArgs.cs
- EdmItemCollection.OcAssemblyCache.cs
- IpcChannel.cs
- RSAProtectedConfigurationProvider.cs
- RecognizedWordUnit.cs
- HttpRuntime.cs
- VersionUtil.cs
- StrokeNode.cs
- CoreSwitches.cs
- HtmlInputButton.cs
- TypeElement.cs
- MouseGestureConverter.cs
- PageThemeCodeDomTreeGenerator.cs
- EventToken.cs
- ExtensionFile.cs
- ContextCorrelationInitializer.cs
- TextEditorSelection.cs
- HttpRuntime.cs
- WebPermission.cs
- DataGridColumnHeaderAutomationPeer.cs
- QueryStringParameter.cs
- BrowsableAttribute.cs
- DBAsyncResult.cs
- SqlBuilder.cs
- CollectionContainer.cs
- PaintEvent.cs
- ProxyWebPartManager.cs
- ResourceIDHelper.cs
- UnicodeEncoding.cs
- TriggerAction.cs
- PolyBezierSegmentFigureLogic.cs
- GlobalProxySelection.cs
- ErrorStyle.cs
- QuotedPairReader.cs
- DeferredSelectedIndexReference.cs
- TextWriter.cs
- Oid.cs
- PlainXmlDeserializer.cs
- HiddenField.cs
- ActivityDesignerHighlighter.cs
- ValidatorAttribute.cs
- ShimAsPublicXamlType.cs
- Matrix3DValueSerializer.cs
- SymbolUsageManager.cs
- PriorityItem.cs
- ClientBuildManagerCallback.cs
- RectAnimationClockResource.cs
- Walker.cs
- ParsedRoute.cs
- KeyEventArgs.cs
- SrgsElementList.cs
- ZipIOZip64EndOfCentralDirectoryLocatorBlock.cs
- XmlCountingReader.cs
- FileFormatException.cs
- AbstractSvcMapFileLoader.cs
- DialogResultConverter.cs