DotNet 4.8.1 build of DotNetBar
This commit is contained in:
73
PROMS/DotNetBar Source Code/Presentation/Line.cs
Normal file
73
PROMS/DotNetBar Source Code/Presentation/Line.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the line drawn between start and end point.
|
||||
/// </summary>
|
||||
internal class Line : Shape
|
||||
{
|
||||
#region Private Variables
|
||||
private Location m_StartPoint = new Location();
|
||||
private Location m_EndPoint = new Location();
|
||||
private ShapeBorder m_Border = new ShapeBorder();
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public Line() { }
|
||||
public Line(Location startPoint, Location endPoint, ShapeBorder border)
|
||||
{
|
||||
m_StartPoint = startPoint;
|
||||
m_EndPoint = endPoint;
|
||||
m_Border = border;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the start point of the line.
|
||||
/// </summary>
|
||||
public Location StartPoint
|
||||
{
|
||||
get { return m_StartPoint; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the end point of the line.
|
||||
/// </summary>
|
||||
public Location EndPoint
|
||||
{
|
||||
get { return m_EndPoint; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the line border.
|
||||
/// </summary>
|
||||
public ShapeBorder Border
|
||||
{
|
||||
get { return m_Border; }
|
||||
}
|
||||
|
||||
public override void Paint(ShapePaintInfo p)
|
||||
{
|
||||
System.Drawing.Point start = GetLocation(p.Bounds, m_StartPoint);
|
||||
System.Drawing.Point end = GetLocation(p.Bounds, m_EndPoint);
|
||||
Graphics g = p.Graphics;
|
||||
|
||||
if (m_Border.Color2.IsEmpty)
|
||||
{
|
||||
if (!m_Border.Color1.IsEmpty)
|
||||
{
|
||||
DisplayHelp.DrawLine(g, start, end, m_Border.Color1, m_Border.Width);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayHelp.DrawGradientLine(g, start, end, m_Border.Color1, m_Border.Color2, m_Border.GradientAngle, m_Border.Width);
|
||||
}
|
||||
|
||||
base.Paint(p);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
54
PROMS/DotNetBar Source Code/Presentation/Location.cs
Normal file
54
PROMS/DotNetBar Source Code/Presentation/Location.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the shape location.
|
||||
/// </summary>
|
||||
internal class Location
|
||||
{
|
||||
public Location() { }
|
||||
public Location(int x, int y)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
}
|
||||
public Location(int x, int y, eRelativeLocation relativeX, eRelativeLocation relativeY)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.RelativeX = relativeX;
|
||||
this.RelativeY = relativeY;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the X location of the shape relative to it's parent.
|
||||
/// </summary>
|
||||
public int X = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the Y location of the shape relative to it's parent.
|
||||
/// </summary>
|
||||
public int Y = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the relative X position.
|
||||
/// </summary>
|
||||
public eRelativeLocation RelativeX = eRelativeLocation.NotSet;
|
||||
/// <summary>
|
||||
/// Gets or sets the relative Y position.
|
||||
/// </summary>
|
||||
public eRelativeLocation RelativeY = eRelativeLocation.NotSet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes the relative location.
|
||||
/// </summary>
|
||||
internal enum eRelativeLocation
|
||||
{
|
||||
NotSet,
|
||||
Top,
|
||||
Left,
|
||||
Right,
|
||||
Bottom
|
||||
}
|
||||
}
|
60
PROMS/DotNetBar Source Code/Presentation/PaddingInfo.cs
Normal file
60
PROMS/DotNetBar Source Code/Presentation/PaddingInfo.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the padding for the shape. Padding is the space inside the shape and between it's child shapes.
|
||||
/// </summary>
|
||||
internal class PaddingInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates new instance of the class.
|
||||
/// </summary>
|
||||
public PaddingInfo() { }
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the class and initializes it with default values.
|
||||
/// </summary>
|
||||
public PaddingInfo(int left, int top, int right, int bottom)
|
||||
{
|
||||
this.Left = left;
|
||||
this.Top = top;
|
||||
this.Right = right;
|
||||
this.Bottom = bottom;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the left padding in pixels.
|
||||
/// </summary>
|
||||
public int Left = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the right padding in pixels.
|
||||
/// </summary>
|
||||
public int Right = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the top padding in pixels.
|
||||
/// </summary>
|
||||
public int Top = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the bottom padding in pixels.
|
||||
/// </summary>
|
||||
public int Bottom = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total horizontal padding.
|
||||
/// </summary>
|
||||
public int HorizontalPadding
|
||||
{
|
||||
get { return Left + Right; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total vertical padding.
|
||||
/// </summary>
|
||||
public int VerticalPadding
|
||||
{
|
||||
get { return Top + Bottom; }
|
||||
}
|
||||
}
|
||||
}
|
216
PROMS/DotNetBar Source Code/Presentation/Rectangle.cs
Normal file
216
PROMS/DotNetBar Source Code/Presentation/Rectangle.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
internal class Rectangle : Shape
|
||||
{
|
||||
#region Private Variables
|
||||
private int m_CornerSize = 0;
|
||||
private ShapeBorder m_Border = new ShapeBorder();
|
||||
private ShapeFill m_Fill = new ShapeFill();
|
||||
private eCornerType m_TopLeftCornerType = eCornerType.Square;
|
||||
private eCornerType m_TopRightCornerType = eCornerType.Square;
|
||||
private eCornerType m_BottomLeftCornerType = eCornerType.Square;
|
||||
private eCornerType m_BottomRightCornerType = eCornerType.Square;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public Rectangle() { }
|
||||
public Rectangle(ShapeBorder border)
|
||||
{
|
||||
m_Border = border;
|
||||
}
|
||||
public Rectangle(ShapeBorder border, int cornerSize, eCornerType cornerType)
|
||||
{
|
||||
m_Border = border;
|
||||
m_CornerSize = cornerSize;
|
||||
this.CornerType = cornerType;
|
||||
}
|
||||
public Rectangle(ShapeBorder border, ShapeFill fill)
|
||||
{
|
||||
m_Border = border;
|
||||
m_Fill = fill;
|
||||
}
|
||||
public Rectangle(ShapeBorder border, ShapeFill fill,int cornerSize, eCornerType cornerType)
|
||||
{
|
||||
m_Border = border;
|
||||
m_Fill = fill;
|
||||
m_CornerSize = cornerSize;
|
||||
this.CornerType = cornerType;
|
||||
}
|
||||
public Rectangle(ShapeBorder border, ShapeFill fill, int cornerSize, eCornerType cornerType, PaddingInfo padding)
|
||||
{
|
||||
m_Border = border;
|
||||
m_Fill = fill;
|
||||
m_CornerSize = cornerSize;
|
||||
this.Padding = padding;
|
||||
this.CornerType = cornerType;
|
||||
}
|
||||
public Rectangle(ShapeFill fill)
|
||||
{
|
||||
m_Fill = fill;
|
||||
}
|
||||
public override void Paint(ShapePaintInfo p)
|
||||
{
|
||||
System.Drawing.Rectangle bounds = this.GetBounds(p.Bounds);
|
||||
Graphics g = p.Graphics;
|
||||
|
||||
PaintFill(g, bounds);
|
||||
PaintBorder(g, bounds);
|
||||
|
||||
base.Paint(p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints the border.
|
||||
/// </summary>
|
||||
protected virtual void PaintBorder(Graphics g, System.Drawing.Rectangle r)
|
||||
{
|
||||
if (m_Border.Width == 0 || m_Border.Color1.IsEmpty || r.Width <= 0 || r.Height <= 0)
|
||||
return;
|
||||
|
||||
int roundCornerSize = m_CornerSize;
|
||||
ShapeBorder border = m_Border;
|
||||
|
||||
// Workaround for GDI+ bug
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
|
||||
using (System.Drawing.Drawing2D.GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(r, m_CornerSize, eStyleBackgroundPathPart.Complete,
|
||||
m_TopLeftCornerType, m_TopRightCornerType, m_BottomLeftCornerType, m_BottomRightCornerType))
|
||||
{
|
||||
|
||||
using (Pen pen = new Pen(border.Color1, border.Width))
|
||||
path.Widen(pen);
|
||||
|
||||
if (border.Color2.IsEmpty)
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(border.Color1))
|
||||
g.FillPath(brush, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (System.Drawing.Drawing2D.LinearGradientBrush brush = DisplayHelp.CreateLinearGradientBrush(r, border.Color1, border.Color2, border.GradientAngle))
|
||||
g.FillPath(brush, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints the border.
|
||||
/// </summary>
|
||||
protected virtual void PaintFill(Graphics g, System.Drawing.Rectangle r)
|
||||
{
|
||||
if (r.Width <= 0 || r.Height <= 0)
|
||||
return;
|
||||
|
||||
int roundCornerSize = m_CornerSize;
|
||||
|
||||
if (roundCornerSize > 0)
|
||||
{
|
||||
using (System.Drawing.Drawing2D.GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(r, m_CornerSize, eStyleBackgroundPathPart.Complete,
|
||||
m_TopLeftCornerType, m_TopRightCornerType, m_BottomLeftCornerType, m_BottomRightCornerType))
|
||||
{
|
||||
Brush brush = m_Fill.CreateBrush(System.Drawing.Rectangle.Ceiling(path.GetBounds()));
|
||||
if (brush != null)
|
||||
{
|
||||
DisplayHelp.FillPath(g, path, m_Fill.Color1, m_Fill.Color2, m_Fill.GradientAngle);
|
||||
brush.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Brush brush = m_Fill.CreateBrush(r);
|
||||
if (brush != null)
|
||||
{
|
||||
g.FillRectangle(brush, r);
|
||||
brush.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override Region ClipChildren(Graphics g, System.Drawing.Rectangle childBounds)
|
||||
{
|
||||
if (m_CornerSize > 0)
|
||||
{
|
||||
Region clip = g.Clip;
|
||||
using (GraphicsPath path = DisplayHelp.GetRoundedRectanglePath(childBounds, m_CornerSize,
|
||||
eStyleBackgroundPathPart.Complete, m_TopLeftCornerType, m_TopRightCornerType, m_BottomLeftCornerType, m_BottomRightCornerType))
|
||||
{
|
||||
g.SetClip(path);
|
||||
}
|
||||
return clip;
|
||||
}
|
||||
|
||||
return base.ClipChildren(g, childBounds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the rounded corner size.
|
||||
/// </summary>
|
||||
public int CornerSize
|
||||
{
|
||||
get { return m_CornerSize; }
|
||||
set {m_CornerSize = value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shape border.
|
||||
/// </summary>
|
||||
public ShapeBorder Border
|
||||
{
|
||||
get { return m_Border; }
|
||||
set { m_Border = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shape fill.
|
||||
/// </summary>
|
||||
public ShapeFill Fill
|
||||
{
|
||||
get { return m_Fill; }
|
||||
set { m_Fill = value; }
|
||||
}
|
||||
|
||||
public eCornerType CornerType
|
||||
{
|
||||
get { return m_TopLeftCornerType; }
|
||||
set
|
||||
{
|
||||
m_TopLeftCornerType = value;
|
||||
m_TopRightCornerType = value;
|
||||
m_BottomLeftCornerType = value;
|
||||
m_BottomRightCornerType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public eCornerType TopLeftCornerType
|
||||
{
|
||||
get { return m_TopLeftCornerType; }
|
||||
set { m_TopLeftCornerType = value; }
|
||||
}
|
||||
|
||||
public eCornerType TopRightCornerType
|
||||
{
|
||||
get { return m_TopRightCornerType; }
|
||||
set { m_TopRightCornerType = value; }
|
||||
}
|
||||
|
||||
public eCornerType BottomLeftCornerType
|
||||
{
|
||||
get { return m_BottomLeftCornerType; }
|
||||
set { m_BottomLeftCornerType = value; }
|
||||
}
|
||||
|
||||
public eCornerType BottomRightCornerType
|
||||
{
|
||||
get { return m_BottomRightCornerType; }
|
||||
set { m_BottomRightCornerType = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
194
PROMS/DotNetBar Source Code/Presentation/Shape.cs
Normal file
194
PROMS/DotNetBar Source Code/Presentation/Shape.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
internal class Shape
|
||||
{
|
||||
#region Private Variables
|
||||
private Location m_Location = new Location();
|
||||
private SizeInfo m_Size = new SizeInfo();
|
||||
private ShapeCollection m_Children = null;
|
||||
private PaddingInfo m_Padding = null;
|
||||
private bool m_SetChildClip = false;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Gets the location of the shape.
|
||||
/// </summary>
|
||||
public Location Location
|
||||
{
|
||||
get { return m_Location; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the shape.
|
||||
/// </summary>
|
||||
public SizeInfo Size
|
||||
{
|
||||
get { return m_Size; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shape padding. Padding is the inside spacing between shape and it's child shapes.
|
||||
/// </summary>
|
||||
public PaddingInfo Padding
|
||||
{
|
||||
get { return m_Padding; }
|
||||
set
|
||||
{
|
||||
m_Padding = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of child shapes.
|
||||
/// </summary>
|
||||
public ShapeCollection Children
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Children == null)
|
||||
m_Children = new ShapeCollection();
|
||||
return m_Children;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this shape will set the ShapePaintInfo.ChildContentClip property to the region that represents the inside content of the shape.
|
||||
/// This is used when there is inside content of the shape which is not part of the shape itself and calling routine needs
|
||||
/// access to the region that defines the shape inside bounds.
|
||||
/// </summary>
|
||||
public bool SetChildClip
|
||||
{
|
||||
get { return m_SetChildClip; }
|
||||
set { m_SetChildClip = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints the shape on canvas. If overriden base implementation must be called to paint any child shapes.
|
||||
/// </summary>
|
||||
/// <param name="p">Shape paint information.</param>
|
||||
public virtual void Paint(ShapePaintInfo p)
|
||||
{
|
||||
if (m_Children != null && m_Children.Count > 0)
|
||||
{
|
||||
System.Drawing.Rectangle originalBounds = p.Bounds;
|
||||
System.Drawing.Rectangle bounds = new System.Drawing.Rectangle(this.GetLocation(p.Bounds), this.GetSize(p.Bounds));
|
||||
|
||||
if (m_Padding != null)
|
||||
{
|
||||
bounds.Width -= m_Padding.HorizontalPadding;
|
||||
bounds.Height -= m_Padding.VerticalPadding;
|
||||
bounds.X += m_Padding.Left;
|
||||
bounds.Y += m_Padding.Top;
|
||||
}
|
||||
|
||||
p.Bounds = bounds;
|
||||
Region clip = ClipChildren(p.Graphics, bounds);
|
||||
if (m_SetChildClip && p.Graphics.Clip!=null)
|
||||
{
|
||||
p.ChildContentClip = p.Graphics.Clip as Region;
|
||||
}
|
||||
|
||||
foreach (Shape shape in m_Children)
|
||||
{
|
||||
shape.Paint(p);
|
||||
}
|
||||
if (p.ChildContentClip != null)
|
||||
{
|
||||
p.ChildContentClip.Dispose();
|
||||
p.ChildContentClip = null;
|
||||
}
|
||||
if (clip != null)
|
||||
{
|
||||
p.Graphics.Clip = clip;
|
||||
clip.Dispose();
|
||||
}
|
||||
else
|
||||
p.Graphics.ResetClip();
|
||||
p.Bounds = originalBounds;
|
||||
if (clip != null) clip.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Region ClipChildren(Graphics g, System.Drawing.Rectangle childBounds)
|
||||
{
|
||||
Region clip = g.Clip;
|
||||
g.SetClip(childBounds);
|
||||
return clip;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns absolute location of the shape based on parent bounds.
|
||||
/// </summary>
|
||||
/// <param name="bounds">Parent absolute bounds.</param>
|
||||
/// <returns>Absolute location of the shape</returns>
|
||||
protected virtual Point GetLocation(System.Drawing.Rectangle bounds)
|
||||
{
|
||||
return GetLocation(bounds, m_Location);
|
||||
}
|
||||
|
||||
protected virtual Point GetLocation(System.Drawing.Rectangle bounds, Location refLocation)
|
||||
{
|
||||
Point loc = bounds.Location;
|
||||
|
||||
if (refLocation.RelativeX == eRelativeLocation.Right)
|
||||
loc.X = bounds.Right;
|
||||
else if (refLocation.RelativeX == eRelativeLocation.Top)
|
||||
loc.X = bounds.Y;
|
||||
else if (refLocation.RelativeX == eRelativeLocation.Bottom)
|
||||
loc.X = bounds.Bottom;
|
||||
|
||||
if (refLocation.RelativeY == eRelativeLocation.Bottom)
|
||||
loc.Y = bounds.Bottom;
|
||||
else if (refLocation.RelativeY == eRelativeLocation.Right)
|
||||
loc.Y = bounds.Right;
|
||||
else if (refLocation.RelativeY == eRelativeLocation.Left)
|
||||
loc.Y = bounds.X;
|
||||
|
||||
loc.Offset(refLocation.X, refLocation.Y);
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns absolute size of the shape based on the parent bounds.
|
||||
/// </summary>
|
||||
/// <param name="bounds">Absolute parent bounds.</param>
|
||||
/// <returns>Absolute size of the shape.</returns>
|
||||
protected virtual Size GetSize(System.Drawing.Rectangle bounds)
|
||||
{
|
||||
Size size = bounds.Size;
|
||||
|
||||
if (m_Size.RelativeWidth == eRelativeSize.Width)
|
||||
size.Width = bounds.Width + m_Size.Width;
|
||||
else if (m_Size.RelativeWidth == eRelativeSize.Height)
|
||||
size.Width = bounds.Height + m_Size.Height;
|
||||
else if (m_Size.Width != 0)
|
||||
size.Width = m_Size.Width;
|
||||
|
||||
if (m_Size.RelativeHeight == eRelativeSize.Height)
|
||||
size.Height = bounds.Height + m_Size.Height;
|
||||
else if (m_Size.RelativeHeight == eRelativeSize.Width)
|
||||
size.Height = bounds.Width + m_Size.Height;
|
||||
else if (m_Size.Height != 0)
|
||||
size.Height = m_Size.Height;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the absolute bounds of the shape.
|
||||
/// </summary>
|
||||
/// <param name="parentBounds">Parent bounds.</param>
|
||||
/// <returns>Absolute bounds of the shape.</returns>
|
||||
protected virtual System.Drawing.Rectangle GetBounds(System.Drawing.Rectangle parentBounds)
|
||||
{
|
||||
return new System.Drawing.Rectangle(GetLocation(parentBounds), GetSize(parentBounds));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
77
PROMS/DotNetBar Source Code/Presentation/ShapeBorder.cs
Normal file
77
PROMS/DotNetBar Source Code/Presentation/ShapeBorder.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the shape border.
|
||||
/// </summary>
|
||||
internal class ShapeBorder
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the border width in pixels.
|
||||
/// </summary>
|
||||
public int Width = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the border color.
|
||||
/// </summary>
|
||||
public Color Color1 = Color.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ending gradient border color.
|
||||
/// </summary>
|
||||
public Color Color2 = Color.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient angle. Default value is 90.
|
||||
/// </summary>
|
||||
public int GradientAngle = 90;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public ShapeBorder() {}
|
||||
public ShapeBorder(int borderWidth) { Width = borderWidth; }
|
||||
public ShapeBorder(LinearGradientColorTable table)
|
||||
{
|
||||
this.Color1 = table.Start;
|
||||
this.Color2 = table.End;
|
||||
this.Width = 1;
|
||||
}
|
||||
public ShapeBorder(LinearGradientColorTable table, int width)
|
||||
{
|
||||
this.Color1 = table.Start;
|
||||
this.Color2 = table.End;
|
||||
this.Width = width;
|
||||
}
|
||||
public void Apply(LinearGradientColorTable table)
|
||||
{
|
||||
if (table == null)
|
||||
{
|
||||
this.Color1 = Color.Empty;
|
||||
this.Color2 = Color.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Color1 = table.Start;
|
||||
this.Color2 = table.End;
|
||||
}
|
||||
}
|
||||
public ShapeBorder(Color color1, Color color2, int width)
|
||||
{
|
||||
this.Color1 = color1;
|
||||
this.Color2 = color2;
|
||||
this.Width = width;
|
||||
}
|
||||
public ShapeBorder(Color color1, int width)
|
||||
{
|
||||
this.Color1 = color1;
|
||||
this.Color2 = Color.Empty;
|
||||
this.Width = width;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
103
PROMS/DotNetBar Source Code/Presentation/ShapeCollection.cs
Normal file
103
PROMS/DotNetBar Source Code/Presentation/ShapeCollection.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
internal class ShapeCollection : CollectionBase
|
||||
{
|
||||
#region Internal Implementation
|
||||
/// <summary>Creates new instance of the class.</summary>
|
||||
public ShapeCollection()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds new object to the collection.
|
||||
/// </summary>
|
||||
/// <param name="Shape">Object to add.</param>
|
||||
/// <returns>Index of newly added object.</returns>
|
||||
public int Add(Shape shape)
|
||||
{
|
||||
return List.Add(shape);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns reference to the object in collection based on it's index.
|
||||
/// </summary>
|
||||
public Shape this[int index]
|
||||
{
|
||||
get {return (Shape)(List[index]);}
|
||||
set {List[index] = value;}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts new object into the collection.
|
||||
/// </summary>
|
||||
/// <param name="index">Position of the object.</param>
|
||||
/// <param name="value">Object to insert.</param>
|
||||
public void Insert(int index, Shape value)
|
||||
{
|
||||
List.Insert(index, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns index of the object inside of the collection.
|
||||
/// </summary>
|
||||
/// <param name="value">Reference to the object.</param>
|
||||
/// <returns>Index of the object.</returns>
|
||||
public int IndexOf(Shape value)
|
||||
{
|
||||
return List.IndexOf(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether collection contains specified object.
|
||||
/// </summary>
|
||||
/// <param name="value">Object to look for.</param>
|
||||
/// <returns>true if object is part of the collection, otherwise false.</returns>
|
||||
public bool Contains(Shape value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes specified object from the collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void Remove(Shape value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
//protected override void OnRemoveComplete(int index,object value)
|
||||
//{
|
||||
// base.OnRemoveComplete(index,value);
|
||||
// Shape me=value as Shape;
|
||||
//}
|
||||
//protected override void OnInsertComplete(int index,object value)
|
||||
//{
|
||||
// base.OnInsertComplete(index,value);
|
||||
// Shape me=value as Shape;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Copies collection into the specified array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy collection to.</param>
|
||||
/// <param name="index">Starting index.</param>
|
||||
public void CopyTo(Shape[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies contained items to the Shape array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy to.</param>
|
||||
internal void CopyTo(Shape[] array)
|
||||
{
|
||||
List.CopyTo(array,0);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
105
PROMS/DotNetBar Source Code/Presentation/ShapeFill.cs
Normal file
105
PROMS/DotNetBar Source Code/Presentation/ShapeFill.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
internal class ShapeFill : Shape
|
||||
{
|
||||
#region Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the starting fill color.
|
||||
/// </summary>
|
||||
public Color Color1 = Color.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the end fill color.
|
||||
/// </summary>
|
||||
public Color Color2 = Color.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient angle.
|
||||
/// </summary>
|
||||
public int GradientAngle = 90;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the background color collection blend.
|
||||
/// </summary>
|
||||
public BackgroundColorBlendCollection BackgroundColorBlend = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the fill gradient type.
|
||||
/// </summary>
|
||||
public eGradientType GradientType = eGradientType.Linear;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public ShapeFill() { }
|
||||
public ShapeFill(Color color1, Color color2)
|
||||
{
|
||||
this.Color1 = color1;
|
||||
this.Color2 = color2;
|
||||
}
|
||||
public ShapeFill(LinearGradientColorTable table)
|
||||
{
|
||||
this.Color1 = table.Start;
|
||||
this.Color2 = table.End;
|
||||
}
|
||||
public ShapeFill(Color color1)
|
||||
{
|
||||
this.Color1 = color1;
|
||||
this.Color2 = Color.Empty;
|
||||
}
|
||||
|
||||
public void Apply(LinearGradientColorTable table)
|
||||
{
|
||||
if (table == null)
|
||||
{
|
||||
this.Color1 = Color.Empty;
|
||||
this.Color2 = Color.Empty;
|
||||
this.GradientAngle = 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Color1 = table.Start;
|
||||
this.Color2 = table.End;
|
||||
this.GradientAngle = table.GradientAngle;
|
||||
}
|
||||
}
|
||||
|
||||
public Brush CreateBrush(System.Drawing.Rectangle r)
|
||||
{
|
||||
if (r.Width <= 0 || r.Height <= 0)
|
||||
return null;
|
||||
|
||||
if(this.BackgroundColorBlend!=null && BackgroundColorBlend.Count>0)
|
||||
{
|
||||
return DisplayHelp.CreateBrush(r, BackgroundColorBlend, GradientAngle, GradientType);
|
||||
}
|
||||
else if(Color2.IsEmpty && !Color1.IsEmpty)
|
||||
{
|
||||
return new SolidBrush(Color1);
|
||||
}
|
||||
else if (!Color2.IsEmpty && !Color1.IsEmpty)
|
||||
{
|
||||
if (GradientType == eGradientType.Linear)
|
||||
return new LinearGradientBrush(r, Color1, Color2, GradientAngle);
|
||||
else
|
||||
{
|
||||
int d = (int)Math.Sqrt(r.Width * r.Width + r.Height * r.Height) + 4;
|
||||
GraphicsPath fillPath = new GraphicsPath();
|
||||
fillPath.AddEllipse(r.X - (d - r.Width) / 2, r.Y - (d - r.Height) / 2, d, d);
|
||||
PathGradientBrush brush = new PathGradientBrush(fillPath);
|
||||
brush.CenterColor = this.Color1;
|
||||
brush.SurroundColors = new Color[] { this.Color2 };
|
||||
return brush;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
19
PROMS/DotNetBar Source Code/Presentation/ShapePaintInfo.cs
Normal file
19
PROMS/DotNetBar Source Code/Presentation/ShapePaintInfo.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
internal class ShapePaintInfo
|
||||
{
|
||||
public ShapePaintInfo(Graphics g, System.Drawing.Rectangle bounds)
|
||||
{
|
||||
this.Graphics = g;
|
||||
this.Bounds = bounds;
|
||||
}
|
||||
|
||||
public Graphics Graphics;
|
||||
public System.Drawing.Rectangle Bounds = System.Drawing.Rectangle.Empty;
|
||||
public Region ChildContentClip = null;
|
||||
}
|
||||
}
|
134
PROMS/DotNetBar Source Code/Presentation/ShapePath.cs
Normal file
134
PROMS/DotNetBar Source Code/Presentation/ShapePath.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
internal class ShapePath : Shape
|
||||
{
|
||||
#region Private Variables
|
||||
private ShapeBorder m_Border = null;
|
||||
private ShapeFill m_Fill = null;
|
||||
private GraphicsPath m_Path = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public ShapePath() { }
|
||||
public ShapePath(ShapeBorder border)
|
||||
{
|
||||
m_Border = border;
|
||||
}
|
||||
public ShapePath(ShapeFill fill)
|
||||
{
|
||||
m_Fill = fill;
|
||||
}
|
||||
public ShapePath(ShapeBorder border, ShapeFill fill)
|
||||
{
|
||||
m_Border = border;
|
||||
m_Fill = fill;
|
||||
}
|
||||
|
||||
public GraphicsPath Path
|
||||
{
|
||||
get { return m_Path; }
|
||||
set { m_Path = value; }
|
||||
}
|
||||
|
||||
public override void Paint(ShapePaintInfo p)
|
||||
{
|
||||
if(m_Path == null)
|
||||
return;
|
||||
|
||||
System.Drawing.Rectangle bounds = this.GetBounds(p.Bounds);
|
||||
Graphics g = p.Graphics;
|
||||
|
||||
if (m_Fill != null)
|
||||
PaintFill(g, bounds);
|
||||
|
||||
if (m_Border != null)
|
||||
PaintBorder(g, bounds);
|
||||
|
||||
base.Paint(p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints the border.
|
||||
/// </summary>
|
||||
protected virtual void PaintBorder(Graphics g, System.Drawing.Rectangle r)
|
||||
{
|
||||
if (m_Border.Color1.IsEmpty)
|
||||
return;
|
||||
|
||||
ShapeBorder border = m_Border;
|
||||
|
||||
using (GraphicsPath path = m_Path.Clone() as GraphicsPath)
|
||||
{
|
||||
path.Transform(new Matrix(1, 0, 0, 1, r.X, r.Y));
|
||||
DisplayHelp.DrawGradientPathBorder(g, path, border.Color1, border.Color2, border.GradientAngle, border.Width);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints the border.
|
||||
/// </summary>
|
||||
protected virtual void PaintFill(Graphics g, System.Drawing.Rectangle r)
|
||||
{
|
||||
if (r.Width <= 0 || r.Height <= 0 || m_Fill==null)
|
||||
return;
|
||||
|
||||
|
||||
using (GraphicsPath path = m_Path.Clone() as GraphicsPath)
|
||||
{
|
||||
// Center path inside of the bounds by default
|
||||
System.Drawing.Rectangle pathBounds = System.Drawing.Rectangle.Ceiling(path.GetBounds());
|
||||
int w = r.X + (int)Math.Ceiling((double)(Math.Max(r.Width, pathBounds.Width) - pathBounds.Width) / 2);
|
||||
int h = r.Y + (r.Height - pathBounds.Height) / 2;
|
||||
using (Matrix matrix = new Matrix(1, 0, 0, 1, w, h))
|
||||
path.Transform(matrix);
|
||||
pathBounds = System.Drawing.Rectangle.Ceiling(path.GetBounds());
|
||||
|
||||
Brush brush = m_Fill.CreateBrush(pathBounds);
|
||||
if (brush != null)
|
||||
{
|
||||
g.FillPath(brush, path);
|
||||
|
||||
brush.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//protected override Region ClipChildren(Graphics g, System.Drawing.Rectangle childBounds)
|
||||
//{
|
||||
// if (m_CornerSize > 0)
|
||||
// {
|
||||
// Region clip = g.Clip;
|
||||
// g.SetClip(DisplayHelp.GetRoundedRectanglePath(childBounds, m_CornerSize, eStyleBackgroundPathPart.Complete, m_TopLeftCornerType,
|
||||
// m_TopRightCornerType, m_BottomLeftCornerType, m_BottomRightCornerType));
|
||||
// return clip;
|
||||
// }
|
||||
|
||||
// return base.ClipChildren(g, childBounds);
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shape border.
|
||||
/// </summary>
|
||||
public ShapeBorder Border
|
||||
{
|
||||
get { return m_Border; }
|
||||
set { m_Border = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the shape fill.
|
||||
/// </summary>
|
||||
public ShapeFill Fill
|
||||
{
|
||||
get { return m_Fill; }
|
||||
set { m_Fill = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
35
PROMS/DotNetBar Source Code/Presentation/SizeInfo.cs
Normal file
35
PROMS/DotNetBar Source Code/Presentation/SizeInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Presentation
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes shape size.
|
||||
/// </summary>
|
||||
internal class SizeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the shape. When RelativeWidth is specified then number specifed here is added to the actual shape width.
|
||||
/// </summary>
|
||||
public int Width = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the height of the shape. When RelativeHeight is specified the number specified here is added to the actual shape height.
|
||||
/// </summary>
|
||||
public int Height = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the relative shape width.
|
||||
/// </summary>
|
||||
public eRelativeSize RelativeWidth = eRelativeSize.NotSet;
|
||||
/// <summary>
|
||||
/// Gets or sets the relative shape height.
|
||||
/// </summary>
|
||||
public eRelativeSize RelativeHeight = eRelativeSize.NotSet;
|
||||
}
|
||||
|
||||
internal enum eRelativeSize
|
||||
{
|
||||
NotSet,
|
||||
Width,
|
||||
Height
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user