Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ButtonInternal / CheckBoxPopupAdapter.cs / 1305376 / CheckBoxPopupAdapter.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; using System.Windows.Forms.Layout; using System.Diagnostics.CodeAnalysis; internal class CheckBoxPopupAdapter : CheckBoxBaseAdapter { internal CheckBoxPopupAdapter(ButtonBase control) : base(control) {} internal override void PaintUp(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonPopupAdapter adapter = new ButtonPopupAdapter(Control); adapter.PaintUp(e, Control.CheckState); } else { System.Drawing.Graphics g = e.Graphics; ColorData colors = PaintPopupRender(e.Graphics).Calculate(); LayoutData layout = PaintPopupLayout(e, false).Layout(); Region original = e.Graphics.Clip; PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckBackground(e, layout.checkBounds, colors.windowText, colors.options.highContrast ? colors.buttonFace : colors.highlight, true, colors); DrawFlatBorder(e.Graphics, layout.checkBounds, colors.buttonShadow); DrawCheckOnly(e, layout, colors, colors.windowText, colors.highlight, true); PaintField(e, layout, colors, colors.windowText, true); } } internal override void PaintOver(PaintEventArgs e, CheckState state) { System.Drawing.Graphics g = e.Graphics; if (Control.Appearance == Appearance.Button) { ButtonPopupAdapter adapter = new ButtonPopupAdapter(Control); adapter.PaintOver(e, Control.CheckState); } else { ColorData colors = PaintPopupRender(e.Graphics).Calculate(); LayoutData layout = PaintPopupLayout(e, true).Layout(); Region original = e.Graphics.Clip; PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckBackground(e, layout.checkBounds, colors.windowText, colors.options.highContrast ? colors.buttonFace : colors.highlight, true, colors); DrawPopupBorder(g, layout.checkBounds, colors); DrawCheckOnly(e, layout, colors, colors.windowText, colors.highlight, true); e.Graphics.Clip = original; e.Graphics.ExcludeClip(layout.checkArea); PaintField(e, layout, colors, colors.windowText, true); } } internal override void PaintDown(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonPopupAdapter adapter = new ButtonPopupAdapter(Control); adapter.PaintDown(e, Control.CheckState); } else { System.Drawing.Graphics g = e.Graphics; ColorData colors = PaintPopupRender(e.Graphics).Calculate(); LayoutData layout = PaintPopupLayout(e, true).Layout(); Region original = e.Graphics.Clip; PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckBackground(e, layout.checkBounds, colors.windowText, colors.buttonFace, true, colors); DrawPopupBorder(g, layout.checkBounds, colors); DrawCheckOnly(e, layout, colors, colors.windowText, colors.buttonFace, true); PaintField(e, layout, colors, colors.windowText, true); } } #region Layout protected override ButtonBaseAdapter CreateButtonAdapter() { return new ButtonPopupAdapter(Control); } protected override LayoutOptions Layout(PaintEventArgs e) { LayoutOptions layout = PaintPopupLayout(e, /* up = */ true); Debug.Assert(layout.GetPreferredSizeCore(LayoutUtils.MaxSize) == PaintPopupLayout(e, /* up = */ false).GetPreferredSizeCore(LayoutUtils.MaxSize), "The state of show3D should not effect PreferredSize"); return layout; } [SuppressMessage("Microsoft.Performance", "CA1801:AvoidUnusedParameters")] // removed graphics, may have to put it back internal static LayoutOptions PaintPopupLayout(Graphics g, bool show3D, int checkSize, Rectangle clientRectangle, Padding padding, bool isDefault, Font font, string text, bool enabled, ContentAlignment textAlign, RightToLeft rtl) { LayoutOptions layout = CommonLayout(clientRectangle, padding, isDefault, font, text, enabled, textAlign, rtl); layout.shadowedText = false; if (show3D) { layout.checkSize = (int)(checkSize * GetDpiScaleRatio(g) + 1); } else { layout.checkSize = (int)(checkSize * GetDpiScaleRatio(g)); layout.checkPaddingSize = 1; } return layout; } [SuppressMessage("Microsoft.Performance", "CA1801:AvoidUnusedParameters")] // removed graphics, may have to put it back private LayoutOptions PaintPopupLayout(PaintEventArgs e, bool show3D) { LayoutOptions layout = CommonLayout(); layout.shadowedText = false; if (show3D) { layout.checkSize = (int)(flatCheckSize * GetDpiScaleRatio(e.Graphics) + 1); } else { layout.checkSize = (int)(flatCheckSize * GetDpiScaleRatio(e.Graphics)); layout.checkPaddingSize = 1; } return layout; } #endregion } } // 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
- Document.cs
- ConfigurationElement.cs
- Exception.cs
- Security.cs
- ReadOnlyAttribute.cs
- storepermission.cs
- ObjectDataSourceStatusEventArgs.cs
- TextSelectionHighlightLayer.cs
- ZipIOModeEnforcingStream.cs
- TrustManagerMoreInformation.cs
- StylusCollection.cs
- FontResourceCache.cs
- PeerCollaboration.cs
- ImageBrush.cs
- SafeEventHandle.cs
- RuleValidation.cs
- RegexRunner.cs
- ChannelManager.cs
- CopyAction.cs
- FileVersionInfo.cs
- FileReservationCollection.cs
- PartialTrustVisibleAssemblyCollection.cs
- RectConverter.cs
- TimerEventSubscriptionCollection.cs
- BatchServiceHost.cs
- AsyncStreamReader.cs
- SpecialNameAttribute.cs
- AsyncResult.cs
- TextRangeBase.cs
- Baml6Assembly.cs
- input.cs
- DesignerAdRotatorAdapter.cs
- ToolStripTextBox.cs
- NullableDoubleSumAggregationOperator.cs
- WebPartVerbsEventArgs.cs
- CodeVariableReferenceExpression.cs
- StrongNamePublicKeyBlob.cs
- EasingKeyFrames.cs
- SafeSecurityHandles.cs
- ExeContext.cs
- ModuleBuilder.cs
- EventRoute.cs
- IndicCharClassifier.cs
- SharedPersonalizationStateInfo.cs
- SimpleMailWebEventProvider.cs
- _AutoWebProxyScriptWrapper.cs
- TabControlAutomationPeer.cs
- MemberJoinTreeNode.cs
- ArrowControl.xaml.cs
- dbdatarecord.cs
- ColumnMapTranslator.cs
- RtfToXamlReader.cs
- BindableTemplateBuilder.cs
- XPathAncestorIterator.cs
- SelectedDatesCollection.cs
- VectorCollectionValueSerializer.cs
- Point4D.cs
- xmlfixedPageInfo.cs
- RSACryptoServiceProvider.cs
- ByteKeyFrameCollection.cs
- Int64.cs
- LinqExpressionNormalizer.cs
- JsonDataContract.cs
- ConfigXmlAttribute.cs
- SynchronizedInputAdaptor.cs
- Oid.cs
- SelectedCellsCollection.cs
- Stackframe.cs
- SwitchExpression.cs
- WebPartDisplayMode.cs
- ResourceExpressionBuilder.cs
- PopupRootAutomationPeer.cs
- DBConcurrencyException.cs
- mactripleDES.cs
- SatelliteContractVersionAttribute.cs
- SBCSCodePageEncoding.cs
- Section.cs
- FrameworkContentElementAutomationPeer.cs
- SspiSafeHandles.cs
- Bold.cs
- SizeChangedEventArgs.cs
- QilTargetType.cs
- PathTooLongException.cs
- ToolStripStatusLabel.cs
- Dump.cs
- ErrorInfoXmlDocument.cs
- DbDataRecord.cs
- OuterGlowBitmapEffect.cs
- RegisteredExpandoAttribute.cs
- EpmSyndicationContentSerializer.cs
- BooleanExpr.cs
- DynamicPropertyHolder.cs
- PageSetupDialog.cs
- ObjectListComponentEditor.cs
- SafeThemeHandle.cs
- DefaultProxySection.cs
- PaginationProgressEventArgs.cs
- IntegrationExceptionEventArgs.cs
- ClientTargetSection.cs
- CanExpandCollapseAllConverter.cs