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
- RightsManagementPermission.cs
- TableLayoutCellPaintEventArgs.cs
- TrustLevel.cs
- InvalidFilterCriteriaException.cs
- FrameworkRichTextComposition.cs
- ProfileSettingsCollection.cs
- PerformanceCounterPermission.cs
- mediaeventshelper.cs
- XNodeNavigator.cs
- EntityTransaction.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- ObservableCollection.cs
- LogReservationCollection.cs
- SmiContextFactory.cs
- ScaleTransform3D.cs
- TextTreeInsertElementUndoUnit.cs
- PointHitTestResult.cs
- SupportsEventValidationAttribute.cs
- HttpDateParse.cs
- InputElement.cs
- ADMembershipUser.cs
- SelectionChangedEventArgs.cs
- SerializationFieldInfo.cs
- CompositeActivityDesigner.cs
- PrintingPermission.cs
- DesignerDataSchemaClass.cs
- WindowsHyperlink.cs
- XPathAncestorQuery.cs
- TerminateSequenceResponse.cs
- CodeIdentifiers.cs
- ContentPlaceHolder.cs
- UInt16Converter.cs
- ZipIOCentralDirectoryFileHeader.cs
- HttpWriter.cs
- XMLUtil.cs
- AuthorizationSection.cs
- Html32TextWriter.cs
- ObjectIDGenerator.cs
- ComplexPropertyEntry.cs
- StylusButtonCollection.cs
- BaseInfoTable.cs
- Native.cs
- DbDataSourceEnumerator.cs
- EncoderParameters.cs
- CommandHelpers.cs
- Context.cs
- FormViewPageEventArgs.cs
- BaseResourcesBuildProvider.cs
- ListItem.cs
- XmlException.cs
- FileNotFoundException.cs
- CTreeGenerator.cs
- IndexingContentUnit.cs
- XmlSchemaInfo.cs
- ProcessStartInfo.cs
- PersonalizationStateInfo.cs
- Win32PrintDialog.cs
- LookupNode.cs
- XmlSchemaCompilationSettings.cs
- TaskHelper.cs
- SafeCryptoHandles.cs
- ResourceReader.cs
- ZipIOModeEnforcingStream.cs
- HiddenFieldPageStatePersister.cs
- XXXInfos.cs
- PnrpPermission.cs
- TextSpan.cs
- XmlNavigatorStack.cs
- ConnectorSelectionGlyph.cs
- ContextItemManager.cs
- RegexRunnerFactory.cs
- FileNameEditor.cs
- SrgsText.cs
- ValidationRule.cs
- QilDataSource.cs
- BinaryUtilClasses.cs
- SmiEventSink.cs
- loginstatus.cs
- XmlILModule.cs
- XPathChildIterator.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- InvalidFilterCriteriaException.cs
- ContentFilePart.cs
- HttpProcessUtility.cs
- X509CertificateStore.cs
- recordstate.cs
- DBSchemaRow.cs
- BitmapInitialize.cs
- AdRotator.cs
- RSAPKCS1KeyExchangeFormatter.cs
- SetStateEventArgs.cs
- WmfPlaceableFileHeader.cs
- State.cs
- StorageTypeMapping.cs
- SerializeAbsoluteContext.cs
- Wizard.cs
- TemplateField.cs
- WinFormsSpinner.cs
- CriticalExceptions.cs
- FieldNameLookup.cs