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
- OdbcRowUpdatingEvent.cs
- BufferedGraphicsContext.cs
- CustomExpression.cs
- EnlistmentState.cs
- IconHelper.cs
- XmlNamespaceMappingCollection.cs
- InstancePersistenceEvent.cs
- HierarchicalDataSourceConverter.cs
- DataGridViewImageColumn.cs
- Ray3DHitTestResult.cs
- PenCursorManager.cs
- CustomErrorsSectionWrapper.cs
- CapiHashAlgorithm.cs
- PageAsyncTaskManager.cs
- CodeComment.cs
- Bidi.cs
- SByteConverter.cs
- ScriptManager.cs
- DataBindingList.cs
- StateChangeEvent.cs
- FileRecordSequenceHelper.cs
- ObjectNotFoundException.cs
- ModelToObjectValueConverter.cs
- UrlMappingsSection.cs
- TimelineGroup.cs
- SqlDelegatedTransaction.cs
- DataBinding.cs
- DataControlImageButton.cs
- CharEnumerator.cs
- ClientFormsAuthenticationCredentials.cs
- LocalizableAttribute.cs
- BindingsCollection.cs
- DmlSqlGenerator.cs
- RuleSetCollection.cs
- MemberAccessException.cs
- SvcFileManager.cs
- SourceInterpreter.cs
- ObjectRef.cs
- HwndSourceParameters.cs
- Math.cs
- PerformanceCounter.cs
- DesignerDataSchemaClass.cs
- DataColumnMapping.cs
- FileLevelControlBuilderAttribute.cs
- XhtmlTextWriter.cs
- CategoryAttribute.cs
- GPStream.cs
- XmlUrlEditor.cs
- CriticalExceptions.cs
- cookiecontainer.cs
- TreeNode.cs
- X509Utils.cs
- CountdownEvent.cs
- PositiveTimeSpanValidatorAttribute.cs
- TableLayoutPanel.cs
- HtmlUtf8RawTextWriter.cs
- AffineTransform3D.cs
- GeometryHitTestParameters.cs
- ProfilePropertySettings.cs
- SQLDateTimeStorage.cs
- WebPartConnection.cs
- WebScriptEndpoint.cs
- RoleProviderPrincipal.cs
- SynchronizedInputAdaptor.cs
- WmlSelectionListAdapter.cs
- HttpConfigurationContext.cs
- PreservationFileWriter.cs
- ActivityXRefPropertyEditor.cs
- SemanticResultValue.cs
- ArrayItemReference.cs
- autovalidator.cs
- ExpressionTextBoxAutomationPeer.cs
- HitTestParameters3D.cs
- LogWriteRestartAreaState.cs
- Socket.cs
- ConfigsHelper.cs
- FramingDecoders.cs
- ClientApiGenerator.cs
- SchemaInfo.cs
- EventDescriptorCollection.cs
- MsmqInputChannelListenerBase.cs
- SafeLibraryHandle.cs
- WaitHandleCannotBeOpenedException.cs
- _LazyAsyncResult.cs
- Cloud.cs
- Main.cs
- MarshalByRefObject.cs
- HelpHtmlBuilder.cs
- LicenseManager.cs
- CalendarDesigner.cs
- DescendantQuery.cs
- ListParagraph.cs
- Operators.cs
- EncodingNLS.cs
- PreDigestedSignedInfo.cs
- XappLauncher.cs
- ClientData.cs
- ExpressionNormalizer.cs
- MsmqHostedTransportConfiguration.cs
- Base64Decoder.cs