Code:
/ FX-1434 / FX-1434 / 1.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
- SHA384CryptoServiceProvider.cs
- Baml2006SchemaContext.cs
- IdentityHolder.cs
- DataSourceControlBuilder.cs
- Pointer.cs
- BitmapPalettes.cs
- CounterSampleCalculator.cs
- BindingList.cs
- ITreeGenerator.cs
- Point3DCollection.cs
- TypeViewSchema.cs
- SafeArchiveContext.cs
- CLSCompliantAttribute.cs
- Transform3D.cs
- OdbcConnectionHandle.cs
- XmlSchemaObject.cs
- DataGridViewComboBoxCell.cs
- EndPoint.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- XmlSchemaIdentityConstraint.cs
- XmlILModule.cs
- CriticalFinalizerObject.cs
- StyleBamlRecordReader.cs
- ClientCultureInfo.cs
- DataGridViewAutoSizeModeEventArgs.cs
- ParamArrayAttribute.cs
- CssClassPropertyAttribute.cs
- FrameworkRichTextComposition.cs
- DeferredSelectedIndexReference.cs
- MsmqIntegrationMessagePool.cs
- ZeroOpNode.cs
- PropertyIDSet.cs
- RegexCompiler.cs
- ProfileBuildProvider.cs
- Compiler.cs
- BufferedWebEventProvider.cs
- StyleXamlParser.cs
- StringArrayEditor.cs
- ImageListStreamer.cs
- GridErrorDlg.cs
- _BaseOverlappedAsyncResult.cs
- VersionedStream.cs
- Sequence.cs
- Condition.cs
- EditorPartCollection.cs
- TaiwanCalendar.cs
- TypePresenter.xaml.cs
- SelectingProviderEventArgs.cs
- InvalidCastException.cs
- XmlILConstructAnalyzer.cs
- MediaSystem.cs
- httpapplicationstate.cs
- ProtocolsConfigurationHandler.cs
- SendActivityDesigner.cs
- PartialArray.cs
- ChannelTokenTypeConverter.cs
- PeerName.cs
- DrawingGroup.cs
- Point.cs
- ColumnCollection.cs
- AnnouncementDispatcherAsyncResult.cs
- ComponentDispatcher.cs
- XmlDsigSep2000.cs
- DateTimeOffsetConverter.cs
- DataColumn.cs
- DesignerTransactionCloseEvent.cs
- TcpClientSocketManager.cs
- ListenerSingletonConnectionReader.cs
- DynamicDataManager.cs
- TrustLevelCollection.cs
- DataGridViewBand.cs
- AutoGeneratedField.cs
- DependencySource.cs
- FileAuthorizationModule.cs
- SynchronousReceiveElement.cs
- DecoratedNameAttribute.cs
- SimpleApplicationHost.cs
- MenuItemBindingCollection.cs
- TextFormatterContext.cs
- CompositionCommandSet.cs
- WindowsListViewScroll.cs
- AccessViolationException.cs
- QilScopedVisitor.cs
- EventSinkHelperWriter.cs
- RequestStatusBarUpdateEventArgs.cs
- OpCellTreeNode.cs
- RelatedEnd.cs
- MultiAsyncResult.cs
- LinqDataSourceInsertEventArgs.cs
- FillBehavior.cs
- UiaCoreProviderApi.cs
- WebFaultException.cs
- PropertyFilterAttribute.cs
- PropertyTab.cs
- CallContext.cs
- DesignerVerbCollection.cs
- XmlNodeList.cs
- SiteMapNodeItemEventArgs.cs
- ToolStripSplitButton.cs
- DataViewManagerListItemTypeDescriptor.cs