1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063 |
- // Licensed to the .NET Foundation under one or more agreements.
- // The .NET Foundation licenses this file to you under the MIT license.
- // See the LICENSE file in the project root for more information.
- //
- // Purpose: Classes that implement different 3D border styles.
- //
- using System;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- namespace FastReport.DataVisualization.Charting.Borders3D
- {
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle1Border : FrameThin1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle1Border()
- {
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize*2f);
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle1";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize * 2f);
- }
- }
- /// <summary>
- /// Returns the position of the rectangular area in the border where
- /// title should be displayed. Returns empty rect if title can't be shown in the border.
- /// </summary>
- /// <returns>Title position in border.</returns>
- public override RectangleF GetTitlePositionInBorder()
- {
- return new RectangleF(
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 1.6f);
- }
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle2Border : FrameThin2Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle2Border()
- {
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize*2f);
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle2";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize * 2f);
- }
- }
- /// <summary>
- /// Returns the position of the rectangular area in the border where
- /// title should be displayed. Returns empty rect if title can't be shown in the border.
- /// </summary>
- /// <returns>Title position in border.</returns>
- public override RectangleF GetTitlePositionInBorder()
- {
- return new RectangleF(
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 1.6f);
- }
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle3Border : FrameThin3Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle3Border()
- {
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize*2f);
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle3";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize * 2f);
- }
- }
- /// <summary>
- /// Returns the position of the rectangular area in the border where
- /// title should be displayed. Returns empty rect if title can't be shown in the border.
- /// </summary>
- /// <returns>Title position in border.</returns>
- public override RectangleF GetTitlePositionInBorder()
- {
- return new RectangleF(
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 1.6f);
- }
- #endregion
- }
-
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle4Border : FrameThin4Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle4Border()
- {
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize*2f);
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle4";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize * 2f);
- }
- }
- /// <summary>
- /// Returns the position of the rectangular area in the border where
- /// title should be displayed. Returns empty rect if title can't be shown in the border.
- /// </summary>
- /// <returns>Title position in border.</returns>
- public override RectangleF GetTitlePositionInBorder()
- {
- return new RectangleF(
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 1.6f);
- }
-
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle5Border : FrameThin5Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle5Border()
- {
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize*2f);
- this.drawScrews = true;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle5";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize * 2f);
- }
- }
- /// <summary>
- /// Returns the position of the rectangular area in the border where
- /// title should be displayed. Returns empty rect if title can't be shown in the border.
- /// </summary>
- /// <returns>Title position in border.</returns>
- public override RectangleF GetTitlePositionInBorder()
- {
- return new RectangleF(
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 1.6f);
- }
-
- #endregion
- }
-
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle6Border : FrameThin6Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle6Border()
- {
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize*2f);
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle6";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- sizeLeftTop = new SizeF(sizeLeftTop.Width, defaultRadiusSize * 2f);
- }
- }
- /// <summary>
- /// Returns the position of the rectangular area in the border where
- /// title should be displayed. Returns empty rect if title can't be shown in the border.
- /// </summary>
- /// <returns>Title position in border.</returns>
- public override RectangleF GetTitlePositionInBorder()
- {
- return new RectangleF(
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 0.25f,
- defaultRadiusSize * 1.6f);
- }
-
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle7Border : FrameTitle1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle7Border()
- {
- this.sizeRightBottom = new SizeF(0, sizeRightBottom.Height);
- float[] corners = {15f, 1f, 1f, 1f, 1f, 15f, 15f, 15f};
- innerCorners = corners;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle7";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- this.sizeRightBottom = new SizeF(0, sizeRightBottom.Height);
- float largeRadius = 15f * resolution / 96.0f;
- float smallRadius = 1 * resolution / 96.0f;
- float[] corners = { largeRadius, smallRadius, smallRadius, smallRadius, smallRadius, largeRadius, largeRadius, largeRadius };
- innerCorners = corners;
- }
- }
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameTitle8Border : FrameTitle1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameTitle8Border()
- {
- this.sizeLeftTop = new SizeF(0, sizeLeftTop.Height);
- this.sizeRightBottom = new SizeF(0, sizeRightBottom.Height);
- float[] corners = {1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f};
- innerCorners = corners;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameTitle8";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- this.sizeLeftTop = new SizeF(0, sizeLeftTop.Height);
- this.sizeRightBottom = new SizeF(0, sizeRightBottom.Height);
- float radius = 1 * resolution / 96.0f;
- float[] corners = { radius, radius, radius, radius, radius, radius, radius, radius };
- innerCorners = corners;
- }
- }
- #endregion
- }
-
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameThin2Border : FrameThin1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameThin2Border()
- {
- float[] corners = {15f, 15f, 15f, 1f, 1f, 1f, 1f, 15f};
- cornerRadius = corners;
- innerCorners = corners;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameThin2";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- float largeRadius = 15f * resolution / 96.0f;
- float smallRadius = 1 * resolution / 96.0f;
- float[] corners = { largeRadius, largeRadius, largeRadius, smallRadius, smallRadius, smallRadius, smallRadius, largeRadius };
- cornerRadius = corners;
- innerCorners = corners;
- }
- }
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameThin3Border : FrameThin1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameThin3Border()
- {
- float[] corners = {1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f};
- cornerRadius = corners;
- innerCorners = corners;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameThin3";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- float radius = resolution / 96.0f;
- float[] corners = { radius, radius, radius, radius, radius, radius, radius, radius };
- cornerRadius = corners;
- innerCorners = corners;
- }
- }
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameThin4Border : FrameThin1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameThin4Border()
- {
- float[] corners = {1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f};
- cornerRadius = corners;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameThin4";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- float radius = 1f * resolution / 96.0f;
- cornerRadius = new float[] { radius, radius, radius, radius, radius, radius, radius, radius };
- }
- }
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameThin5Border : FrameThin1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameThin5Border()
- {
- drawScrews = true;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameThin5";}}
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameThin6Border : FrameThin1Border
- {
- #region Border properties and methods
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameThin6Border()
- {
- float[] corners = {1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f};
- innerCorners = corners;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameThin6";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- float radius = resolution / 96.0f;
- float[] corners = { radius, radius, radius, radius, radius, radius, radius, radius };
- innerCorners = corners;
- }
- }
- #endregion
- }
- /// <summary>
- /// Implements frame border.
- /// </summary>
- internal class FrameThin1Border : RaisedBorder
- {
- #region Border properties and methods
- /// <summary>
- /// Inner corners radius array
- /// </summary>
- internal float[] innerCorners = { 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f };
- /// <summary>
- /// Default constructor
- /// </summary>
- public FrameThin1Border()
- {
- sizeLeftTop = new SizeF(defaultRadiusSize * .8f, defaultRadiusSize * .8f);
- sizeRightBottom = new SizeF(defaultRadiusSize * .8f, defaultRadiusSize * .8f);
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "FrameThin1";}}
- public override float Resolution
- {
- set
- {
- base.Resolution = value;
- float radius = 15.0f * resolution / 96.0f;
- innerCorners = new float[] { radius, radius, radius, radius, radius, radius, radius, radius };
- sizeLeftTop = new SizeF(defaultRadiusSize * .8f, defaultRadiusSize * .8f);
- sizeRightBottom = new SizeF(defaultRadiusSize * .8f, defaultRadiusSize * .8f);
- }
- }
- /// <summary>
- /// Draws 3D border.
- /// </summary>
- /// <param name="graph">Graphics to draw the border on.</param>
- /// <param name="borderSkin">Border skin object.</param>
- /// <param name="rect">Rectangle of the border.</param>
- /// <param name="backColor">Color of rectangle</param>
- /// <param name="backHatchStyle">Hatch style</param>
- /// <param name="backImage">Back Image</param>
- /// <param name="backImageWrapMode">Image mode</param>
- /// <param name="backImageTransparentColor">Image transparent color.</param>
- /// <param name="backImageAlign">Image alignment</param>
- /// <param name="backGradientStyle">Gradient type</param>
- /// <param name="backSecondaryColor">Gradient End Color</param>
- /// <param name="borderColor">Border Color</param>
- /// <param name="borderWidth">Border Width</param>
- /// <param name="borderDashStyle">Border Style</param>
- public override void DrawBorder(
- ChartGraphics graph,
- BorderSkin borderSkin,
- RectangleF rect,
- Color backColor,
- ChartHatchStyle backHatchStyle,
- string backImage,
- ChartImageWrapMode backImageWrapMode,
- Color backImageTransparentColor,
- ChartImageAlignmentStyle backImageAlign,
- GradientStyle backGradientStyle,
- Color backSecondaryColor,
- Color borderColor,
- int borderWidth,
- ChartDashStyle borderDashStyle)
- {
- drawBottomShadow = true;
- sunken = false;
- outsideShadowRate = .9f;
- drawOutsideTopLeftShadow = false;
- bool oldScrewsFlag = this.drawScrews;
- this.drawScrews = false;
- base.DrawBorder(
- graph,
- borderSkin,
- rect,
- borderSkin.BackColor,
- borderSkin.BackHatchStyle,
- borderSkin.BackImage,
- borderSkin.BackImageWrapMode,
- borderSkin.BackImageTransparentColor,
- borderSkin.BackImageAlignment,
- borderSkin.BackGradientStyle,
- borderSkin.BackSecondaryColor,
- borderSkin.BorderColor,
- borderSkin.BorderWidth,
- borderSkin.BorderDashStyle);
- this.drawScrews = oldScrewsFlag;
- rect.X += sizeLeftTop.Width;
- rect.Y += sizeLeftTop.Height;
- rect.Width -= sizeRightBottom.Width + sizeLeftTop.Width;
- rect.Height -= sizeRightBottom.Height + sizeLeftTop.Height;
- if(rect.Width > 0 && rect.Height > 0 )
- {
- float[] oldCorners = new float[8];
- oldCorners = (float[])cornerRadius.Clone();
- cornerRadius = innerCorners;
- drawBottomShadow = false;
- sunken = true;
- drawOutsideTopLeftShadow = true;
- outsideShadowRate = 1.4f;
- Color oldPageColor = borderSkin.PageColor;
- borderSkin.PageColor = Color.Transparent;
- base.DrawBorder(
- graph,
- borderSkin,
- rect,
- backColor,
- backHatchStyle,
- backImage,
- backImageWrapMode,
- backImageTransparentColor,
- backImageAlign,
- backGradientStyle,
- backSecondaryColor,
- borderColor,
- borderWidth,
- borderDashStyle );
- borderSkin.PageColor = oldPageColor;
- cornerRadius = oldCorners;
- }
- }
- #endregion
- }
- /// <summary>
- /// Implements raised border.
- /// </summary>
- internal class RaisedBorder : SunkenBorder
- {
- #region Border properties and methods
- /// <summary>
- /// Public constructor
- /// </summary>
- public RaisedBorder()
- {
- sunken = false;
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public override string Name { get{ return "Raised";}}
- #endregion
- }
- /// <summary>
- /// Implements embed 3D border.
- /// </summary>
- internal class SunkenBorder : IBorderType
- {
- #region Border properties and methods
- /// <summary>
- /// Radius for rounded rectangle
- /// </summary>
- internal float defaultRadiusSize = 15f;
- /// <summary>
- /// Outside shadow rate
- /// </summary>
- internal float outsideShadowRate = .9f;
-
- /// <summary>
- /// Indicates that sunken shadows should be drawn
- /// </summary>
- internal bool sunken = true;
- /// <summary>
- /// Indicates that bottom shadow should be drawn
- /// </summary>
- internal bool drawBottomShadow = true;
- /// <summary>
- /// Indicates that top left outside dark shadow must be drawn
- /// </summary>
- internal bool drawOutsideTopLeftShadow = false;
- /// <summary>
- /// Array of corner radius
- /// </summary>
- internal float[] cornerRadius = { 15f, 15f, 15f, 15f, 15f, 15f, 15f, 15f };
- /// <summary>
- /// Border top/left size
- /// </summary>
- internal SizeF sizeLeftTop = SizeF.Empty;
- /// <summary>
- /// Border right/bottom size
- /// </summary>
- internal SizeF sizeRightBottom = SizeF.Empty;
- /// <summary>
- /// Indicates that screws should be drawn in the corners of the frame
- /// </summary>
- internal bool drawScrews = false;
- internal float resolution = 96f;
- /// <summary>
- /// Public constructor
- /// </summary>
- public SunkenBorder()
- {
- }
- /// <summary>
- /// Chart type name
- /// </summary>
- public virtual string Name { get{ return "Sunken";}}
- public virtual float Resolution
- {
- set
- {
- resolution = value;
- defaultRadiusSize = 15 * resolution / 96;
- //X = defaultRadiusSize;
- //Y = defaultRadiusSize;
- cornerRadius = new float[] { defaultRadiusSize, defaultRadiusSize, defaultRadiusSize, defaultRadiusSize, defaultRadiusSize, defaultRadiusSize, defaultRadiusSize, defaultRadiusSize };
- }
- }
- /// <summary>
- /// Returns the position of the rectangular area in the border where
- /// title should be displayed. Returns empty rect if title can't be shown in the border.
- /// </summary>
- /// <returns>Title position in border.</returns>
- public virtual RectangleF GetTitlePositionInBorder()
- {
- return RectangleF.Empty;
- }
- /// <summary>
- /// Adjust areas rectangle coordinate to fit the 3D border
- /// </summary>
- /// <param name="graph">Graphics to draw the border on.</param>
- /// <param name="areasRect">Position to adjust.</param>
- public virtual void AdjustAreasPosition(ChartGraphics graph, ref RectangleF areasRect)
- {
- SizeF relSizeLeftTop = new SizeF(sizeLeftTop);
- SizeF relSizeRightBottom = new SizeF(sizeRightBottom);
- relSizeLeftTop.Width += defaultRadiusSize * 0.7f;
- relSizeLeftTop.Height += defaultRadiusSize * 0.85f;
- relSizeRightBottom.Width += defaultRadiusSize * 0.7f;
- relSizeRightBottom.Height += defaultRadiusSize * 0.7f;
- relSizeLeftTop = graph.GetRelativeSize(relSizeLeftTop);
- relSizeRightBottom = graph.GetRelativeSize(relSizeRightBottom);
- if(relSizeLeftTop.Width > 30f)
- relSizeLeftTop.Width = 0;
- if(relSizeLeftTop.Height > 30f)
- relSizeLeftTop.Height = 0;
- if(relSizeRightBottom.Width > 30f)
- relSizeRightBottom.Width = 0;
- if(relSizeRightBottom.Height > 30f)
- relSizeRightBottom.Height = 0;
- areasRect.X += relSizeLeftTop.Width;
- areasRect.Width -= (float)Math.Min(areasRect.Width, relSizeLeftTop.Width + relSizeRightBottom.Width);
- areasRect.Y += relSizeLeftTop.Height;
- areasRect.Height -= (float)Math.Min(areasRect.Height, relSizeLeftTop.Height + relSizeRightBottom.Height);
- if(areasRect.Right > 100f)
- {
- if(areasRect.Width > 100f - areasRect.Right)
- areasRect.Width -= 100f - areasRect.Right;
- else
- areasRect.X -= 100f - areasRect.Right;
- }
- if(areasRect.Bottom > 100f)
- {
- if(areasRect.Height > 100f - areasRect.Bottom)
- areasRect.Height -= 100f - areasRect.Bottom;
- else
- areasRect.Y -= 100f - areasRect.Bottom;
- }
- }
- /// <summary>
- /// Draws 3D border
- /// </summary>
- /// <param name="graph">Graphics to draw the border on.</param>
- /// <param name="borderSkin">Border skin object.</param>
- /// <param name="rect">Rectangle of the border.</param>
- /// <param name="backColor">Color of rectangle</param>
- /// <param name="backHatchStyle">Hatch style</param>
- /// <param name="backImage">Back Image</param>
- /// <param name="backImageWrapMode">Image mode</param>
- /// <param name="backImageTransparentColor">Image transparent color.</param>
- /// <param name="backImageAlign">Image alignment</param>
- /// <param name="backGradientStyle">Gradient type</param>
- /// <param name="backSecondaryColor">Gradient End Color</param>
- /// <param name="borderColor">Border Color</param>
- /// <param name="borderWidth">Border Width</param>
- /// <param name="borderDashStyle">Border Style</param>
- public virtual void DrawBorder(
- ChartGraphics graph,
- BorderSkin borderSkin,
- RectangleF rect,
- Color backColor,
- ChartHatchStyle backHatchStyle,
- string backImage,
- ChartImageWrapMode backImageWrapMode,
- Color backImageTransparentColor,
- ChartImageAlignmentStyle backImageAlign,
- GradientStyle backGradientStyle,
- Color backSecondaryColor,
- Color borderColor,
- int borderWidth,
- ChartDashStyle borderDashStyle)
- {
- RectangleF absolute = graph.Round( rect );
- RectangleF shadowRect = absolute;
- // Calculate shadow colors (0.2 - 0.6)
- float colorDarkeningIndex = 0.3f + (0.4f * (borderSkin.PageColor.R + borderSkin.PageColor.G + borderSkin.PageColor.B) / 765f);
- Color shadowColor = Color.FromArgb(
- (int)(backColor.R*colorDarkeningIndex),
- (int)(backColor.G*colorDarkeningIndex),
- (int)(backColor.B*colorDarkeningIndex));
- colorDarkeningIndex += 0.2f;
- Color shadowLightColor = Color.FromArgb(
- (int)(borderSkin.PageColor.R*colorDarkeningIndex),
- (int)(borderSkin.PageColor.G*colorDarkeningIndex),
- (int)(borderSkin.PageColor.B*colorDarkeningIndex));
- if(borderSkin.PageColor == Color.Transparent)
- {
- shadowLightColor = Color.FromArgb(60, 0, 0, 0);
- }
-
- // Calculate rounded rect radius
- float radius = defaultRadiusSize;
- radius = (float)Math.Max(radius, 2f * resolution / 96.0f);
- radius = (float)Math.Min(radius, rect.Width/2f);
- radius = (float)Math.Min(radius, rect.Height/2f);
- radius = (float)Math.Ceiling(radius);
- // Fill page background color
- using (Brush brush = new SolidBrush(borderSkin.PageColor))
- {
- graph.FillRectangle(brush, rect);
- }
- if(drawOutsideTopLeftShadow)
- {
- // Top/Left outside shadow
- shadowRect = absolute;
- shadowRect.X -= radius * 0.3f;
- shadowRect.Y -= radius * 0.3f;
- shadowRect.Width -= radius * .3f;
- shadowRect.Height -= radius * .3f;
- graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, Color.FromArgb(128, Color.Black), borderSkin.PageColor, outsideShadowRate);
- }
- // Bottom/Right outside shadow
- shadowRect = absolute;
- shadowRect.X += radius * 0.3f;
- shadowRect.Y += radius * 0.3f;
- shadowRect.Width -= radius * .3f;
- shadowRect.Height -= radius * .3f;
- graph.DrawRoundedRectShadowAbs(shadowRect, cornerRadius, radius, shadowLightColor, borderSkin.PageColor, outsideShadowRate);
- // Background
- shadowRect = absolute;
- shadowRect.Width -= radius * .3f;
- shadowRect.Height -= radius * .3f;
- GraphicsPath path = graph.CreateRoundedRectPath(shadowRect, cornerRadius);
- graph.DrawPathAbs(
- path,
- backColor,
- backHatchStyle,
- backImage,
- backImageWrapMode,
- backImageTransparentColor,
- backImageAlign,
- backGradientStyle,
- backSecondaryColor,
- borderColor,
- borderWidth,
- borderDashStyle,
- PenAlignment.Inset );
- // Dispose Graphic path
- if( path != null )
- path.Dispose();
- // Draw screws imitation in the corners of the farame
- if(drawScrews)
- {
- // Left/Top screw
- RectangleF screwRect = RectangleF.Empty;
- float offset = radius * 0.4f;
- screwRect.X = shadowRect.X + offset;
- screwRect.Y = shadowRect.Y + offset;
- screwRect.Width = radius * 0.55f;
- screwRect.Height = screwRect.Width;
- DrawScrew(graph, screwRect);
- // Right/Top screw
- screwRect.X = shadowRect.Right - offset - screwRect.Width;
- DrawScrew(graph, screwRect);
- // Right/Bottom screw
- screwRect.X = shadowRect.Right - offset - screwRect.Width;
- screwRect.Y = shadowRect.Bottom - offset - screwRect.Height;
- DrawScrew(graph, screwRect);
-
- // Left/Bottom screw
- screwRect.X = shadowRect.X + offset;
- screwRect.Y = shadowRect.Bottom - offset - screwRect.Height;
- DrawScrew(graph, screwRect);
- }
- // Bottom/Right inner shadow
- Region innerShadowRegion = null;
- if(drawBottomShadow)
- {
- shadowRect = absolute;
- shadowRect.Width -= radius * .3f;
- shadowRect.Height -= radius * .3f;
- innerShadowRegion = new Region(
- graph.CreateRoundedRectPath(
- new RectangleF(
- shadowRect.X - radius,
- shadowRect.Y - radius,
- shadowRect.Width + 0.5f*radius,
- shadowRect.Height + 0.5f*radius),
- cornerRadius));
- innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowRect, cornerRadius));
- graph.Clip = innerShadowRegion;
- shadowRect.X -= 0.5f*radius;
- shadowRect.Width += 0.5f*radius;
- shadowRect.Y -= 0.5f*radius;
- shadowRect.Height += 0.5f*radius;
- graph.DrawRoundedRectShadowAbs(
- shadowRect,
- cornerRadius,
- radius,
- Color.Transparent,
- Color.FromArgb(175, (sunken) ? Color.White : shadowColor),
- 1.0f);
- graph.Clip = new Region();
- }
- // Top/Left inner shadow
- shadowRect = absolute;
- shadowRect.Width -= radius * .3f;
- shadowRect.Height -= radius * .3f;
- innerShadowRegion = new Region(
- graph.CreateRoundedRectPath(
- new RectangleF(
- shadowRect.X + radius*.5f,
- shadowRect.Y + radius*.5f,
- shadowRect.Width - .2f*radius,
- shadowRect.Height - .2f*radius),
- cornerRadius));
- RectangleF shadowWithOffset = shadowRect;
- shadowWithOffset.Width += radius;
- shadowWithOffset.Height += radius;
- innerShadowRegion.Complement(graph.CreateRoundedRectPath(shadowWithOffset, cornerRadius));
-
- innerShadowRegion.Intersect(graph.CreateRoundedRectPath(shadowRect, cornerRadius));
- graph.Clip = innerShadowRegion;
- graph.DrawRoundedRectShadowAbs(
- shadowWithOffset,
- cornerRadius,
- radius,
- Color.Transparent,
- Color.FromArgb(175, (sunken) ? shadowColor : Color.White),
- 1.0f);
- graph.Clip = new Region();
- }
- /// <summary>
- /// Helper function, which draws a screw on the frame
- /// </summary>
- /// <param name="graph">Chart graphics to use.</param>
- /// <param name="rect">Screw position.</param>
- private void DrawScrew(ChartGraphics graph, RectangleF rect)
- {
- // Draw screw
- Pen screwPen = new Pen(Color.FromArgb(128,255,255,255), 1);
- graph.DrawEllipse(screwPen, rect.X, rect.Y, rect.Width, rect.Height);
- graph.DrawLine(screwPen, rect.X + 2 * resolution / 96.0f, rect.Y + rect.Height - 2 * resolution / 96.0f, rect.Right - 2 * resolution / 96.0f, rect.Y + 2 * resolution / 96.0f);
- screwPen = new Pen(Color.FromArgb(128, Color.Black), 1);
- graph.DrawEllipse(screwPen, rect.X + 1 * resolution / 96.0f, rect.Y + 1 * resolution / 96.0f, rect.Width, rect.Height);
- graph.DrawLine(screwPen, rect.X + 3 * resolution / 96.0f, rect.Y + rect.Height - 1 * resolution / 96.0f, rect.Right - 1 * resolution / 96.0f, rect.Y + 3 * resolution / 96.0f);
- }
- #endregion
- }
- }
|