Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WinForms / System / WinForms / Design / PanelDesigner.cs / 1 / PanelDesigner.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms.Design { using System.ComponentModel; using System.Diagnostics; using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; using Microsoft.Win32; using System.Windows.Forms.Design.Behavior; ////// /// This class handles all design time behavior for the panel class. This /// draws a visible border on the panel if it doesn't have a border so the /// user knows where the boundaries of the panel lie. /// internal class PanelDesigner : ScrollableControlDesigner { public PanelDesigner() { AutoResizeHandles = true; } ////// /// This draws a nice border around our panel. We need /// this because the panel can have no border and you can't /// tell where it is. /// ///protected virtual void DrawBorder(Graphics graphics) { Panel panel = (Panel)Component; // if the panel is invisible, bail now if(panel == null || !panel.Visible) { return; } Pen pen = BorderPen; Rectangle rc = Control.ClientRectangle; rc.Width --; rc.Height--; graphics.DrawRectangle(pen, rc); pen.Dispose(); } /// /// /// Overrides our base class. Here we check to see if there /// is no border on the panel. If not, we draw one so that /// the panel shape is visible at design time. /// protected override void OnPaintAdornments(PaintEventArgs pe) { Panel panel = (Panel)Component; if (panel.BorderStyle == BorderStyle.None) { DrawBorder(pe.Graphics); } base.OnPaintAdornments(pe); } ////// Creates a Dashed-Pen of appropriate color. /// protected Pen BorderPen { get { Color penColor = Control.BackColor.GetBrightness() < .5 ? ControlPaint.Light(Control.BackColor) : ControlPaint.Dark(Control.BackColor); Pen pen = new Pen(penColor); pen.DashStyle = DashStyle.Dash; return pen; } } } } // 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
- NotCondition.cs
- StringAnimationUsingKeyFrames.cs
- UidPropertyAttribute.cs
- CompositeScriptReferenceEventArgs.cs
- DataServiceStreamResponse.cs
- EventMetadata.cs
- UriTemplate.cs
- ChildrenQuery.cs
- NativeCppClassAttribute.cs
- PathFigureCollection.cs
- Sql8ExpressionRewriter.cs
- PerfCounterSection.cs
- FrameworkRichTextComposition.cs
- QilExpression.cs
- TickBar.cs
- InstanceNameConverter.cs
- LinqDataSourceContextData.cs
- loginstatus.cs
- TrackBarRenderer.cs
- UnsafeNetInfoNativeMethods.cs
- TypefaceMap.cs
- AuthenticationSection.cs
- ZoomPercentageConverter.cs
- DataGridViewCellLinkedList.cs
- DependencyProperty.cs
- CompareValidator.cs
- NegationPusher.cs
- PageCache.cs
- DiscoveryClientElement.cs
- TerminatorSinks.cs
- ArraySubsetEnumerator.cs
- InlineCategoriesDocument.cs
- AdornerHitTestResult.cs
- WizardSideBarListControlItemEventArgs.cs
- Interfaces.cs
- AuthenticationModuleElement.cs
- PartialTrustHelpers.cs
- XsltFunctions.cs
- AppDomainFactory.cs
- EventListener.cs
- TableLayoutStyle.cs
- SmtpDigestAuthenticationModule.cs
- GroupStyle.cs
- CngProperty.cs
- XmlTextWriter.cs
- Int32Collection.cs
- MouseGestureValueSerializer.cs
- BoundField.cs
- MenuEventArgs.cs
- ContentTextAutomationPeer.cs
- DNS.cs
- DescriptionAttribute.cs
- UrlMappingCollection.cs
- Compensation.cs
- DelayedRegex.cs
- WaitHandleCannotBeOpenedException.cs
- EndpointConfigContainer.cs
- WorkflowItemsPresenter.cs
- FilteredXmlReader.cs
- PixelFormatConverter.cs
- LOSFormatter.cs
- WindowsListViewGroup.cs
- LinqToSqlWrapper.cs
- LocatorPartList.cs
- OdbcConnectionFactory.cs
- ObjectFullSpanRewriter.cs
- DataColumnMapping.cs
- ListItemCollection.cs
- DBNull.cs
- UnsafeNativeMethods.cs
- CodeTypeReferenceCollection.cs
- Condition.cs
- WebException.cs
- QueryableDataSourceHelper.cs
- MouseGestureConverter.cs
- MdImport.cs
- ReferenceEqualityComparer.cs
- DataBindingCollectionConverter.cs
- HierarchicalDataBoundControlAdapter.cs
- AppDomainFactory.cs
- Roles.cs
- DmlSqlGenerator.cs
- GridViewColumnHeader.cs
- ToolStripGrip.cs
- DataGridViewRowEventArgs.cs
- GridView.cs
- ConsoleCancelEventArgs.cs
- ListViewSelectEventArgs.cs
- DependencyProperty.cs
- ColorConvertedBitmap.cs
- BamlRecordReader.cs
- XmlSchemaAttributeGroupRef.cs
- EntityDataSourceSelectingEventArgs.cs
- ProxyManager.cs
- LogExtentCollection.cs
- ToolStripSplitButton.cs
- CustomLineCap.cs
- TextContainerChangeEventArgs.cs
- ButtonBase.cs
- PointUtil.cs