Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / ToolStripProfessionalLowResolutionRenderer.cs / 1 / ToolStripProfessionalLowResolutionRenderer.cs
namespace System.Windows.Forms {
using System;
using System.Drawing;
internal class ToolStripProfessionalLowResolutionRenderer : ToolStripProfessionalRenderer {
public ToolStripProfessionalLowResolutionRenderer() {
}
internal override ToolStripRenderer RendererOverride {
get {
return null;
}
}
protected override void OnRenderToolStripBackground(ToolStripRenderEventArgs e) {
if( e.ToolStrip is ToolStripDropDown ) {
base.OnRenderToolStripBackground(e);
}
}
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) {
if(e.ToolStrip is MenuStrip) {
return;
}
else if (e.ToolStrip is StatusStrip ) {
return;
}
else if (e.ToolStrip is ToolStripDropDown) {
base.OnRenderToolStripBorder(e);
}
else {
RenderToolStripBorderInternal(e);
}
}
private void RenderToolStripBorderInternal(ToolStripRenderEventArgs e) {
Rectangle bounds = new Rectangle(Point.Empty, e.ToolStrip.Size);
Graphics g = e.Graphics;
// have to create a pen here because we're not allowed to modify the SystemPens.
using( Pen p = new Pen(SystemColors.ButtonShadow) ) {
p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
bool oddWidth = ((bounds.Width & 0x1) == 0x1);
bool oddHeight = ((bounds.Height & 0x1) == 0x1);
int indent = 2;
// top
g.DrawLine(p, bounds.X + indent, bounds.Y, bounds.Width - 1, bounds.Y);
// bottom
g.DrawLine(p, bounds.X + indent, bounds.Height - 1, bounds.Width - 1, bounds.Height - 1);
// left
g.DrawLine(p, bounds.X, bounds.Y + indent, bounds.X, bounds.Height - 1);
// right
g.DrawLine(p, bounds.Width - 1, bounds.Y + indent, bounds.Width - 1, bounds.Height - 1);
// connecting pixels
// top left conntecting pixel - always drawn
g.FillRectangle(SystemBrushes.ButtonShadow, new Rectangle(1, 1, 1, 1));
if (oddWidth) {
// top right pixel
g.FillRectangle(SystemBrushes.ButtonShadow, new Rectangle(bounds.Width - 2, 1, 1, 1));
}
// bottom conntecting pixels - drawn only if height is odd
if(oddHeight) {
// bottom left
g.FillRectangle(SystemBrushes.ButtonShadow, new Rectangle(1, bounds.Height - 2, 1, 1));
}
// top and bottom right conntecting pixel - drawn only if height and width are odd
if( oddHeight && oddWidth ) {
// bottom right
g.FillRectangle(SystemBrushes.ButtonShadow, new Rectangle(bounds.Width - 2, bounds.Height - 2, 1, 1));
}
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ManagementEventArgs.cs
- InputDevice.cs
- DebugInfoGenerator.cs
- DataServiceContext.cs
- NativeMethods.cs
- SelfIssuedAuthProofToken.cs
- TemplatedMailWebEventProvider.cs
- FontNamesConverter.cs
- XPathNavigatorReader.cs
- TextEffectCollection.cs
- AffineTransform3D.cs
- RepeaterItem.cs
- ComEventsHelper.cs
- FrameworkElementFactory.cs
- TimeZoneNotFoundException.cs
- HtmlTableCellCollection.cs
- GZipDecoder.cs
- SelectionEditingBehavior.cs
- OleDbFactory.cs
- LocalizableResourceBuilder.cs
- WebPartDisplayModeEventArgs.cs
- InfiniteIntConverter.cs
- UserMapPath.cs
- Hex.cs
- EmptyReadOnlyDictionaryInternal.cs
- AccessibleObject.cs
- CaseStatement.cs
- TableItemStyle.cs
- MetabaseReader.cs
- Types.cs
- EntityDataSource.cs
- FormViewDeletedEventArgs.cs
- StateDesigner.LayoutSelectionGlyph.cs
- DataKey.cs
- UidManager.cs
- SafeLibraryHandle.cs
- MouseGesture.cs
- DropTarget.cs
- BuiltInExpr.cs
- EditorZoneBase.cs
- TemplateBindingExpressionConverter.cs
- TextTreeRootTextBlock.cs
- Win32MouseDevice.cs
- OleDbErrorCollection.cs
- Int32RectValueSerializer.cs
- SerialPort.cs
- TypedRowGenerator.cs
- XmlSerializerSection.cs
- Visitors.cs
- XAMLParseException.cs
- ModelVisual3D.cs
- WebOperationContext.cs
- X509CertificateClaimSet.cs
- NumericExpr.cs
- DirtyTextRange.cs
- ArrayList.cs
- TextAction.cs
- ProgressBarHighlightConverter.cs
- FileRegion.cs
- SortedList.cs
- ToolStripStatusLabel.cs
- XmlCDATASection.cs
- NumberAction.cs
- ParentUndoUnit.cs
- DesignerOptionService.cs
- ReplyChannelBinder.cs
- ResourceIDHelper.cs
- NumberSubstitution.cs
- Vector3DCollectionConverter.cs
- DiffuseMaterial.cs
- AttributeSetAction.cs
- FixedSOMLineRanges.cs
- CustomAssemblyResolver.cs
- RootDesignerSerializerAttribute.cs
- SqlCacheDependencyDatabaseCollection.cs
- CssStyleCollection.cs
- CommonProperties.cs
- PlaceHolder.cs
- ReadWriteObjectLock.cs
- COM2TypeInfoProcessor.cs
- WindowsUpDown.cs
- SimplePropertyEntry.cs
- SafeRegistryHandle.cs
- PeerToPeerException.cs
- StringUtil.cs
- PropertyEmitter.cs
- PersistChildrenAttribute.cs
- WeakReference.cs
- Hyperlink.cs
- BitmapPalette.cs
- NonParentingControl.cs
- DocumentPageHost.cs
- SmiEventSink_DeferedProcessing.cs
- XmlSubtreeReader.cs
- AuthorizationRuleCollection.cs
- SettingsBindableAttribute.cs
- PlanCompiler.cs
- MouseBinding.cs
- HttpAsyncResult.cs
- EdgeProfileValidation.cs