Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ButtonInternal / CheckBoxFlatAdapter.cs / 1305376 / CheckBoxFlatAdapter.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; internal class CheckBoxFlatAdapter : CheckBoxBaseAdapter { internal CheckBoxFlatAdapter(ButtonBase control) : base(control) {} internal override void PaintDown(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonAdapter.PaintDown(e, Control.CheckState); return; } ColorData colors = PaintFlatRender(e.Graphics).Calculate(); if (Control.Enabled) { PaintFlatWorker(e, colors.windowText, colors.highlight, colors.windowFrame, colors); } else { PaintFlatWorker(e, colors.buttonShadow, colors.buttonFace, colors.buttonShadow, colors); } } internal override void PaintOver(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonAdapter.PaintOver(e, Control.CheckState); return; } ColorData colors = PaintFlatRender(e.Graphics).Calculate(); if (Control.Enabled) { PaintFlatWorker(e, colors.windowText, colors.lowHighlight, colors.windowFrame, colors); } else { PaintFlatWorker(e, colors.buttonShadow, colors.buttonFace, colors.buttonShadow, colors); } } internal override void PaintUp(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonAdapter.PaintUp(e, Control.CheckState); return; } ColorData colors = PaintFlatRender(e.Graphics).Calculate(); if (Control.Enabled) { PaintFlatWorker(e, colors.windowText, colors.highlight, colors.windowFrame, colors); } else { PaintFlatWorker(e, colors.buttonShadow, colors.buttonFace, colors.buttonShadow, colors); } } private void PaintFlatWorker(PaintEventArgs e, Color checkColor, Color checkBackground, Color checkBorder, ColorData colors) { System.Drawing.Graphics g = e.Graphics; LayoutData layout = Layout(e).Layout(); PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckFlat(e, layout, checkColor, colors.options.highContrast ? colors.buttonFace : checkBackground, checkBorder, colors); PaintField(e, layout, colors, checkColor, true); } #region Layout private new ButtonFlatAdapter ButtonAdapter { get { return ((ButtonFlatAdapter)base.ButtonAdapter); } } protected override ButtonBaseAdapter CreateButtonAdapter() { return new ButtonFlatAdapter(Control); } protected override LayoutOptions Layout(PaintEventArgs e) { LayoutOptions layout = CommonLayout(); layout.checkSize = (int)(flatCheckSize * GetDpiScaleRatio(e.Graphics)); layout.shadowedText = false; 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; internal class CheckBoxFlatAdapter : CheckBoxBaseAdapter { internal CheckBoxFlatAdapter(ButtonBase control) : base(control) {} internal override void PaintDown(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonAdapter.PaintDown(e, Control.CheckState); return; } ColorData colors = PaintFlatRender(e.Graphics).Calculate(); if (Control.Enabled) { PaintFlatWorker(e, colors.windowText, colors.highlight, colors.windowFrame, colors); } else { PaintFlatWorker(e, colors.buttonShadow, colors.buttonFace, colors.buttonShadow, colors); } } internal override void PaintOver(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonAdapter.PaintOver(e, Control.CheckState); return; } ColorData colors = PaintFlatRender(e.Graphics).Calculate(); if (Control.Enabled) { PaintFlatWorker(e, colors.windowText, colors.lowHighlight, colors.windowFrame, colors); } else { PaintFlatWorker(e, colors.buttonShadow, colors.buttonFace, colors.buttonShadow, colors); } } internal override void PaintUp(PaintEventArgs e, CheckState state) { if (Control.Appearance == Appearance.Button) { ButtonAdapter.PaintUp(e, Control.CheckState); return; } ColorData colors = PaintFlatRender(e.Graphics).Calculate(); if (Control.Enabled) { PaintFlatWorker(e, colors.windowText, colors.highlight, colors.windowFrame, colors); } else { PaintFlatWorker(e, colors.buttonShadow, colors.buttonFace, colors.buttonShadow, colors); } } private void PaintFlatWorker(PaintEventArgs e, Color checkColor, Color checkBackground, Color checkBorder, ColorData colors) { System.Drawing.Graphics g = e.Graphics; LayoutData layout = Layout(e).Layout(); PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckFlat(e, layout, checkColor, colors.options.highContrast ? colors.buttonFace : checkBackground, checkBorder, colors); PaintField(e, layout, colors, checkColor, true); } #region Layout private new ButtonFlatAdapter ButtonAdapter { get { return ((ButtonFlatAdapter)base.ButtonAdapter); } } protected override ButtonBaseAdapter CreateButtonAdapter() { return new ButtonFlatAdapter(Control); } protected override LayoutOptions Layout(PaintEventArgs e) { LayoutOptions layout = CommonLayout(); layout.checkSize = (int)(flatCheckSize * GetDpiScaleRatio(e.Graphics)); layout.shadowedText = false; 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
- ListViewDeletedEventArgs.cs
- TextTreeInsertUndoUnit.cs
- RenderContext.cs
- ToolStripPanel.cs
- ListDataBindEventArgs.cs
- MetadataCacheItem.cs
- MsmqProcessProtocolHandler.cs
- TransferRequestHandler.cs
- TemplateLookupAction.cs
- ProxyHelper.cs
- XamlPoint3DCollectionSerializer.cs
- ScriptMethodAttribute.cs
- CustomValidator.cs
- BaseParagraph.cs
- MaskDescriptors.cs
- FontFamilyIdentifier.cs
- ImageBrush.cs
- PageCodeDomTreeGenerator.cs
- OneToOneMappingSerializer.cs
- ToolStripRendererSwitcher.cs
- EarlyBoundInfo.cs
- Double.cs
- ChildChangedEventArgs.cs
- XmlQueryContext.cs
- EmptyQuery.cs
- RoleGroupCollectionEditor.cs
- RawStylusInputReport.cs
- Input.cs
- __Filters.cs
- PhysicalOps.cs
- Win32PrintDialog.cs
- TaskCanceledException.cs
- TimeIntervalCollection.cs
- HttpCacheVary.cs
- GroupJoinQueryOperator.cs
- ReadOnlyDictionary.cs
- SectionVisual.cs
- ColumnReorderedEventArgs.cs
- FeatureManager.cs
- XmlSchemaParticle.cs
- PreviewPrintController.cs
- WebPartConnectionCollection.cs
- BrowserCapabilitiesFactoryBase.cs
- BackStopAuthenticationModule.cs
- SQLGuid.cs
- VisualStyleElement.cs
- TemplateColumn.cs
- ScrollChrome.cs
- StructuralCache.cs
- OraclePermissionAttribute.cs
- XmlEventCache.cs
- ResXDataNode.cs
- DiagnosticTraceSource.cs
- HTMLTextWriter.cs
- X509Certificate2Collection.cs
- DrawingCollection.cs
- DateTimeFormat.cs
- SharedStatics.cs
- Attachment.cs
- RelationshipEndCollection.cs
- _SslState.cs
- RegexWriter.cs
- TargetControlTypeCache.cs
- HashCryptoHandle.cs
- ToolStripSplitButton.cs
- TcpChannelHelper.cs
- WebEvents.cs
- AutomationPatternInfo.cs
- DefaultValueTypeConverter.cs
- HttpEncoderUtility.cs
- XPathParser.cs
- RemotingException.cs
- wgx_exports.cs
- SystemIPInterfaceProperties.cs
- ResetableIterator.cs
- HtmlSelect.cs
- WebPartZoneCollection.cs
- ActivityExecutionContextCollection.cs
- Rect.cs
- SafeSecurityHelper.cs
- VBCodeProvider.cs
- GroupStyle.cs
- CreateUserWizardStep.cs
- Compiler.cs
- EnvironmentPermission.cs
- MetadataSource.cs
- WindowsUpDown.cs
- StretchValidation.cs
- SmtpException.cs
- BitmapEffect.cs
- QueryException.cs
- ToolStripComboBox.cs
- EventListenerClientSide.cs
- SqlReferenceCollection.cs
- ConstructorNeedsTagAttribute.cs
- ExpandCollapseProviderWrapper.cs
- CodeIterationStatement.cs
- TimeoutException.cs
- TargetException.cs
- SqlInternalConnectionTds.cs