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
- InstanceOwnerQueryResult.cs
- MyContact.cs
- HostProtectionPermission.cs
- X509ChainPolicy.cs
- UpdateTranslator.cs
- XmlSchemaInclude.cs
- CoreSwitches.cs
- XmlJsonWriter.cs
- PeerApplication.cs
- DataTemplate.cs
- CurrentChangingEventManager.cs
- SessionEndingEventArgs.cs
- RemotingServices.cs
- SoapReflectionImporter.cs
- MinimizableAttributeTypeConverter.cs
- WSSecurityTokenSerializer.cs
- SymbolType.cs
- HttpProtocolReflector.cs
- DbDataRecord.cs
- ReadOnlyHierarchicalDataSourceView.cs
- SqlUtil.cs
- ExpressionEvaluator.cs
- AppSecurityManager.cs
- SyntaxCheck.cs
- TypeFieldSchema.cs
- AutomationElementIdentifiers.cs
- StorageScalarPropertyMapping.cs
- BuildDependencySet.cs
- SoapObjectReader.cs
- InvalidateEvent.cs
- RelatedView.cs
- RoleGroup.cs
- XmlDsigSep2000.cs
- PathParser.cs
- FormsIdentity.cs
- CodeAssignStatement.cs
- GetFileNameResult.cs
- MbpInfo.cs
- XamlValidatingReader.cs
- safelink.cs
- MsdtcWrapper.cs
- NotSupportedException.cs
- PrinterUnitConvert.cs
- FixedSOMPageConstructor.cs
- ControlValuePropertyAttribute.cs
- ListSortDescriptionCollection.cs
- FontFamilyIdentifier.cs
- DynamicMetaObject.cs
- ErrorLog.cs
- ImageSource.cs
- PersonalizableTypeEntry.cs
- MoveSizeWinEventHandler.cs
- TypeBuilder.cs
- Activity.cs
- Helper.cs
- SchemaMapping.cs
- RadioButtonList.cs
- DocumentPage.cs
- DataBindEngine.cs
- SizeIndependentAnimationStorage.cs
- SelectionRangeConverter.cs
- EdmTypeAttribute.cs
- PluralizationService.cs
- sqlinternaltransaction.cs
- DataGridAddNewRow.cs
- WindowPattern.cs
- SecurityKeyUsage.cs
- Itemizer.cs
- NativeMethods.cs
- RegexCapture.cs
- QueryOpcode.cs
- StreamInfo.cs
- UnsafeNativeMethods.cs
- ReturnEventArgs.cs
- PropertyInfoSet.cs
- ProcessInputEventArgs.cs
- AmbiguousMatchException.cs
- BitmapEffectvisualstate.cs
- OciHandle.cs
- BufferedStream2.cs
- DebuggerAttributes.cs
- Padding.cs
- ExtendedPropertyInfo.cs
- FontStyleConverter.cs
- BypassElement.cs
- DbConnectionHelper.cs
- ProcessProtocolHandler.cs
- WebPartTracker.cs
- TransactionScope.cs
- XmlHierarchyData.cs
- Region.cs
- ChtmlMobileTextWriter.cs
- XsltSettings.cs
- ControlBuilder.cs
- FusionWrap.cs
- NotifyParentPropertyAttribute.cs
- DbBuffer.cs
- Variable.cs
- PropertyTab.cs
- ListViewGroup.cs