Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / WinForms / Managed / System / WinForms / ButtonInternal / RadioButtonStandardAdapter.cs / 1 / RadioButtonStandardAdapter.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 RadioButtonStandardAdapter : RadioButtonBaseAdapter {
internal RadioButtonStandardAdapter(ButtonBase control) : base(control) {}
internal override void PaintUp(PaintEventArgs e, CheckState state) {
if (Control.Appearance == Appearance.Button) {
ButtonAdapter.PaintUp(e, Control.Checked ? CheckState.Checked : CheckState.Unchecked);
}
else {
ColorData colors = PaintRender(e.Graphics).Calculate();
LayoutData layout = Layout(e).Layout();
PaintButtonBackground(e, Control.ClientRectangle, null);
PaintImage(e, layout);
DrawCheckBox(e, layout);
PaintField(e, layout, colors, colors.windowText, true);
}
}
internal override void PaintDown(PaintEventArgs e, CheckState state) {
if (Control.Appearance == Appearance.Button) {
ButtonAdapter.PaintDown(e, Control.Checked ? CheckState.Checked : CheckState.Unchecked);
}
else {
PaintUp(e, state);
}
}
internal override void PaintOver(PaintEventArgs e, CheckState state) {
if (Control.Appearance == Appearance.Button) {
ButtonAdapter.PaintOver(e, Control.Checked ? CheckState.Checked : CheckState.Unchecked);
}
else {
PaintUp(e, state);
}
}
private new ButtonStandardAdapter ButtonAdapter {
get {
return ((ButtonStandardAdapter)base.ButtonAdapter);
}
}
protected override ButtonBaseAdapter CreateButtonAdapter() {
return new ButtonStandardAdapter(Control);
}
#region Temp
protected override LayoutOptions Layout(PaintEventArgs e) {
LayoutOptions layout = CommonLayout();
layout.hintTextUp = false;
layout.everettButtonCompat = !Application.RenderWithVisualStyles;
// VSWhidbey 420870
if (Application.RenderWithVisualStyles) {
using (Graphics g = WindowsFormsUtils.CreateMeasurementGraphics()) {
layout.checkSize = RadioButtonRenderer.GetGlyphSize(g, RadioButtonRenderer.ConvertFromButtonState(GetState(), Control.MouseIsOver)).Width;
}
}
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 RadioButtonStandardAdapter : RadioButtonBaseAdapter {
internal RadioButtonStandardAdapter(ButtonBase control) : base(control) {}
internal override void PaintUp(PaintEventArgs e, CheckState state) {
if (Control.Appearance == Appearance.Button) {
ButtonAdapter.PaintUp(e, Control.Checked ? CheckState.Checked : CheckState.Unchecked);
}
else {
ColorData colors = PaintRender(e.Graphics).Calculate();
LayoutData layout = Layout(e).Layout();
PaintButtonBackground(e, Control.ClientRectangle, null);
PaintImage(e, layout);
DrawCheckBox(e, layout);
PaintField(e, layout, colors, colors.windowText, true);
}
}
internal override void PaintDown(PaintEventArgs e, CheckState state) {
if (Control.Appearance == Appearance.Button) {
ButtonAdapter.PaintDown(e, Control.Checked ? CheckState.Checked : CheckState.Unchecked);
}
else {
PaintUp(e, state);
}
}
internal override void PaintOver(PaintEventArgs e, CheckState state) {
if (Control.Appearance == Appearance.Button) {
ButtonAdapter.PaintOver(e, Control.Checked ? CheckState.Checked : CheckState.Unchecked);
}
else {
PaintUp(e, state);
}
}
private new ButtonStandardAdapter ButtonAdapter {
get {
return ((ButtonStandardAdapter)base.ButtonAdapter);
}
}
protected override ButtonBaseAdapter CreateButtonAdapter() {
return new ButtonStandardAdapter(Control);
}
#region Temp
protected override LayoutOptions Layout(PaintEventArgs e) {
LayoutOptions layout = CommonLayout();
layout.hintTextUp = false;
layout.everettButtonCompat = !Application.RenderWithVisualStyles;
// VSWhidbey 420870
if (Application.RenderWithVisualStyles) {
using (Graphics g = WindowsFormsUtils.CreateMeasurementGraphics()) {
layout.checkSize = RadioButtonRenderer.GetGlyphSize(g, RadioButtonRenderer.ConvertFromButtonState(GetState(), Control.MouseIsOver)).Width;
}
}
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
- WindowAutomationPeer.cs
- XmlSchemaSimpleContent.cs
- Drawing.cs
- FormatVersion.cs
- Calendar.cs
- DesignerAutoFormat.cs
- DataFormats.cs
- DependencySource.cs
- SqlCacheDependency.cs
- TreeViewImageKeyConverter.cs
- SelectionEditor.cs
- FrameworkTemplate.cs
- PackageFilter.cs
- Transform.cs
- ProtocolsConfigurationEntry.cs
- BinaryObjectInfo.cs
- DataObjectMethodAttribute.cs
- BrowserCapabilitiesFactoryBase.cs
- BaseInfoTable.cs
- IriParsingElement.cs
- SqlBulkCopy.cs
- SafeFileMappingHandle.cs
- GlyphCache.cs
- SqlXml.cs
- TableLayoutColumnStyleCollection.cs
- SweepDirectionValidation.cs
- FixedPageAutomationPeer.cs
- FontDriver.cs
- ScriptControl.cs
- DependencyPropertyConverter.cs
- TypeForwardedToAttribute.cs
- NetworkInformationException.cs
- AssemblyNameProxy.cs
- Mutex.cs
- NameSpaceEvent.cs
- MulticastIPAddressInformationCollection.cs
- NullRuntimeConfig.cs
- PersianCalendar.cs
- DbConnectionPool.cs
- _SSPISessionCache.cs
- WebServiceData.cs
- StringValueConverter.cs
- RewritingValidator.cs
- AsyncCallback.cs
- PopupRootAutomationPeer.cs
- CngKeyCreationParameters.cs
- ReferencedType.cs
- WebBrowserPermission.cs
- UrlPath.cs
- ExpressionBindingCollection.cs
- OLEDB_Util.cs
- AsyncOperation.cs
- DataReceivedEventArgs.cs
- PhonemeConverter.cs
- XhtmlBasicListAdapter.cs
- CustomErrorsSection.cs
- RoutedEventConverter.cs
- PropertyItemInternal.cs
- DbParameterHelper.cs
- EmptyQuery.cs
- TypeFieldSchema.cs
- OdbcFactory.cs
- IndexedWhereQueryOperator.cs
- LayoutDump.cs
- BooleanToVisibilityConverter.cs
- SiteIdentityPermission.cs
- WebEventCodes.cs
- ServiceNameCollection.cs
- DataTableMapping.cs
- HtmlEmptyTagControlBuilder.cs
- HttpStreams.cs
- WindowInteractionStateTracker.cs
- HelpOperationInvoker.cs
- DataServiceException.cs
- XamlPathDataSerializer.cs
- FtpWebResponse.cs
- ReadOnlyNameValueCollection.cs
- DocumentApplicationJournalEntryEventArgs.cs
- UriScheme.cs
- Vector3D.cs
- PropertyHelper.cs
- Brush.cs
- FormatterConverter.cs
- CustomAttributeFormatException.cs
- TiffBitmapDecoder.cs
- DecoratedNameAttribute.cs
- AstNode.cs
- BamlResourceContent.cs
- BitmapEffectInput.cs
- PersonalizablePropertyEntry.cs
- Dump.cs
- SimplePropertyEntry.cs
- ProtocolElementCollection.cs
- LineBreak.cs
- Helper.cs
- ADMembershipProvider.cs
- ColorConverter.cs
- AggregateNode.cs
- CompiledRegexRunner.cs
- XmlCharacterData.cs