Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / ButtonInternal / CheckBoxFlatAdapter.cs / 1 / 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 = flatCheckSize;
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 = flatCheckSize;
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
- Partitioner.cs
- Bits.cs
- WindowsScroll.cs
- OleDbErrorCollection.cs
- XmlSchemaAttribute.cs
- NativeMethods.cs
- HttpHandlersSection.cs
- RouteValueDictionary.cs
- SID.cs
- MediaElementAutomationPeer.cs
- UniqueEventHelper.cs
- UIElementCollection.cs
- AssemblyHash.cs
- Utility.cs
- SignatureToken.cs
- UnmanagedBitmapWrapper.cs
- ReadingWritingEntityEventArgs.cs
- HttpStreamMessageEncoderFactory.cs
- FaultReasonText.cs
- SqlDataSourceSelectingEventArgs.cs
- Group.cs
- ValidationRuleCollection.cs
- ScriptResourceHandler.cs
- DataGridCellsPresenter.cs
- StringValueSerializer.cs
- DataContext.cs
- GeneralTransform.cs
- Token.cs
- ConcurrentBag.cs
- JournalEntry.cs
- ContractBase.cs
- JournalEntryListConverter.cs
- MdImport.cs
- TextEncodedRawTextWriter.cs
- DataObjectSettingDataEventArgs.cs
- ToolStripSystemRenderer.cs
- CurrentChangedEventManager.cs
- PassportAuthenticationEventArgs.cs
- InternalDispatchObject.cs
- LookupBindingPropertiesAttribute.cs
- AttachedAnnotation.cs
- AsyncContentLoadedEventArgs.cs
- ListViewDeletedEventArgs.cs
- JsonCollectionDataContract.cs
- LiteralControl.cs
- ConditionCollection.cs
- HttpFileCollection.cs
- DesignerForm.cs
- BaseDataListComponentEditor.cs
- WizardStepBase.cs
- assemblycache.cs
- HelpInfo.cs
- ButtonChrome.cs
- AssemblyCache.cs
- XPathBinder.cs
- CompilationRelaxations.cs
- SystemFonts.cs
- ellipse.cs
- LineBreak.cs
- Parameter.cs
- WebResponse.cs
- TableItemPattern.cs
- SpnEndpointIdentityExtension.cs
- ServiceChannel.cs
- Soap.cs
- EntityCollectionChangedParams.cs
- ParseElement.cs
- OleDbReferenceCollection.cs
- OdbcEnvironment.cs
- DbProviderFactory.cs
- XsdBuilder.cs
- ReferenceConverter.cs
- WebSysDescriptionAttribute.cs
- ToolboxItemFilterAttribute.cs
- InvokeAction.cs
- PropertyFilterAttribute.cs
- StringInfo.cs
- ScriptingRoleServiceSection.cs
- RuntimeConfig.cs
- DeferredElementTreeState.cs
- sqlnorm.cs
- ValueCollectionParameterReader.cs
- MetadataSerializer.cs
- Convert.cs
- AssemblyHash.cs
- EncoderExceptionFallback.cs
- VerticalAlignConverter.cs
- FontStyleConverter.cs
- ListViewCommandEventArgs.cs
- SqlConnectionFactory.cs
- OnOperation.cs
- Formatter.cs
- XsltCompileContext.cs
- StreamedWorkflowDefinitionContext.cs
- WorkflowWebHostingModule.cs
- XmlSortKey.cs
- TimeoutException.cs
- NegationPusher.cs
- StructuralObject.cs
- StylusTip.cs