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
- ImportContext.cs
- WebReference.cs
- OleDbTransaction.cs
- XmlSerializerVersionAttribute.cs
- DataKeyCollection.cs
- ExceptionValidationRule.cs
- CollectionExtensions.cs
- __ConsoleStream.cs
- AudienceUriMode.cs
- TimeSpanOrInfiniteConverter.cs
- DataBinder.cs
- DataAdapter.cs
- HtmlInputRadioButton.cs
- WebColorConverter.cs
- ConfigXmlText.cs
- CompositeDataBoundControl.cs
- CatalogZoneDesigner.cs
- StringArrayConverter.cs
- LicenseProviderAttribute.cs
- SynchronizedInputPattern.cs
- FirstMatchCodeGroup.cs
- OperationCanceledException.cs
- AutoResetEvent.cs
- DrawingState.cs
- ResXFileRef.cs
- SqlDataSource.cs
- TableLayoutCellPaintEventArgs.cs
- TextElement.cs
- LayoutTable.cs
- DataGridRelationshipRow.cs
- Html32TextWriter.cs
- MatrixIndependentAnimationStorage.cs
- OperationAbortedException.cs
- HostProtectionException.cs
- SRDisplayNameAttribute.cs
- CharacterMetrics.cs
- TextAutomationPeer.cs
- loginstatus.cs
- _PooledStream.cs
- _Semaphore.cs
- UTF8Encoding.cs
- ByteFacetDescriptionElement.cs
- PropertyItem.cs
- FreeFormDesigner.cs
- TransactedBatchingElement.cs
- EntityViewContainer.cs
- validation.cs
- GZipStream.cs
- coordinatorscratchpad.cs
- HttpDictionary.cs
- wgx_sdk_version.cs
- ApplicationDirectory.cs
- PropertyEmitterBase.cs
- Color.cs
- StateMachineWorkflow.cs
- DecoderBestFitFallback.cs
- SecureStringHasher.cs
- TypeToken.cs
- ControlUtil.cs
- PageCatalogPart.cs
- Configuration.cs
- OracleParameterBinding.cs
- XsdDateTime.cs
- ExpressionParser.cs
- ComponentSerializationService.cs
- recordstatescratchpad.cs
- FacetChecker.cs
- PeerApplicationLaunchInfo.cs
- FreeFormDragDropManager.cs
- StringWriter.cs
- LambdaExpression.cs
- DictionaryTraceRecord.cs
- TraceHwndHost.cs
- XmlSchemaAll.cs
- XmlSchemaNotation.cs
- ContainerParagraph.cs
- Int64KeyFrameCollection.cs
- StreamWithDictionary.cs
- LeafCellTreeNode.cs
- XmlCompatibilityReader.cs
- WebPartDisplayModeEventArgs.cs
- MimeReflector.cs
- NameValueCollection.cs
- OneOfScalarConst.cs
- SamlNameIdentifierClaimResource.cs
- DefaultAssemblyResolver.cs
- ValueConversionAttribute.cs
- String.cs
- GridViewPageEventArgs.cs
- DiagnosticTrace.cs
- GuidelineCollection.cs
- ArrangedElement.cs
- DataBindingList.cs
- XsdDataContractImporter.cs
- WorkflowDispatchContext.cs
- FamilyMapCollection.cs
- SqlFacetAttribute.cs
- MinMaxParagraphWidth.cs
- Command.cs
- ReadOnlyHierarchicalDataSource.cs