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
- StyleXamlParser.cs
- ItemList.cs
- CodeNamespaceCollection.cs
- Mappings.cs
- ItemCheckedEvent.cs
- ZoneButton.cs
- SqlConnectionFactory.cs
- DataGridHeaderBorder.cs
- TriggerCollection.cs
- MonitoringDescriptionAttribute.cs
- StructuredTypeInfo.cs
- PlatformNotSupportedException.cs
- ToolboxItemCollection.cs
- XmlDataSourceView.cs
- ValueChangedEventManager.cs
- HelloMessage11.cs
- SqlAliaser.cs
- entityreference_tresulttype.cs
- ISAPIRuntime.cs
- ProfileSettingsCollection.cs
- ControlValuePropertyAttribute.cs
- MimeTypePropertyAttribute.cs
- WrapPanel.cs
- MobileUserControlDesigner.cs
- DataSourceHelper.cs
- EventProviderWriter.cs
- TextLineBreak.cs
- BulletChrome.cs
- OleCmdHelper.cs
- HScrollBar.cs
- HtmlTable.cs
- RowUpdatedEventArgs.cs
- XmlSchemaAnyAttribute.cs
- VersionValidator.cs
- CompiledELinqQueryState.cs
- SchemaAttDef.cs
- ViewPort3D.cs
- GridView.cs
- DeploymentSectionCache.cs
- DbFunctionCommandTree.cs
- RSAOAEPKeyExchangeFormatter.cs
- QilInvokeEarlyBound.cs
- XmlTextReaderImpl.cs
- DesignerVerb.cs
- ValueTypeFixupInfo.cs
- HighlightVisual.cs
- ClosableStream.cs
- AbandonedMutexException.cs
- CodeAttachEventStatement.cs
- sqlpipe.cs
- CacheMode.cs
- SafeTimerHandle.cs
- AdRotator.cs
- SmtpFailedRecipientsException.cs
- XamlVector3DCollectionSerializer.cs
- SamlConstants.cs
- VerifyHashRequest.cs
- WizardPanel.cs
- NameValueSectionHandler.cs
- SamlAuthorityBinding.cs
- AnnotationAdorner.cs
- SqlDataRecord.cs
- WebPartEditorApplyVerb.cs
- CreateParams.cs
- BufferedGraphicsContext.cs
- Registry.cs
- HostDesigntimeLicenseContext.cs
- TrustSection.cs
- IconConverter.cs
- ValidationHelper.cs
- InvalidBodyAccessException.cs
- PrimaryKeyTypeConverter.cs
- CompoundFileStreamReference.cs
- ConnectionStringsExpressionBuilder.cs
- Typography.cs
- EnumDataContract.cs
- UnmanagedBitmapWrapper.cs
- RegisteredDisposeScript.cs
- DrawListViewItemEventArgs.cs
- TransformGroup.cs
- ToolStripGripRenderEventArgs.cs
- MappingItemCollection.cs
- XslAst.cs
- DBSqlParserColumn.cs
- DataObjectFieldAttribute.cs
- Quad.cs
- XPathNavigatorReader.cs
- WindowsToolbarItemAsMenuItem.cs
- SourceSwitch.cs
- KeyGestureConverter.cs
- DataGridViewColumnStateChangedEventArgs.cs
- embossbitmapeffect.cs
- WriteableBitmap.cs
- DependencyPropertyValueSerializer.cs
- ServiceReflector.cs
- PointKeyFrameCollection.cs
- SafeRightsManagementEnvironmentHandle.cs
- ListViewItem.cs
- PageAsyncTask.cs
- QueryReaderSettings.cs