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
- BinaryFormatterWriter.cs
- ApplicationServiceHelper.cs
- PropertyInfoSet.cs
- IncrementalReadDecoders.cs
- SqlProviderManifest.cs
- DataGridPagerStyle.cs
- CharacterMetrics.cs
- PolicyStatement.cs
- SmtpTransport.cs
- HttpFileCollection.cs
- CookieProtection.cs
- ServiceOperationViewControl.cs
- CrossSiteScriptingValidation.cs
- SendingRequestEventArgs.cs
- SessionSymmetricTransportSecurityProtocolFactory.cs
- CallbackValidatorAttribute.cs
- DataServiceQueryProvider.cs
- SqlDataSourceQueryEditorForm.cs
- ContextStack.cs
- ContainerUIElement3D.cs
- HandlerBase.cs
- TrackingRecord.cs
- RealizationContext.cs
- TargetPerspective.cs
- FileLogRecord.cs
- CreatingCookieEventArgs.cs
- TargetConverter.cs
- GradientStop.cs
- RunInstallerAttribute.cs
- updatecommandorderer.cs
- IUnknownConstantAttribute.cs
- XmlStreamNodeWriter.cs
- ContextMenu.cs
- SQLGuidStorage.cs
- DataGridColumnsPage.cs
- TabControlToolboxItem.cs
- ChildChangedEventArgs.cs
- SqlDataSourceCommandParser.cs
- WebPartDescriptionCollection.cs
- DetailsViewCommandEventArgs.cs
- InstanceContextMode.cs
- CommandHelper.cs
- IssuanceLicense.cs
- CalendarDesigner.cs
- EdgeModeValidation.cs
- SafeProcessHandle.cs
- ToolStripDropDownItem.cs
- BindingFormattingDialog.cs
- XamlFilter.cs
- RsaKeyIdentifierClause.cs
- StringComparer.cs
- KeyPullup.cs
- SqlBulkCopyColumnMappingCollection.cs
- CompiledRegexRunner.cs
- SqlCacheDependencySection.cs
- WebConvert.cs
- BitmapEffectGroup.cs
- DataGridCommandEventArgs.cs
- control.ime.cs
- DummyDataSource.cs
- BehaviorEditorPart.cs
- FixedDocumentPaginator.cs
- ProxyHelper.cs
- UnknownBitmapDecoder.cs
- AssertFilter.cs
- ServicePoint.cs
- DataRelation.cs
- Point4D.cs
- DataServiceRequest.cs
- Label.cs
- DefaultSection.cs
- HwndProxyElementProvider.cs
- GraphicsState.cs
- DbConnectionClosed.cs
- SchemaTypeEmitter.cs
- FormsAuthenticationModule.cs
- Rotation3DAnimation.cs
- ExternalCalls.cs
- TypeUtil.cs
- NewExpression.cs
- OracleLob.cs
- SourceFilter.cs
- LeftCellWrapper.cs
- LogEntryUtils.cs
- OverflowException.cs
- ViewBase.cs
- ChangeDirector.cs
- validation.cs
- CryptoHandle.cs
- XsdBuildProvider.cs
- XNodeNavigator.cs
- XmlExceptionHelper.cs
- TCPClient.cs
- ModuleBuilder.cs
- HwndTarget.cs
- IFlowDocumentViewer.cs
- PropertyDescriptor.cs
- PageCodeDomTreeGenerator.cs
- SecurityHeader.cs
- RepeaterItemCollection.cs