Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- XPathNode.cs
- exports.cs
- MSHTMLHost.cs
- ClientProtocol.cs
- UserControlAutomationPeer.cs
- recordstatescratchpad.cs
- ContentPlaceHolder.cs
- OleDragDropHandler.cs
- SimpleTypeResolver.cs
- CommandEventArgs.cs
- HtmlProps.cs
- Point3DCollection.cs
- _ProxyChain.cs
- ObjectKeyFrameCollection.cs
- AuthenticationModuleElement.cs
- OdbcReferenceCollection.cs
- TreeNodeConverter.cs
- HtmlValidationSummaryAdapter.cs
- DateTimeConverter.cs
- FixedSOMTableCell.cs
- CachingHintValidation.cs
- _TimerThread.cs
- ListBindableAttribute.cs
- XsdBuilder.cs
- CombinedGeometry.cs
- EventLogEntryCollection.cs
- MinimizableAttributeTypeConverter.cs
- BooleanStorage.cs
- GroupBoxRenderer.cs
- DynamicQueryableWrapper.cs
- SolidColorBrush.cs
- _OSSOCK.cs
- ZipIOExtraField.cs
- GlyphShapingProperties.cs
- LinqToSqlWrapper.cs
- Dictionary.cs
- AppDomainShutdownMonitor.cs
- SchemaObjectWriter.cs
- PrintPageEvent.cs
- TreeNodeBinding.cs
- Visual3D.cs
- SqlHelper.cs
- InsufficientExecutionStackException.cs
- Clause.cs
- AutomationPatternInfo.cs
- PointConverter.cs
- TagPrefixAttribute.cs
- AppDomainAttributes.cs
- DbConnectionOptions.cs
- ObjectListCommandsPage.cs
- RequestStatusBarUpdateEventArgs.cs
- StreamGeometryContext.cs
- LabelEditEvent.cs
- CanExecuteRoutedEventArgs.cs
- DesignOnlyAttribute.cs
- Run.cs
- _TimerThread.cs
- ChildChangedEventArgs.cs
- RemotingException.cs
- DispatchChannelSink.cs
- ConfigurationManagerHelper.cs
- httpstaticobjectscollection.cs
- ErrorFormatterPage.cs
- SerializationException.cs
- wmiprovider.cs
- PeerTransportListenAddressConverter.cs
- PackWebRequest.cs
- GenericRootAutomationPeer.cs
- PageBuildProvider.cs
- Int32CollectionConverter.cs
- UInt16Converter.cs
- RequiredFieldValidator.cs
- BitmapEffectCollection.cs
- ConfigXmlComment.cs
- DataGridLengthConverter.cs
- ThreadNeutralSemaphore.cs
- DataGridSortingEventArgs.cs
- AnimatedTypeHelpers.cs
- WhiteSpaceTrimStringConverter.cs
- AddressHeader.cs
- PenLineJoinValidation.cs
- RenamedEventArgs.cs
- CompatibleComparer.cs
- HttpDictionary.cs
- TracedNativeMethods.cs
- CmsInterop.cs
- PointAnimationUsingPath.cs
- LassoSelectionBehavior.cs
- PropertyGridCommands.cs
- EntityContainer.cs
- DbParameterHelper.cs
- PropertyEmitterBase.cs
- SQLUtility.cs
- ObjectQueryState.cs
- SourceInterpreter.cs
- DocumentGrid.cs
- StringCollection.cs
- InkPresenterAutomationPeer.cs
- ViewgenGatekeeper.cs
- CustomErrorCollection.cs