Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / ToolStripProfessionalLowResolutionRenderer.cs / 1305376 / 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. 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
- DataGridItem.cs
- SmtpFailedRecipientException.cs
- DrawingAttributes.cs
- DocumentGridContextMenu.cs
- DBSchemaTable.cs
- ObjectManager.cs
- QueryCreatedEventArgs.cs
- DetailsViewInsertedEventArgs.cs
- Aggregates.cs
- SqlNotificationRequest.cs
- MailBnfHelper.cs
- ContractCodeDomInfo.cs
- XmlSchemaInclude.cs
- Faults.cs
- CustomCredentialPolicy.cs
- CustomTypeDescriptor.cs
- CollectionEditor.cs
- PropertyFilterAttribute.cs
- UpdateProgress.cs
- ZipArchive.cs
- GeneralTransformGroup.cs
- ColorAnimation.cs
- XmlDocumentType.cs
- OutputScope.cs
- XamlFigureLengthSerializer.cs
- Material.cs
- Expander.cs
- DocumentPageView.cs
- ProcessingInstructionAction.cs
- listitem.cs
- NetStream.cs
- SQLBytes.cs
- ActivityMarkupSerializer.cs
- Image.cs
- DataGridViewDataErrorEventArgs.cs
- SR.cs
- ScopelessEnumAttribute.cs
- AssociatedControlConverter.cs
- FlagsAttribute.cs
- XmlDictionaryWriter.cs
- SystemIPInterfaceStatistics.cs
- XmlTextReaderImplHelpers.cs
- EndpointAddressAugust2004.cs
- MimeParameterWriter.cs
- EntityCommandDefinition.cs
- ADMembershipProvider.cs
- XmlValidatingReaderImpl.cs
- Stylus.cs
- LinkConverter.cs
- JobStaple.cs
- Mouse.cs
- SmiGettersStream.cs
- InfoCardSymmetricAlgorithm.cs
- ProcessProtocolHandler.cs
- DataFormats.cs
- WinEventQueueItem.cs
- KeyTime.cs
- Stream.cs
- RichTextBoxContextMenu.cs
- DataGridTableStyleMappingNameEditor.cs
- SerializableAttribute.cs
- OverlappedAsyncResult.cs
- EventData.cs
- ExternalCalls.cs
- TextEditorDragDrop.cs
- TrustManagerPromptUI.cs
- RowsCopiedEventArgs.cs
- DrawListViewItemEventArgs.cs
- XmlTextReaderImplHelpers.cs
- FileSystemInfo.cs
- DefaultAssemblyResolver.cs
- FactoryId.cs
- RegexParser.cs
- NetworkInformationPermission.cs
- AuthenticateEventArgs.cs
- XmlSerializableWriter.cs
- HttpRuntime.cs
- NameSpaceEvent.cs
- HtmlTableCell.cs
- SmtpMail.cs
- BuildProviderAppliesToAttribute.cs
- DragEventArgs.cs
- WpfKnownMember.cs
- TargetConverter.cs
- StorageEndPropertyMapping.cs
- AssemblySettingAttributes.cs
- ConnectionPointCookie.cs
- SHA512Managed.cs
- EntityKeyElement.cs
- loginstatus.cs
- Expr.cs
- GeometryConverter.cs
- PropertyPathWorker.cs
- ConstraintManager.cs
- BooleanAnimationUsingKeyFrames.cs
- DynamicResourceExtensionConverter.cs
- SourceFilter.cs
- ValuePatternIdentifiers.cs
- SchemaImporterExtension.cs
- ListViewInsertedEventArgs.cs