Code:
/ 4.0 / 4.0 / 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. //------------------------------------------------------------------------------ //// 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
- SqlDataSourceConnectionPanel.cs
- SingleConverter.cs
- ParseHttpDate.cs
- WebServiceReceiveDesigner.cs
- HttpCachePolicy.cs
- Choices.cs
- WaitHandleCannotBeOpenedException.cs
- ISO2022Encoding.cs
- GridErrorDlg.cs
- WebControlsSection.cs
- XmlSchemaValidator.cs
- _NativeSSPI.cs
- ProfileBuildProvider.cs
- ResXResourceReader.cs
- MetadataUtilsSmi.cs
- SnapshotChangeTrackingStrategy.cs
- ListBoxAutomationPeer.cs
- CodeSubDirectory.cs
- ConstraintManager.cs
- OperationValidationEventArgs.cs
- FamilyCollection.cs
- TraceContext.cs
- ObjectTag.cs
- BamlResourceDeserializer.cs
- WindowsFormsEditorServiceHelper.cs
- ToolbarAUtomationPeer.cs
- DateBoldEvent.cs
- Pen.cs
- LayoutManager.cs
- StdValidatorsAndConverters.cs
- DeclarationUpdate.cs
- SerializationAttributes.cs
- Attachment.cs
- TCEAdapterGenerator.cs
- NativeMethods.cs
- RequestCachingSection.cs
- AnnouncementDispatcherAsyncResult.cs
- RecognizeCompletedEventArgs.cs
- EntityContainerRelationshipSet.cs
- CodeMemberProperty.cs
- ReliabilityContractAttribute.cs
- iisPickupDirectory.cs
- ListBoxChrome.cs
- PersistenceMetadataNamespace.cs
- CapabilitiesUse.cs
- AssemblyInfo.cs
- AssociationSetMetadata.cs
- MediaTimeline.cs
- TimeoutTimer.cs
- TemplateControlCodeDomTreeGenerator.cs
- UniqueConstraint.cs
- ExpressionHelper.cs
- TextSelectionHighlightLayer.cs
- UnmanagedMemoryStreamWrapper.cs
- StylusDevice.cs
- MediaElementAutomationPeer.cs
- HtmlButton.cs
- Operator.cs
- AssemblyBuilder.cs
- Expression.cs
- EventLogger.cs
- XPathNavigatorReader.cs
- CharEnumerator.cs
- SharedConnectionWorkflowTransactionService.cs
- PageHandlerFactory.cs
- Message.cs
- EmptyStringExpandableObjectConverter.cs
- HttpResponseInternalWrapper.cs
- FlowDocumentReader.cs
- TextBoxAutomationPeer.cs
- UriWriter.cs
- SqlDataSourceQueryConverter.cs
- Path.cs
- _FtpDataStream.cs
- UDPClient.cs
- ActivitySurrogate.cs
- CurrencyWrapper.cs
- WebConfigurationManager.cs
- DefaultEvaluationContext.cs
- ChangeProcessor.cs
- TypeUsage.cs
- selecteditemcollection.cs
- CachedRequestParams.cs
- SimpleType.cs
- RawStylusInputCustomData.cs
- OpenFileDialog.cs
- PropertyMapper.cs
- StagingAreaInputItem.cs
- DynamicResourceExtension.cs
- CachedTypeface.cs
- EventsTab.cs
- SplineQuaternionKeyFrame.cs
- CompilationRelaxations.cs
- HtmlInputControl.cs
- CapabilitiesUse.cs
- CommonRemoteMemoryBlock.cs
- MethodBuilder.cs
- ThreadAttributes.cs
- QuaternionAnimationUsingKeyFrames.cs
- CqlGenerator.cs