Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- WindowsTooltip.cs
- XmlEventCache.cs
- ObjectDataSourceDisposingEventArgs.cs
- ToggleButton.cs
- UTF8Encoding.cs
- ResXFileRef.cs
- GridViewSelectEventArgs.cs
- SerialErrors.cs
- SplitterEvent.cs
- DataColumnCollection.cs
- WorkflowRuntimeBehavior.cs
- Policy.cs
- CfgParser.cs
- EpmCustomContentSerializer.cs
- Padding.cs
- InternalUserCancelledException.cs
- MsmqIntegrationChannelFactory.cs
- SecureStringHasher.cs
- SafeHandle.cs
- TransformProviderWrapper.cs
- LocationSectionRecord.cs
- SelectionEditingBehavior.cs
- ToolStripSystemRenderer.cs
- EventSinkHelperWriter.cs
- StrokeNodeData.cs
- ObjectDataSourceView.cs
- MetadataElement.cs
- OptionalColumn.cs
- DataGridViewElement.cs
- ProfileProvider.cs
- AuthenticationModuleElementCollection.cs
- DataTableMapping.cs
- SEHException.cs
- XmlLangPropertyAttribute.cs
- ObjectListFieldCollection.cs
- DesignTimeParseData.cs
- ValidationErrorCollection.cs
- ObjectQuery.cs
- DataControlField.cs
- DodSequenceMerge.cs
- WebConvert.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- ControlBuilder.cs
- _ProxyChain.cs
- BlockExpression.cs
- NativeMethods.cs
- SQLDecimal.cs
- DPTypeDescriptorContext.cs
- HtmlInputSubmit.cs
- DurationConverter.cs
- Action.cs
- QilName.cs
- BidirectionalDictionary.cs
- BuilderPropertyEntry.cs
- TextEditorSpelling.cs
- TextSchema.cs
- DbParameterHelper.cs
- IISMapPath.cs
- HighlightOverlayGlyph.cs
- CompositeCollection.cs
- SyndicationDeserializer.cs
- MultipleViewProviderWrapper.cs
- MobileResource.cs
- XmlSchemaComplexContent.cs
- GridViewDeletedEventArgs.cs
- DataGridState.cs
- WindowsGraphicsCacheManager.cs
- SqlRowUpdatedEvent.cs
- PostBackOptions.cs
- Lease.cs
- CfgSemanticTag.cs
- HttpCachePolicyBase.cs
- FileLevelControlBuilderAttribute.cs
- BinaryNode.cs
- WbemException.cs
- GridViewCancelEditEventArgs.cs
- AnnouncementInnerClientCD1.cs
- XmlMtomReader.cs
- RecognitionEventArgs.cs
- XPathChildIterator.cs
- XpsFilter.cs
- MediaCommands.cs
- StylusOverProperty.cs
- QueryTaskGroupState.cs
- VisualTreeUtils.cs
- QuaternionAnimation.cs
- HtmlWindow.cs
- ChannelEndpointElementCollection.cs
- Tool.cs
- TextClipboardData.cs
- ObjectDataSourceDisposingEventArgs.cs
- ResourceKey.cs
- TextContainerChangeEventArgs.cs
- Base64Decoder.cs
- StorageComplexTypeMapping.cs
- httpserverutility.cs
- sqlcontext.cs
- VectorKeyFrameCollection.cs
- DataGridViewRowHeaderCell.cs
- ReferenceEqualityComparer.cs