Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / Workflow / Activities / Design / GradientPanel.cs / 1305376 / GradientPanel.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.Workflow.Activities.Design { using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D; internal partial class GradientPanel : Panel { protected Rectangle frameRect; private Color baseColor; private Color borderColor; private bool dropShadow; int glossHeight; private bool glossy; private Color lightingColor; private int radius; public GradientPanel() { BaseColor = Color.FromArgb(255, 255, 255, 255); LightingColor = Color.FromArgb(255, 176, 186, 196); Radius = 7; this.DoubleBuffered = true; } public Color BaseColor { get { return baseColor; } set { baseColor = value; } } public Color BorderColor { get { return borderColor; } set { borderColor = value; } } public bool DropShadow { get { return dropShadow; } set { dropShadow = value; } } public bool Glossy { get { return glossy; } set { glossy = value; } } public Color LightingColor { get { return lightingColor; } set { lightingColor = value; } } public int Radius { get { return radius; } set { radius = value; } } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); this.SuspendLayout(); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; if (DropShadow) { frameRect = new Rectangle(6, 0, this.Size.Width - 14, this.Size.Height - 8); } else { frameRect = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1); } frameRect.X -= Margin.Left; frameRect.Y -= Margin.Top; frameRect.Width += Margin.Left + Margin.Right; frameRect.Height += Margin.Top + Margin.Bottom; Rectangle shadowRect = new Rectangle(frameRect.X, frameRect.Y + 6, frameRect.Width, frameRect.Height - 5); glossHeight = frameRect.Height / 3; Brush glossBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Top + glossHeight + 1), Color.FromArgb(120, 255, 255, 255), Color.FromArgb(60, 255, 255, 255)); // SolidBrush(Color.FromArgb(32, 255, 255, 255)); Brush frameBrush = new LinearGradientBrush(new Point(frameRect.Left, frameRect.Top), new Point(frameRect.Left, frameRect.Bottom), BaseColor, LightingColor); Graphics outputGraphics = e.Graphics; if (DropShadow) { shadowRect = DropRoundedRectangleShadow(shadowRect, outputGraphics); } e.Graphics.FillPath(frameBrush, RoundedRect(frameRect)); if (Glossy) { e.Graphics.FillPath(glossBrush, RoundedRectTopHalf(frameRect)); } e.Graphics.DrawPath(new Pen(this.BorderColor), RoundedRect(frameRect)); this.ResumeLayout(); } private Rectangle DropRoundedRectangleShadow(Rectangle shadowRect, Graphics outputGraphics) { int shadowIntensity = 1; using (Pen shadowPen = new Pen(Color.FromArgb(shadowIntensity, 0, 0, 0))) { shadowPen.Width = 16; for (int i = 0; i < 8; i++) { outputGraphics.DrawPath(shadowPen, RoundedRect(shadowRect)); shadowPen.Color = Color.FromArgb(shadowIntensity - 1, 0, 0, 0); shadowIntensity += 8; shadowPen.Width = shadowPen.Width - 2;; } return shadowRect; } } private GraphicsPath RoundedRect(Rectangle frame) { GraphicsPath path = new GraphicsPath(); if (Radius < 1) { path.AddRectangle(frame); return path; } int diameter = Radius * 2; Rectangle arc = new Rectangle(frame.Left, frame.Top, diameter, diameter); path.AddArc(arc, 180, 90); arc.X = frame.Right - diameter; path.AddArc(arc, 270, 90); arc.Y = frame.Bottom - diameter; path.AddArc(arc, 0, 90); arc.X = frame.Left; path.AddArc(arc, 90, 90); path.CloseFigure(); return path; } private GraphicsPath RoundedRectTopHalf(Rectangle frame) { GraphicsPath path = new GraphicsPath(); int diameter = Radius * 2; Rectangle arc = new Rectangle(frame.Left, frame.Top, diameter, diameter); path.AddArc(arc, 180, 90); arc.X = frame.Right - diameter; path.AddArc(arc, 270, 90); path.AddLine(new Point(frame.Right, frame.Top + glossHeight), new Point(frame.Left, frame.Top + glossHeight)); path.CloseFigure(); return path; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UpdateException.cs
- FontWeightConverter.cs
- CounterSet.cs
- MobileTextWriter.cs
- MobileComponentEditorPage.cs
- ToolboxItem.cs
- ButtonPopupAdapter.cs
- BindValidator.cs
- AtlasWeb.Designer.cs
- GradientSpreadMethodValidation.cs
- CmsInterop.cs
- TcpProcessProtocolHandler.cs
- PerfCounters.cs
- TypeConverterAttribute.cs
- TimeoutTimer.cs
- DurableInstancingOptions.cs
- OdbcStatementHandle.cs
- HttpCacheVary.cs
- RoleManagerSection.cs
- Button.cs
- XamlWrappingReader.cs
- ListItem.cs
- TraversalRequest.cs
- AlphaSortedEnumConverter.cs
- Script.cs
- PageFunction.cs
- FamilyMapCollection.cs
- TypeSystem.cs
- Image.cs
- SqlFileStream.cs
- NoPersistHandle.cs
- SqlProvider.cs
- HttpDebugHandler.cs
- ElementProxy.cs
- SplashScreenNativeMethods.cs
- ArraySortHelper.cs
- DataControlField.cs
- EntityContainerEmitter.cs
- ItemMap.cs
- ScrollBarRenderer.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- MarshalByValueComponent.cs
- ProtectedProviderSettings.cs
- EventDescriptor.cs
- SiteOfOriginContainer.cs
- ButtonBase.cs
- AssemblyAssociatedContentFileAttribute.cs
- SimpleWebHandlerParser.cs
- FragmentNavigationEventArgs.cs
- WorkflowMarkupSerializationProvider.cs
- TableLayoutStyleCollection.cs
- SiteMapNodeItemEventArgs.cs
- DbConnectionPoolGroup.cs
- Paragraph.cs
- ChildChangedEventArgs.cs
- PolyQuadraticBezierSegmentFigureLogic.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- SqlConnectionPoolProviderInfo.cs
- DetailsViewPageEventArgs.cs
- MaterialCollection.cs
- AppModelKnownContentFactory.cs
- WindowHideOrCloseTracker.cs
- SelectionItemProviderWrapper.cs
- TrackingProfile.cs
- SelectionList.cs
- ErrorRuntimeConfig.cs
- StartFileNameEditor.cs
- WebPartConnectionsDisconnectVerb.cs
- BasicCellRelation.cs
- Perspective.cs
- ScrollItemProviderWrapper.cs
- DefaultParameterValueAttribute.cs
- ResourceSet.cs
- UseLicense.cs
- ExpressionParser.cs
- RelationshipEndMember.cs
- ZipIOCentralDirectoryBlock.cs
- SafeProcessHandle.cs
- DoubleIndependentAnimationStorage.cs
- WebDisplayNameAttribute.cs
- SerializationHelper.cs
- DocumentGrid.cs
- DataRelationCollection.cs
- GeneralTransform2DTo3DTo2D.cs
- _ShellExpression.cs
- HttpContextWrapper.cs
- COM2IDispatchConverter.cs
- ReadOnlyHierarchicalDataSource.cs
- WorkflowMarkupSerializationManager.cs
- IncrementalReadDecoders.cs
- WindowsListViewScroll.cs
- DesignerActionItemCollection.cs
- NamedObject.cs
- ListViewTableCell.cs
- SvcMapFileLoader.cs
- DataRowExtensions.cs
- AudioFileOut.cs
- DockProviderWrapper.cs
- RoutedEventArgs.cs
- ClientUrlResolverWrapper.cs