Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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. 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
- XamlSerializerUtil.cs
- SystemInformation.cs
- CqlParserHelpers.cs
- MultiTrigger.cs
- HTMLTextWriter.cs
- PropertyChangeTracker.cs
- XmlSchemaElement.cs
- PathSegment.cs
- IsolationInterop.cs
- ControlCachePolicy.cs
- LoadedOrUnloadedOperation.cs
- FlowLayoutPanel.cs
- MissingSatelliteAssemblyException.cs
- BitVector32.cs
- SerializableAttribute.cs
- TextChangedEventArgs.cs
- CollectionAdapters.cs
- InlineObject.cs
- ExtractorMetadata.cs
- NamespaceDisplay.xaml.cs
- AnnotationHelper.cs
- Type.cs
- OLEDB_Enum.cs
- UnmanagedMemoryStream.cs
- RadioButtonStandardAdapter.cs
- SymbolUsageManager.cs
- PersonalizationProvider.cs
- PkcsUtils.cs
- TextViewDesigner.cs
- GroupJoinQueryOperator.cs
- FirewallWrapper.cs
- ExpressionConverter.cs
- MultiAsyncResult.cs
- UIInitializationException.cs
- BaseTemplateCodeDomTreeGenerator.cs
- StickyNote.cs
- TreeViewEvent.cs
- XmlCharacterData.cs
- ProfileModule.cs
- ServiceModelActivity.cs
- HttpAsyncResult.cs
- Panel.cs
- ObjectStateEntry.cs
- MenuItemStyleCollection.cs
- InputLangChangeRequestEvent.cs
- EntityContainerEmitter.cs
- StringBuilder.cs
- AffineTransform3D.cs
- SwitchDesigner.xaml.cs
- Hex.cs
- UdpChannelListener.cs
- recordstate.cs
- TraceSource.cs
- SQLBytes.cs
- GridViewRow.cs
- ResourcePart.cs
- NavigationCommands.cs
- BaseValidator.cs
- StaticSiteMapProvider.cs
- Vector.cs
- ActivityIdHeader.cs
- ApplicationInterop.cs
- ServiceOperation.cs
- ItemCollection.cs
- KeyInfo.cs
- GregorianCalendarHelper.cs
- TextEncodedRawTextWriter.cs
- RegexCapture.cs
- SqlBulkCopyColumnMappingCollection.cs
- PagedDataSource.cs
- DirectoryNotFoundException.cs
- EntityConnection.cs
- ClientRoleProvider.cs
- SchemaCollectionPreprocessor.cs
- PersistenceIOParticipant.cs
- SoapInteropTypes.cs
- Win32Exception.cs
- DBSqlParserTable.cs
- MemberPathMap.cs
- MarkupWriter.cs
- FlowchartSizeFeature.cs
- HttpHandlerActionCollection.cs
- QueryServiceConfigHandle.cs
- EmptyEnumerator.cs
- CustomValidator.cs
- ListControlDataBindingHandler.cs
- Screen.cs
- TypeConverter.cs
- PointIndependentAnimationStorage.cs
- CodeSnippetTypeMember.cs
- RequestCachePolicy.cs
- RuntimeHelpers.cs
- LinqDataSourceValidationException.cs
- Size.cs
- XmlObjectSerializerReadContextComplexJson.cs
- FunctionOverloadResolver.cs
- DataBoundControl.cs
- MulticastOption.cs
- Pens.cs
- AppSettingsExpressionBuilder.cs