DotNet 4.8.1 build of DotNetBar
This commit is contained in:
96
PROMS/DotNetBar Source Code/TextMarkup/BodyElement.cs
Normal file
96
PROMS/DotNetBar Source Code/TextMarkup/BodyElement.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class BodyElement : ContainerElement
|
||||
{
|
||||
#region Private Variables
|
||||
private MarkupElementCollection m_ActiveElements=null;
|
||||
private IActiveMarkupElement m_MouseOverElement = null;
|
||||
internal bool HasExpandElement = false;
|
||||
internal string PlainText = "";
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
public event EventHandler HyperLinkClick;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public BodyElement()
|
||||
{
|
||||
m_ActiveElements = new MarkupElementCollection(null);
|
||||
}
|
||||
|
||||
public MarkupElementCollection ActiveElements
|
||||
{
|
||||
get { return m_ActiveElements; }
|
||||
}
|
||||
|
||||
public void MouseLeave(Control parent)
|
||||
{
|
||||
if (m_MouseOverElement != null)
|
||||
m_MouseOverElement.MouseLeave(parent);
|
||||
m_MouseOverElement = null;
|
||||
}
|
||||
|
||||
public void MouseMove(Control parent, MouseEventArgs e)
|
||||
{
|
||||
if (m_MouseOverElement != null && m_MouseOverElement.HitTest(e.X, e.Y))
|
||||
return;
|
||||
if (m_MouseOverElement != null)
|
||||
m_MouseOverElement.MouseLeave(parent);
|
||||
|
||||
m_MouseOverElement = null;
|
||||
|
||||
foreach(IActiveMarkupElement el in m_ActiveElements)
|
||||
{
|
||||
if (el.HitTest(e.X, e.Y))
|
||||
{
|
||||
m_MouseOverElement = el;
|
||||
m_MouseOverElement.MouseEnter(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void MouseDown(Control parent, MouseEventArgs e)
|
||||
{
|
||||
if (m_MouseOverElement != null)
|
||||
m_MouseOverElement.MouseDown(parent, e);
|
||||
}
|
||||
|
||||
public void MouseUp(Control parent, MouseEventArgs e)
|
||||
{
|
||||
if (m_MouseOverElement != null)
|
||||
m_MouseOverElement.MouseUp(parent, e);
|
||||
}
|
||||
|
||||
public void Click(Control parent)
|
||||
{
|
||||
if (m_MouseOverElement != null)
|
||||
{
|
||||
m_MouseOverElement.Click(parent);
|
||||
if (m_MouseOverElement is HyperLink)
|
||||
{
|
||||
if (HyperLinkClick != null)
|
||||
HyperLinkClick(m_MouseOverElement, new EventArgs());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IActiveMarkupElement MouseOverElement
|
||||
{
|
||||
get { return m_MouseOverElement;}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
113
PROMS/DotNetBar Source Code/TextMarkup/ContainerElement.cs
Normal file
113
PROMS/DotNetBar Source Code/TextMarkup/ContainerElement.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
using DevComponents.UI.ContentManager;
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class ContainerElement : MarkupElement
|
||||
{
|
||||
#region Private Variables
|
||||
private SerialContentLayoutManager m_Layout = null;
|
||||
private MarkupLayoutManager m_MarkupLayout = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void Measure(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
ArrangeInternal(new Rectangle(Point.Empty, availableSize), d);
|
||||
}
|
||||
|
||||
protected virtual SerialContentLayoutManager GetLayoutManager(bool mutliLine)
|
||||
{
|
||||
if (m_Layout == null)
|
||||
{
|
||||
m_Layout = new SerialContentLayoutManager();
|
||||
m_Layout.MultiLine = mutliLine;
|
||||
m_Layout.ContentVerticalAlignment = eContentVerticalAlignment.Top;
|
||||
m_Layout.BlockLineAlignment = eContentVerticalAlignment.Top;
|
||||
m_Layout.BlockSpacing = 0;
|
||||
}
|
||||
|
||||
m_Layout.EvenHeight = true;
|
||||
return m_Layout;
|
||||
}
|
||||
|
||||
private MarkupLayoutManager GetMarkupLayout()
|
||||
{
|
||||
if (m_MarkupLayout == null)
|
||||
{
|
||||
m_MarkupLayout = new MarkupLayoutManager();
|
||||
}
|
||||
return m_MarkupLayout;
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
Point offset = this.GetContainerOffset();
|
||||
d.Offset.Offset(offset.X, offset.Y);
|
||||
|
||||
try
|
||||
{
|
||||
foreach (MarkupElement e in this.Elements)
|
||||
{
|
||||
e.Render(d);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
d.Offset.Offset(-offset.X, -offset.Y);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Point GetContainerOffset()
|
||||
{
|
||||
return this.Bounds.Location;
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(Rectangle finalRect, MarkupDrawContext d)
|
||||
{
|
||||
this.Bounds = finalRect;
|
||||
ArrangeInternal(finalRect, d);
|
||||
}
|
||||
|
||||
protected virtual void ArrangeInternal(Rectangle bounds, MarkupDrawContext d)
|
||||
{
|
||||
SerialContentLayoutManager layout = GetLayoutManager(d.AllowMultiLine);
|
||||
layout.RightToLeft = d.RightToLeft;
|
||||
MarkupLayoutManager markupLayout = GetMarkupLayout();
|
||||
markupLayout.MarkupDrawContext = d;
|
||||
try
|
||||
{
|
||||
MarkupElement[] blocks = new MarkupElement[this.Elements.Count];
|
||||
this.Elements.CopyTo(blocks);
|
||||
|
||||
Rectangle r = layout.Layout(new Rectangle(Point.Empty, bounds.Size), blocks, markupLayout);
|
||||
this.Bounds = new Rectangle(bounds.Location, r.Size);
|
||||
}
|
||||
finally
|
||||
{
|
||||
markupLayout.MarkupDrawContext = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether markup element is an block element that always consumes a whole line in layout.
|
||||
/// </summary>
|
||||
public override bool IsBlockElement
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
226
PROMS/DotNetBar Source Code/TextMarkup/Div.cs
Normal file
226
PROMS/DotNetBar Source Code/TextMarkup/Div.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
using DevComponents.UI.ContentManager;
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Div : ContainerElement
|
||||
{
|
||||
#region Private Variables
|
||||
private eParagraphAlignment m_Align = eParagraphAlignment.Left;
|
||||
private eParagraphVerticalAlignment m_VAlign = eParagraphVerticalAlignment.Top;
|
||||
private int m_Width = 0;
|
||||
private int m_Height = 0;
|
||||
private Padding m_Padding = new Padding(0, 0, 0, 0);
|
||||
private Color m_BackColor = Color.Empty;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
Rectangle r = this.Bounds;
|
||||
r.Offset(d.Offset);
|
||||
if (!m_BackColor.IsEmpty)
|
||||
{
|
||||
DisplayHelp.FillRectangle(d.Graphics, r, m_BackColor);
|
||||
}
|
||||
|
||||
base.Render(d);
|
||||
}
|
||||
|
||||
public eParagraphAlignment Align
|
||||
{
|
||||
get { return m_Align; }
|
||||
set { m_Align = value; }
|
||||
}
|
||||
|
||||
protected override SerialContentLayoutManager GetLayoutManager(bool multiLine)
|
||||
{
|
||||
SerialContentLayoutManager sm = base.GetLayoutManager(multiLine);
|
||||
if (m_Align == eParagraphAlignment.Left)
|
||||
sm.ContentAlignment = eContentAlignment.Left;
|
||||
else if (m_Align == eParagraphAlignment.Right)
|
||||
sm.ContentAlignment = eContentAlignment.Right;
|
||||
else if (m_Align == eParagraphAlignment.Center)
|
||||
sm.ContentAlignment = eContentAlignment.Center;
|
||||
|
||||
if (m_VAlign != eParagraphVerticalAlignment.Top)
|
||||
{
|
||||
sm.EvenHeight = false;
|
||||
sm.ContentVerticalAlignment = (m_VAlign == eParagraphVerticalAlignment.Bottom ? eContentVerticalAlignment.Bottom : eContentVerticalAlignment.Middle);
|
||||
//sm.BlockLineAlignment = (m_VAlign == eParagraphVerticalAlignment.Bottom ? eContentVerticalAlignment.Bottom : eContentVerticalAlignment.Middle);
|
||||
}
|
||||
|
||||
return sm;
|
||||
}
|
||||
|
||||
protected override Point GetContainerOffset()
|
||||
{
|
||||
if (m_Padding.Left == 0 && m_Padding.Top == 0)
|
||||
return base.GetContainerOffset();
|
||||
|
||||
Point p = base.GetContainerOffset();
|
||||
p.X += m_Padding.Left;
|
||||
p.Y += m_Padding.Top;
|
||||
return p;
|
||||
}
|
||||
|
||||
protected override void ArrangeInternal(Rectangle bounds, MarkupDrawContext d)
|
||||
{
|
||||
Rectangle r = bounds;
|
||||
int width = Dpi.Width(m_Width);
|
||||
if (width > 0)
|
||||
r.Width = width;
|
||||
int height = Dpi.Height(m_Height);
|
||||
if (height > 0)
|
||||
r.Height = height;
|
||||
Padding padding = Dpi.Size(m_Padding);
|
||||
if (padding.IsEmpty)
|
||||
{
|
||||
base.ArrangeInternal(r, d);
|
||||
if (width > 0)
|
||||
this.Bounds = new Rectangle(this.Bounds.X, this.Bounds.Y, width, height > 0 ? height : this.Bounds.Height + padding.Bottom);
|
||||
else if(height>0)
|
||||
this.Bounds = new Rectangle(this.Bounds.X, this.Bounds.Y, this.Bounds.Width, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
r.X += padding.Left;
|
||||
r.Y += padding.Top;
|
||||
r.Width -= padding.Horizontal;
|
||||
r.Height -= padding.Vertical;
|
||||
base.ArrangeInternal(r, d);
|
||||
|
||||
r = new Rectangle(bounds.X, bounds.Y, this.Bounds.Width + padding.Horizontal, this.Bounds.Height + padding.Vertical);
|
||||
if (width > 0)
|
||||
r.Width = width;
|
||||
if (height > 0)
|
||||
r.Height = height;
|
||||
|
||||
this.Bounds = r;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReadAttributes(XmlTextReader reader)
|
||||
{
|
||||
for (int i = 0; i < reader.AttributeCount; i++)
|
||||
{
|
||||
reader.MoveToAttribute(i);
|
||||
if (reader.Name.ToLower() == "align")
|
||||
{
|
||||
string s = reader.Value.ToLower();
|
||||
if (s == "left")
|
||||
m_Align = eParagraphAlignment.Left;
|
||||
else if (s == "right")
|
||||
m_Align = eParagraphAlignment.Right;
|
||||
else if (s == "center")
|
||||
m_Align = eParagraphAlignment.Center;
|
||||
}
|
||||
else if (reader.Name.ToLower() == "valign")
|
||||
{
|
||||
string s = reader.Value.ToLower();
|
||||
if (s == "top")
|
||||
m_VAlign = eParagraphVerticalAlignment.Top;
|
||||
else if (s == "middle")
|
||||
m_VAlign = eParagraphVerticalAlignment.Middle;
|
||||
else if (s == "bottom")
|
||||
m_VAlign = eParagraphVerticalAlignment.Bottom;
|
||||
}
|
||||
else if (reader.Name.ToLower() == "width")
|
||||
{
|
||||
try
|
||||
{
|
||||
m_Width = Int32.Parse(reader.Value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Width = 0;
|
||||
}
|
||||
}
|
||||
else if (reader.Name.ToLower() == "height")
|
||||
{
|
||||
try
|
||||
{
|
||||
m_Height = Int32.Parse(reader.Value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Height = 0;
|
||||
}
|
||||
}
|
||||
else if (reader.Name.ToLower() == "padding")
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] values = reader.Value.Split(',');
|
||||
if (values.Length > 0)
|
||||
m_Padding.Left = Int32.Parse(values[0]);
|
||||
if (values.Length > 1)
|
||||
m_Padding.Right = Int32.Parse(values[1]);
|
||||
if (values.Length > 2)
|
||||
m_Padding.Top = Int32.Parse(values[2]);
|
||||
if (values.Length > 3)
|
||||
m_Padding.Bottom = Int32.Parse(values[3]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Padding = new Padding(0,0,0,0);
|
||||
}
|
||||
}
|
||||
else if (reader.Name.ToLower() == "bgcolor")
|
||||
{
|
||||
try
|
||||
{
|
||||
string s = reader.Value;
|
||||
if (s.StartsWith("#"))
|
||||
{
|
||||
if (s.Length == 7)
|
||||
m_BackColor = ColorScheme.GetColor(s.Substring(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_BackColor = Color.FromName(s);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_BackColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region eParagraphAlignment
|
||||
/// <summary>
|
||||
/// Indicates paragraph content alignment
|
||||
/// </summary>
|
||||
internal enum eParagraphAlignment
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Center
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates paragraph content alignment
|
||||
/// </summary>
|
||||
internal enum eParagraphVerticalAlignment
|
||||
{
|
||||
Top,
|
||||
Middle,
|
||||
Bottom
|
||||
}
|
||||
#endregion
|
||||
}
|
50
PROMS/DotNetBar Source Code/TextMarkup/EndMarkupElement.cs
Normal file
50
PROMS/DotNetBar Source Code/TextMarkup/EndMarkupElement.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class EndMarkupElement : MarkupElement
|
||||
{
|
||||
#region Internap Implementation
|
||||
private MarkupElement m_StartElement = null;
|
||||
|
||||
public EndMarkupElement(MarkupElement startElement)
|
||||
{
|
||||
m_StartElement = startElement;
|
||||
}
|
||||
|
||||
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
m_StartElement.MeasureEnd(availableSize, d);
|
||||
this.Bounds = Rectangle.Empty;
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
m_StartElement.RenderEnd(d);
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d)
|
||||
{
|
||||
this.Bounds = Rectangle.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to markup start element.
|
||||
/// </summary>
|
||||
public MarkupElement StartElement
|
||||
{
|
||||
get { return m_StartElement; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
202
PROMS/DotNetBar Source Code/TextMarkup/ExpandElement.cs
Normal file
202
PROMS/DotNetBar Source Code/TextMarkup/ExpandElement.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Xml;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class ExpandElement : MarkupElement
|
||||
{
|
||||
#region Internal Implementation
|
||||
private Size m_DefaultSize = new Size(5, 4);
|
||||
private eExpandDirection m_Direction = eExpandDirection.Default;
|
||||
|
||||
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
this.Bounds = new Rectangle(Point.Empty, Dpi.Size(m_DefaultSize));
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d) { }
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
Rectangle r = this.Bounds;
|
||||
r.Offset(d.Offset);
|
||||
|
||||
if (!d.ClipRectangle.IsEmpty && !r.IntersectsWith(d.ClipRectangle))
|
||||
return;
|
||||
|
||||
Graphics g = d.Graphics;
|
||||
Color color = d.CurrentForeColor;
|
||||
//Color shadeColor = Color.FromArgb(96, Color.White);
|
||||
|
||||
eExpandDirection direction = eExpandDirection.Bottom;
|
||||
if (m_Direction != eExpandDirection.Default)
|
||||
direction = m_Direction;
|
||||
|
||||
#if DOTNETBAR
|
||||
if(d.ContextObject is ButtonItem)
|
||||
{
|
||||
if (m_Direction == eExpandDirection.Default)
|
||||
{
|
||||
ButtonItem item = d.ContextObject as ButtonItem;
|
||||
if (item.IsOnMenu)
|
||||
{
|
||||
direction = eExpandDirection.Right;
|
||||
if (item.PopupSide == ePopupSide.Default && d.RightToLeft || item.PopupSide == ePopupSide.Left)
|
||||
direction = eExpandDirection.Left;
|
||||
}
|
||||
else if (item.PopupSide == ePopupSide.Default)
|
||||
direction = eExpandDirection.Bottom;
|
||||
else if (item.PopupSide == ePopupSide.Left)
|
||||
direction = eExpandDirection.Left;
|
||||
else if (item.PopupSide == ePopupSide.Right)
|
||||
direction = eExpandDirection.Right;
|
||||
else if (item.PopupSide == ePopupSide.Bottom)
|
||||
direction = eExpandDirection.Bottom;
|
||||
else if (item.PopupSide == ePopupSide.Top)
|
||||
direction = eExpandDirection.Top;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.None;
|
||||
|
||||
Rectangle shadeRect = r;
|
||||
if (direction == eExpandDirection.Bottom || direction == eExpandDirection.PopupDropDown)
|
||||
shadeRect.Offset(0, 1);
|
||||
else if (direction == eExpandDirection.Top)
|
||||
shadeRect.Offset(0, -1);
|
||||
else if (direction == eExpandDirection.Left)
|
||||
shadeRect.Offset(1, 0);
|
||||
else if (direction == eExpandDirection.Right)
|
||||
shadeRect.Offset(-1, 0);
|
||||
Point[] p = GetExpandPolygon(shadeRect, direction);
|
||||
//using (SolidBrush brush = new SolidBrush(shadeColor))
|
||||
// g.FillPolygon(brush, p);
|
||||
|
||||
p = GetExpandPolygon(r, direction);
|
||||
using(SolidBrush brush = new SolidBrush(color))
|
||||
g.FillPolygon(brush, p);
|
||||
|
||||
if (direction == eExpandDirection.PopupDropDown)
|
||||
{
|
||||
using (Pen pen = new Pen(color, Dpi.Height1))
|
||||
g.DrawLine(pen, r.X, r.Y - Dpi.Width2, r.Right - 1, r.Y - Dpi.Width2);
|
||||
//using (Pen pen = new Pen(shadeColor, 1))
|
||||
// g.DrawLine(pen, r.X, r.Y - 1, r.Right - 1, r.Y - 1);
|
||||
}
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
|
||||
this.RenderBounds = r;
|
||||
}
|
||||
|
||||
private Point[] GetExpandPolygon(Rectangle r, eExpandDirection direction)
|
||||
{
|
||||
Point[] p = new Point[3];
|
||||
int signHeight = Dpi.Height(m_DefaultSize.Height);
|
||||
switch (direction)
|
||||
{
|
||||
case eExpandDirection.Right:
|
||||
{
|
||||
p[0].X = r.Left + 1;
|
||||
p[0].Y = r.Top + (r.Height - signHeight) / 2 - 1;
|
||||
p[1].X = p[0].X;
|
||||
p[1].Y = p[0].Y + Dpi.Height6;
|
||||
p[2].X = p[0].X + Dpi.Width3;
|
||||
p[2].Y = p[0].Y + Dpi.Height3;
|
||||
break;
|
||||
}
|
||||
case eExpandDirection.Left:
|
||||
{
|
||||
p[0].X = r.Left + Dpi.Width3;
|
||||
p[0].Y = r.Top + (r.Height - signHeight) / 2 - 1;
|
||||
p[1].X = p[0].X;
|
||||
p[1].Y = p[0].Y + Dpi.Height6;
|
||||
p[2].X = p[0].X - Dpi.Width3;
|
||||
p[2].Y = p[0].Y + Dpi.Height3;
|
||||
break;
|
||||
}
|
||||
case eExpandDirection.Top:
|
||||
{
|
||||
p[0].X = r.Left - 1;
|
||||
p[0].Y = r.Top + (r.Height - signHeight) / 2 + signHeight;
|
||||
p[1].X = p[0].X + Dpi.Width6;
|
||||
p[1].Y = p[0].Y;
|
||||
p[2].X = p[0].X + Dpi.Width3;
|
||||
p[2].Y = p[0].Y - Dpi.Height4;
|
||||
break;
|
||||
}
|
||||
case eExpandDirection.Bottom:
|
||||
case eExpandDirection.PopupDropDown:
|
||||
{
|
||||
p[0].X = r.Left;
|
||||
p[0].Y = r.Top + (r.Height - signHeight) / 2 + 1;
|
||||
p[1].X = p[0].X + Dpi.Width5;
|
||||
p[1].Y = p[0].Y;
|
||||
p[2].X = p[0].X + Dpi.Width2;
|
||||
p[2].Y = p[0].Y + Dpi.Height3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
public override void ReadAttributes(XmlTextReader reader)
|
||||
{
|
||||
m_Direction = eExpandDirection.Default;
|
||||
|
||||
for (int i = 0; i < reader.AttributeCount; i++)
|
||||
{
|
||||
reader.MoveToAttribute(i);
|
||||
if (reader.Name.ToLower() == "direction")
|
||||
{
|
||||
string s = reader.Value.ToLower();
|
||||
if (s == "left")
|
||||
m_Direction = eExpandDirection.Left;
|
||||
else if (s == "right")
|
||||
m_Direction = eExpandDirection.Right;
|
||||
else if (s == "top")
|
||||
m_Direction = eExpandDirection.Top;
|
||||
else if (s == "bottom")
|
||||
m_Direction = eExpandDirection.Bottom;
|
||||
else if (s == "popup")
|
||||
m_Direction = eExpandDirection.PopupDropDown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum eExpandDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom,
|
||||
Default,
|
||||
PopupDropDown
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether layout manager can start new line with this element.
|
||||
/// </summary>
|
||||
public override bool CanStartNewLine
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
57
PROMS/DotNetBar Source Code/TextMarkup/FontChangeElement.cs
Normal file
57
PROMS/DotNetBar Source Code/TextMarkup/FontChangeElement.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class FontChangeElement : MarkupElement
|
||||
{
|
||||
#region Private Variables
|
||||
protected Font m_OldFont = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
|
||||
public override void Measure(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
this.Bounds = Rectangle.Empty;
|
||||
SetFont(d);
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
SetFont(d);
|
||||
}
|
||||
|
||||
protected virtual void SetFont(MarkupDrawContext d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void RenderEnd(MarkupDrawContext d)
|
||||
{
|
||||
if(m_OldFont!=null)
|
||||
d.CurrentFont = m_OldFont;
|
||||
m_OldFont = null;
|
||||
base.RenderEnd(d);
|
||||
}
|
||||
|
||||
public override void MeasureEnd(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
if (m_OldFont != null)
|
||||
d.CurrentFont = m_OldFont;
|
||||
m_OldFont = null;
|
||||
base.MeasureEnd(availableSize, d);
|
||||
}
|
||||
protected override void ArrangeCore(Rectangle finalRect, MarkupDrawContext d) { }
|
||||
#endregion
|
||||
}
|
||||
}
|
187
PROMS/DotNetBar Source Code/TextMarkup/FontElement.cs
Normal file
187
PROMS/DotNetBar Source Code/TextMarkup/FontElement.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
|
||||
#if AdvTree
|
||||
using DevComponents.Tree;
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class FontElement : FontChangeElement
|
||||
{
|
||||
#region Private Variables
|
||||
private Color m_ForeColor = Color.Empty;
|
||||
private Color m_OldForeColor = Color.Empty;
|
||||
private int m_Size = 0;
|
||||
private bool m_RelativeSize = false;
|
||||
private string m_Face = "";
|
||||
private string m_SystemColorName = "";
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
protected override void SetFont(MarkupDrawContext d)
|
||||
{
|
||||
Font font = d.CurrentFont;
|
||||
try
|
||||
{
|
||||
if (m_Face != "" || m_Size != 0 && m_RelativeSize || m_Size>4 && !m_RelativeSize)
|
||||
{
|
||||
if (m_Face != "")
|
||||
d.CurrentFont = new Font(m_Face, ((m_RelativeSize || m_Size == 0)?font.SizeInPoints + m_Size:m_Size), font.Style);
|
||||
else
|
||||
d.CurrentFont = new Font(font.FontFamily, ((m_RelativeSize || m_Size == 0)? font.SizeInPoints + m_Size : m_Size), font.Style);
|
||||
}
|
||||
else
|
||||
font = null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
font = null;
|
||||
}
|
||||
|
||||
if (font != null)
|
||||
m_OldFont = font;
|
||||
|
||||
if (!d.IgnoreFormattingColors)
|
||||
{
|
||||
if (!m_ForeColor.IsEmpty)
|
||||
{
|
||||
m_OldForeColor = d.CurrentForeColor;
|
||||
d.CurrentForeColor = m_ForeColor;
|
||||
}
|
||||
else if (m_SystemColorName != "")
|
||||
{
|
||||
#if DOTNETBAR
|
||||
if (Rendering.GlobalManager.Renderer is Rendering.Office2007Renderer)
|
||||
{
|
||||
m_OldForeColor = d.CurrentForeColor;
|
||||
d.CurrentForeColor = ((Rendering.Office2007Renderer)Rendering.GlobalManager.Renderer).ColorTable.Form.Active.CaptionTextExtra;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void RenderEnd(MarkupDrawContext d)
|
||||
{
|
||||
RestoreForeColor(d);
|
||||
|
||||
base.RenderEnd(d);
|
||||
}
|
||||
|
||||
public override void MeasureEnd(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
RestoreForeColor(d);
|
||||
base.MeasureEnd(availableSize, d);
|
||||
}
|
||||
|
||||
protected virtual void RestoreForeColor(MarkupDrawContext d)
|
||||
{
|
||||
if (d == null) return;
|
||||
if (!m_OldForeColor.IsEmpty)
|
||||
d.CurrentForeColor = m_OldForeColor;
|
||||
m_OldForeColor = Color.Empty;
|
||||
}
|
||||
|
||||
public Color ForeColor
|
||||
{
|
||||
get { return m_ForeColor; }
|
||||
set { m_ForeColor = value; }
|
||||
}
|
||||
|
||||
public int Size
|
||||
{
|
||||
get { return m_Size; }
|
||||
set { m_Size = value; }
|
||||
}
|
||||
|
||||
public string Face
|
||||
{
|
||||
get { return m_Face; }
|
||||
set { m_Face = value; }
|
||||
}
|
||||
|
||||
private Color GetColorFromName(string name)
|
||||
{
|
||||
string s = name.ToLower();
|
||||
m_SystemColorName = "";
|
||||
if (s == "syscaptiontextextra")
|
||||
{
|
||||
m_SystemColorName = s;
|
||||
return Color.Empty;
|
||||
}
|
||||
|
||||
return Color.FromName(name);
|
||||
}
|
||||
|
||||
public override void ReadAttributes(XmlTextReader reader)
|
||||
{
|
||||
m_RelativeSize = false;
|
||||
for (int i = 0; i < reader.AttributeCount; i++)
|
||||
{
|
||||
reader.MoveToAttribute(i);
|
||||
if (reader.Name.ToLower() == "color")
|
||||
{
|
||||
try
|
||||
{
|
||||
string s = reader.Value;
|
||||
if (s.StartsWith("#"))
|
||||
{
|
||||
if (s.Length == 7)
|
||||
m_ForeColor = ColorScheme.GetColor(s.Substring(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ForeColor = GetColorFromName(s);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_ForeColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
else if (reader.Name.ToLower() == "size")
|
||||
{
|
||||
string s = reader.Value;
|
||||
if (s.StartsWith("+"))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_Size = Int32.Parse(s.Substring(1));
|
||||
m_RelativeSize = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Size = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (s.StartsWith("-"))
|
||||
m_RelativeSize = true;
|
||||
try
|
||||
{
|
||||
m_Size = Int32.Parse(s);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_Size = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (reader.Name.ToLower() == "face")
|
||||
{
|
||||
m_Face = reader.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
97
PROMS/DotNetBar Source Code/TextMarkup/Heading.cs
Normal file
97
PROMS/DotNetBar Source Code/TextMarkup/Heading.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Heading: ContainerElement
|
||||
{
|
||||
#region Private Variables
|
||||
private int m_Level = 1;
|
||||
private Font m_OldFont = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public Heading() { }
|
||||
public Heading(int level)
|
||||
{
|
||||
m_Level = level;
|
||||
}
|
||||
|
||||
public override void Measure(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
SetFont(d);
|
||||
base.Measure(availableSize, d);
|
||||
if (m_OldFont != null)
|
||||
d.CurrentFont = m_OldFont;
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
SetFont(d);
|
||||
base.Render(d);
|
||||
if (m_OldFont != null)
|
||||
d.CurrentFont = m_OldFont;
|
||||
}
|
||||
|
||||
protected virtual void SetFont(MarkupDrawContext d)
|
||||
{
|
||||
Font font = d.CurrentFont;
|
||||
try
|
||||
{
|
||||
float size = d.CurrentFont.SizeInPoints;
|
||||
if (m_Level == 1)
|
||||
{
|
||||
size += 12;
|
||||
}
|
||||
else if (m_Level == 2)
|
||||
{
|
||||
size += 8;
|
||||
}
|
||||
else if (m_Level == 3)
|
||||
{
|
||||
size += 6;
|
||||
}
|
||||
else if (m_Level == 4)
|
||||
{
|
||||
size += 4;
|
||||
}
|
||||
else if (m_Level == 5)
|
||||
{
|
||||
size += 2;
|
||||
}
|
||||
else if (m_Level == 6)
|
||||
{
|
||||
size += 1;
|
||||
}
|
||||
|
||||
d.CurrentFont = new Font(d.CurrentFont.FontFamily, size, FontStyle.Bold);
|
||||
}
|
||||
catch
|
||||
{
|
||||
font = null;
|
||||
}
|
||||
|
||||
if (font != null)
|
||||
m_OldFont = font;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets heading level. Values from 1 to 6 are valid. Default is 1.
|
||||
/// </summary>
|
||||
public int Level
|
||||
{
|
||||
get { return m_Level; }
|
||||
set { m_Level = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
249
PROMS/DotNetBar Source Code/TextMarkup/HyperLink.cs
Normal file
249
PROMS/DotNetBar Source Code/TextMarkup/HyperLink.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class HyperLink : MarkupElement, IActiveMarkupElement
|
||||
{
|
||||
#region Private Variables
|
||||
private Color m_ForeColor = Color.Empty;
|
||||
private Color m_OldForeColor = Color.Empty;
|
||||
private string m_HRef = "";
|
||||
private string m_Name = "";
|
||||
private Cursor m_OldCursor = null;
|
||||
private bool m_IsMouseOver = false;
|
||||
private bool m_Visited = false;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void Measure(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
this.Bounds = Rectangle.Empty;
|
||||
SetForeColor(d);
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
d.HyperLink = true;
|
||||
d.HyperlinkStyle = GetHyperlinkStyle();
|
||||
if (!d.HyperlinkStyle.BackColor.IsEmpty)
|
||||
{
|
||||
using (GraphicsPath gp = new GraphicsPath())
|
||||
{
|
||||
MarkupElementCollection col = this.Parent.Elements;
|
||||
int start = col.IndexOf(this) + 1;
|
||||
for (int i = start; i < col.Count; i++)
|
||||
{
|
||||
MarkupElement elem = col[i];
|
||||
if (!elem.Visible) continue;
|
||||
if (elem is EndMarkupElement && ((EndMarkupElement)elem).StartElement == this)
|
||||
break;
|
||||
gp.AddRectangle(elem.RenderBounds);
|
||||
}
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(d.HyperlinkStyle.BackColor))
|
||||
d.Graphics.FillPath(brush, gp);
|
||||
}
|
||||
}
|
||||
SetForeColor(d);
|
||||
}
|
||||
|
||||
private HyperlinkStyle GetHyperlinkStyle()
|
||||
{
|
||||
if (m_IsMouseOver && MarkupSettings.MouseOverHyperlink.IsChanged)
|
||||
return MarkupSettings.MouseOverHyperlink;
|
||||
else if (m_Visited && MarkupSettings.VisitedHyperlink.IsChanged)
|
||||
return MarkupSettings.VisitedHyperlink;
|
||||
|
||||
return MarkupSettings.NormalHyperlink;
|
||||
}
|
||||
|
||||
protected virtual void SetForeColor(MarkupDrawContext d)
|
||||
{
|
||||
Color c = Color.Empty;
|
||||
HyperlinkStyle style = GetHyperlinkStyle();
|
||||
if (style != null && !style.TextColor.IsEmpty)
|
||||
c = style.TextColor;
|
||||
|
||||
if (!m_ForeColor.IsEmpty)
|
||||
c = m_ForeColor;
|
||||
if (!c.IsEmpty)
|
||||
{
|
||||
m_OldForeColor = d.CurrentForeColor;
|
||||
d.CurrentForeColor = c;
|
||||
}
|
||||
}
|
||||
|
||||
public override void RenderEnd(MarkupDrawContext d)
|
||||
{
|
||||
RestoreForeColor(d);
|
||||
d.HyperLink = false;
|
||||
d.HyperlinkStyle = null;
|
||||
base.RenderEnd(d);
|
||||
}
|
||||
|
||||
public override void MeasureEnd(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
RestoreForeColor(d);
|
||||
base.MeasureEnd(availableSize, d);
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(Rectangle finalRect, MarkupDrawContext d) { }
|
||||
|
||||
protected virtual void RestoreForeColor(MarkupDrawContext d)
|
||||
{
|
||||
if (d == null) return;
|
||||
if (!m_OldForeColor.IsEmpty)
|
||||
d.CurrentForeColor = m_OldForeColor;
|
||||
m_OldForeColor = Color.Empty;
|
||||
}
|
||||
|
||||
public Color ForeColor
|
||||
{
|
||||
get { return m_ForeColor; }
|
||||
set { m_ForeColor = value; }
|
||||
}
|
||||
|
||||
public string HRef
|
||||
{
|
||||
get { return m_HRef; }
|
||||
set { m_HRef = value; }
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return m_Name; }
|
||||
set { m_Name = value; }
|
||||
}
|
||||
|
||||
public override void ReadAttributes(XmlTextReader reader)
|
||||
{
|
||||
for (int i = 0; i < reader.AttributeCount; i++)
|
||||
{
|
||||
reader.MoveToAttribute(i);
|
||||
if (reader.Name.ToLower() == "href")
|
||||
{
|
||||
m_HRef = reader.Value;
|
||||
}
|
||||
else if (reader.Name.ToLower() == "name")
|
||||
{
|
||||
m_Name = reader.Value;
|
||||
}
|
||||
else if (reader.Name.ToLower() == "color")
|
||||
{
|
||||
try
|
||||
{
|
||||
string s = reader.Value;
|
||||
if (s.StartsWith("#"))
|
||||
{
|
||||
if (s.Length == 7)
|
||||
m_ForeColor = ColorScheme.GetColor(s.Substring(1));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ForeColor = GetColorFromName(s);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_ForeColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color GetColorFromName(string name)
|
||||
{
|
||||
return Color.FromName(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether hyper-link contains specified coordinates.
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
public bool HitTest(int x, int y)
|
||||
{
|
||||
if (this.Parent == null)
|
||||
return false;
|
||||
|
||||
MarkupElementCollection col = this.Parent.Elements;
|
||||
int start = col.IndexOf(this)+1;
|
||||
for (int i = start; i < col.Count; i++)
|
||||
{
|
||||
MarkupElement el = col[i];
|
||||
if (el is EndMarkupElement && ((EndMarkupElement)el).StartElement == this)
|
||||
break;
|
||||
|
||||
if (col[i].RenderBounds.Contains(x, y))
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void MouseEnter(Control parent)
|
||||
{
|
||||
m_OldCursor = parent.Cursor;
|
||||
parent.Cursor = Cursors.Hand;
|
||||
m_IsMouseOver = true;
|
||||
if (MarkupSettings.MouseOverHyperlink.IsChanged)
|
||||
{
|
||||
InvalidateElements(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public void MouseLeave(Control parent)
|
||||
{
|
||||
if (m_OldCursor != null && parent!=null)
|
||||
parent.Cursor = m_OldCursor;
|
||||
m_OldCursor = null;
|
||||
m_IsMouseOver = false;
|
||||
if (MarkupSettings.MouseOverHyperlink.IsChanged)
|
||||
{
|
||||
InvalidateElements(parent);
|
||||
}
|
||||
}
|
||||
|
||||
public void MouseDown(Control parent, MouseEventArgs e) { }
|
||||
public void MouseUp(Control parent, MouseEventArgs e) { }
|
||||
public void Click(Control parent)
|
||||
{
|
||||
m_Visited = true;
|
||||
if (MarkupSettings.VisitedHyperlink.IsChanged)
|
||||
{
|
||||
InvalidateElements(parent);
|
||||
}
|
||||
}
|
||||
|
||||
private void InvalidateElements(Control parent)
|
||||
{
|
||||
if (this.Parent == null) return;
|
||||
MarkupElementCollection col = this.Parent.Elements;
|
||||
int start = col.IndexOf(this) + 1;
|
||||
for (int i = start; i < col.Count; i++)
|
||||
{
|
||||
MarkupElement elem = col[i];
|
||||
if (!elem.Visible) continue;
|
||||
if (elem is EndMarkupElement && ((EndMarkupElement)elem).StartElement == this)
|
||||
break;
|
||||
parent.Invalidate(elem.RenderBounds);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal interface IActiveMarkupElement
|
||||
{
|
||||
bool HitTest(int x, int y);
|
||||
void MouseEnter(Control parent);
|
||||
void MouseLeave(Control parent);
|
||||
void MouseDown(Control parent, MouseEventArgs e);
|
||||
void MouseUp(Control parent, MouseEventArgs e);
|
||||
void Click(Control parent);
|
||||
}
|
||||
}
|
202
PROMS/DotNetBar Source Code/TextMarkup/ImageElement.cs
Normal file
202
PROMS/DotNetBar Source Code/TextMarkup/ImageElement.cs
Normal file
@@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
using System.Reflection;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
|
||||
{
|
||||
internal class ImageElement : MarkupElement
|
||||
{
|
||||
#region Private Variables
|
||||
private Size m_ImageSize = Size.Empty;
|
||||
private string m_ImageSource = "";
|
||||
private Image m_Image = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
if (!m_ImageSize.IsEmpty)
|
||||
this.Bounds = new Rectangle(Point.Empty, m_ImageSize);
|
||||
else if (m_ImageSource.Length == 0)
|
||||
this.Bounds = Rectangle.Empty;
|
||||
else
|
||||
{
|
||||
Image img = this.GetImage();
|
||||
if (img != null)
|
||||
this.Bounds = new Rectangle(Point.Empty, img.Size);
|
||||
else
|
||||
this.Bounds = new Rectangle(Point.Empty, new Size(16,16));
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsBlockElement
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private Image GetImage()
|
||||
{
|
||||
if (m_Image != null) return m_Image;
|
||||
Assembly a = null;
|
||||
|
||||
// Try static custom image resolver
|
||||
ResolveImageEventArgs e = new ResolveImageEventArgs();
|
||||
e.Key = m_ImageSource;
|
||||
e.ResolvedImage = null;
|
||||
MarkupSettings.InvokeResolveImage(e);
|
||||
if (e.Handled)
|
||||
return e.ResolvedImage;
|
||||
|
||||
// Load from format: ClassLibrary1/ClassLibrary1.MyImage.png or ClassLibrary1/global::ClassLibrary1.Resources.MyImage
|
||||
if (m_ImageSource.IndexOf('/') >= 0)
|
||||
{
|
||||
string[] parts = m_ImageSource.Split('/');
|
||||
a = Assembly.Load(parts[0]);
|
||||
string ResourceName = parts[1];
|
||||
if (a != null)
|
||||
{
|
||||
m_Image = LoadImageGlobalResource(parts[1], a);
|
||||
if (m_Image == null)
|
||||
m_Image = LoadImageResource(parts[1], a);
|
||||
|
||||
if (m_Image != null) return m_Image;
|
||||
}
|
||||
}
|
||||
|
||||
// Probe Executing Assembly
|
||||
a = Assembly.GetExecutingAssembly();
|
||||
m_Image = LoadImageGlobalResource(m_ImageSource, a);
|
||||
if(m_Image==null)
|
||||
m_Image = LoadImageResource(m_ImageSource, a);
|
||||
|
||||
// Probe Entry Assembly
|
||||
if (m_Image == null)
|
||||
{
|
||||
a = Assembly.GetEntryAssembly();
|
||||
m_Image = LoadImageGlobalResource(m_ImageSource, a);
|
||||
if (m_Image == null)
|
||||
m_Image = LoadImageResource(m_ImageSource, a);
|
||||
}
|
||||
|
||||
return m_Image;
|
||||
}
|
||||
|
||||
private Image LoadImageGlobalResource(string imageSource, Assembly a)
|
||||
{
|
||||
Image img = null;
|
||||
#if FRAMEWORK20
|
||||
if (imageSource.StartsWith("global::"))
|
||||
{
|
||||
string name = imageSource.Substring(8);
|
||||
if (name.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
int i = name.LastIndexOf('.');
|
||||
string resName = name.Substring(0, i);
|
||||
name = name.Substring(i + 1);
|
||||
System.Resources.ResourceManager r = new System.Resources.ResourceManager(resName, a);
|
||||
object obj = r.GetObject(name);
|
||||
img = (Bitmap)obj;
|
||||
}
|
||||
catch
|
||||
{
|
||||
img = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return img;
|
||||
}
|
||||
|
||||
private Image LoadImageResource(string imageSource, Assembly a)
|
||||
{
|
||||
Image img = null;
|
||||
try
|
||||
{
|
||||
img = new Bitmap(a.GetManifestResourceStream(imageSource));
|
||||
}
|
||||
catch { }
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
Rectangle r = this.Bounds;
|
||||
r.Offset(d.Offset);
|
||||
|
||||
if (!d.ClipRectangle.IsEmpty && !r.IntersectsWith(d.ClipRectangle))
|
||||
return;
|
||||
|
||||
Image img = this.GetImage();
|
||||
if (img != null)
|
||||
{
|
||||
Rectangle imageRect = r;
|
||||
if (m_ImageSize.IsEmpty)
|
||||
imageRect.Size = img.Size;
|
||||
else
|
||||
imageRect.Size = m_ImageSize;
|
||||
d.Graphics.DrawImage(img, imageRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (SolidBrush brush = new SolidBrush(Color.White))
|
||||
{
|
||||
d.Graphics.FillRectangle(brush, r);
|
||||
}
|
||||
using (Pen pen = new Pen(Color.DarkGray, 1))
|
||||
{
|
||||
d.Graphics.DrawRectangle(pen, r);
|
||||
d.Graphics.DrawLine(pen, r.X, r.Y, r.Right, r.Bottom);
|
||||
d.Graphics.DrawLine(pen, r.Right, r.Y, r.X, r.Bottom);
|
||||
}
|
||||
}
|
||||
|
||||
this.RenderBounds = r;
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d) { }
|
||||
|
||||
public override void ReadAttributes(XmlTextReader reader)
|
||||
{
|
||||
m_ImageSize = Size.Empty;
|
||||
m_ImageSource = "";
|
||||
m_Image = null;
|
||||
|
||||
for (int i = 0; i < reader.AttributeCount; i++)
|
||||
{
|
||||
reader.MoveToAttribute(i);
|
||||
if (reader.Name.ToLower() == "width")
|
||||
{
|
||||
string s = reader.Value;
|
||||
m_ImageSize.Width = int.Parse(s);
|
||||
}
|
||||
else if (reader.Name.ToLower() == "height")
|
||||
{
|
||||
string s = reader.Value;
|
||||
m_ImageSize.Height = int.Parse(s);
|
||||
}
|
||||
else if (reader.Name.ToLower() == "src")
|
||||
{
|
||||
m_ImageSource = reader.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
35
PROMS/DotNetBar Source Code/TextMarkup/Italic.cs
Normal file
35
PROMS/DotNetBar Source Code/TextMarkup/Italic.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Italic : FontChangeElement
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override void SetFont(MarkupDrawContext d)
|
||||
{
|
||||
Font font = d.CurrentFont;
|
||||
FontStyle style=font.Style | FontStyle.Italic;
|
||||
|
||||
if (!font.Italic && d.CurrentFont.FontFamily.IsStyleAvailable(style))
|
||||
d.CurrentFont = new Font(font, style);
|
||||
else
|
||||
font = null;
|
||||
|
||||
if (font != null)
|
||||
m_OldFont = font;
|
||||
|
||||
base.SetFont(d);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
58
PROMS/DotNetBar Source Code/TextMarkup/MarkupDrawContext.cs
Normal file
58
PROMS/DotNetBar Source Code/TextMarkup/MarkupDrawContext.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
public class MarkupDrawContext
|
||||
{
|
||||
public Graphics Graphics = null;
|
||||
public Font CurrentFont = null;
|
||||
public Color CurrentForeColor = SystemColors.ControlText;
|
||||
public bool RightToLeft = false;
|
||||
public Point Offset = Point.Empty;
|
||||
public bool HyperLink = false;
|
||||
public HyperlinkStyle HyperlinkStyle = null;
|
||||
public bool Underline = false;
|
||||
public Rectangle ClipRectangle = Rectangle.Empty;
|
||||
public bool HotKeyPrefixVisible = false;
|
||||
public object ContextObject = null;
|
||||
public bool AllowMultiLine = true;
|
||||
public bool IgnoreFormattingColors = false;
|
||||
public bool StrikeOut;
|
||||
|
||||
public MarkupDrawContext(Graphics g, Font currentFont, Color currentForeColor, bool rightToLeft) : this(g, currentFont, currentForeColor, rightToLeft, Rectangle.Empty, false)
|
||||
{
|
||||
}
|
||||
|
||||
public MarkupDrawContext(Graphics g, Font currentFont, Color currentForeColor, bool rightToLeft, Rectangle clipRectangle, bool hotKeyPrefixVisible)
|
||||
{
|
||||
this.Graphics = g;
|
||||
this.CurrentFont = currentFont;
|
||||
this.CurrentForeColor = currentForeColor;
|
||||
this.RightToLeft = rightToLeft;
|
||||
this.ClipRectangle = clipRectangle;
|
||||
this.HotKeyPrefixVisible = hotKeyPrefixVisible;
|
||||
}
|
||||
|
||||
public MarkupDrawContext(Graphics g, Font currentFont, Color currentForeColor, bool rightToLeft, Rectangle clipRectangle, bool hotKeyPrefixVisible, object contextObject)
|
||||
{
|
||||
this.Graphics = g;
|
||||
this.CurrentFont = currentFont;
|
||||
this.CurrentForeColor = currentForeColor;
|
||||
this.RightToLeft = rightToLeft;
|
||||
this.ClipRectangle = clipRectangle;
|
||||
this.HotKeyPrefixVisible = hotKeyPrefixVisible;
|
||||
this.ContextObject = contextObject;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
197
PROMS/DotNetBar Source Code/TextMarkup/MarkupElement.cs
Normal file
197
PROMS/DotNetBar Source Code/TextMarkup/MarkupElement.cs
Normal file
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
using DevComponents.UI.ContentManager;
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal abstract class MarkupElement : IBlockExtended
|
||||
{
|
||||
#region Private Variables
|
||||
private MarkupElementCollection m_Elements = null;
|
||||
private MarkupElement m_Parent = null;
|
||||
private Rectangle m_Bounds = Rectangle.Empty;
|
||||
private bool m_Visible = true;
|
||||
private bool m_SizeValid = false;
|
||||
private Rectangle m_RenderBounds = Rectangle.Empty;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public MarkupElement()
|
||||
{
|
||||
m_Elements = new MarkupElementCollection(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns whether markup element is an container so it receives full available size of parent control for layout.
|
||||
/// </summary>
|
||||
public virtual bool IsBlockContainer
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether markup element is an block element that always consumes a whole line in layout.
|
||||
/// </summary>
|
||||
public virtual bool IsBlockElement
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether layout manager switches to new line after processing this element.
|
||||
/// </summary>
|
||||
public virtual bool IsNewLineAfterElement
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether layout manager can start new line with this element.
|
||||
/// </summary>
|
||||
public virtual bool CanStartNewLine
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of child elements if any for this markup element.
|
||||
/// </summary>
|
||||
public virtual MarkupElementCollection Elements
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Elements == null)
|
||||
m_Elements = new MarkupElementCollection(this);
|
||||
return m_Elements;
|
||||
}
|
||||
}
|
||||
|
||||
internal void InvalidateElementsSize()
|
||||
{
|
||||
this.IsSizeValid = false;
|
||||
if (m_Elements==null || m_Elements.Count == 0)
|
||||
return;
|
||||
foreach (MarkupElement e in m_Elements)
|
||||
{
|
||||
e.InvalidateElementsSize();
|
||||
e.IsSizeValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether element size is valid. When size is not valid element Measure method will be called to validate size.
|
||||
/// </summary>
|
||||
public virtual bool IsSizeValid
|
||||
{
|
||||
get { return m_SizeValid; }
|
||||
set { m_SizeValid = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets element parent or null if parent is not set.
|
||||
/// </summary>
|
||||
public virtual MarkupElement Parent
|
||||
{
|
||||
get { return m_Parent; }
|
||||
}
|
||||
|
||||
internal void SetParent(MarkupElement parent)
|
||||
{
|
||||
m_Parent = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets actual rendering bounds.
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get { return m_Bounds; }
|
||||
set { m_Bounds = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether markup element is visible.
|
||||
/// </summary>
|
||||
public bool Visible
|
||||
{
|
||||
get { return m_Visible; }
|
||||
set { m_Visible = value; }
|
||||
}
|
||||
|
||||
private Padding _Margin = new Padding(0);
|
||||
/// <summary>
|
||||
/// Gets or sets the element margin.
|
||||
/// </summary>
|
||||
public Padding Margin
|
||||
{
|
||||
get { return _Margin; }
|
||||
set { _Margin = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Measures the element given available size.
|
||||
/// </summary>
|
||||
/// <param name="availableSize">Size available to element</param>
|
||||
/// <param name="g">Reference to graphics object</param>
|
||||
public abstract void Measure(Size availableSize, MarkupDrawContext d);
|
||||
|
||||
/// <summary>
|
||||
/// Measures the end tag of an element. Most implementations do not need to do anything but implementations like the ones
|
||||
/// that change color should return state back at this time.
|
||||
/// </summary>
|
||||
/// <param name="availableSize"></param>
|
||||
/// <param name="d"></param>
|
||||
public virtual void MeasureEnd(Size availableSize, MarkupDrawContext d) { }
|
||||
|
||||
/// <summary>
|
||||
/// Renders element.
|
||||
/// </summary>
|
||||
/// <param name="d">Provides markup drawing context information.</param>
|
||||
public abstract void Render(MarkupDrawContext d);
|
||||
|
||||
/// <summary>
|
||||
/// Renders element tag end. Most implementations do not need to do anything but mplementations like the ones
|
||||
/// that change color should return state back at this time.
|
||||
/// </summary>
|
||||
/// <param name="d">Provides markup drawing context information.</param>
|
||||
public virtual void RenderEnd(MarkupDrawContext d) { }
|
||||
|
||||
/// <summary>
|
||||
/// Provides final rectangle to element and lets it arrange it's content given new constraint.
|
||||
/// </summary>
|
||||
/// <param name="finalRect">Final rectangle.</param>
|
||||
/// <param name="g"></param>
|
||||
protected abstract void ArrangeCore(Rectangle finalRect, MarkupDrawContext d);
|
||||
|
||||
/// <summary>
|
||||
/// Arranges the element given the final size. Layout is two step process with Measure followed by Arrange.
|
||||
/// </summary>
|
||||
/// <param name="finalSize"></param>
|
||||
/// <param name="g"></param>
|
||||
public void Arrange(Rectangle finalSize, MarkupDrawContext d)
|
||||
{
|
||||
this.ArrangeCore(finalSize, d);
|
||||
}
|
||||
|
||||
public virtual void ReadAttributes(XmlTextReader reader) { }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets actual rendered bounds for a give markup element if applicable.
|
||||
/// </summary>
|
||||
public Rectangle RenderBounds
|
||||
{
|
||||
get { return m_RenderBounds; }
|
||||
set { m_RenderBounds = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class MarkupElementCollection : CollectionBase
|
||||
{
|
||||
#region Private Variables
|
||||
private MarkupElement m_Parent = null;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>Creates new instance of the class.</summary>
|
||||
public MarkupElementCollection(MarkupElement parent)
|
||||
{
|
||||
m_Parent = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the collection parent element.
|
||||
/// </summary>
|
||||
public MarkupElement Parent
|
||||
{
|
||||
get { return m_Parent; }
|
||||
set { m_Parent = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds new object to the collection.
|
||||
/// </summary>
|
||||
/// <param name="MarkupElement">Object to add.</param>
|
||||
/// <returns>Index of newly added object.</returns>
|
||||
public int Add(MarkupElement MarkupElement)
|
||||
{
|
||||
return List.Add(MarkupElement);
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns reference to the object in collection based on it's index.
|
||||
/// </summary>
|
||||
public MarkupElement this[int index]
|
||||
{
|
||||
get {return (MarkupElement)(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, MarkupElement 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(MarkupElement 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(MarkupElement value)
|
||||
{
|
||||
return List.Contains(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes specified object from the collection.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void Remove(MarkupElement value)
|
||||
{
|
||||
List.Remove(value);
|
||||
}
|
||||
|
||||
protected override void OnRemoveComplete(int index,object value)
|
||||
{
|
||||
base.OnRemoveComplete(index,value);
|
||||
MarkupElement me=value as MarkupElement;
|
||||
if (m_Parent != null)
|
||||
{
|
||||
me.SetParent(null);
|
||||
m_Parent.IsSizeValid = false;
|
||||
}
|
||||
}
|
||||
protected override void OnInsertComplete(int index,object value)
|
||||
{
|
||||
base.OnInsertComplete(index,value);
|
||||
MarkupElement me=value as MarkupElement;
|
||||
if (m_Parent != null)
|
||||
{
|
||||
me.SetParent(m_Parent);
|
||||
m_Parent.IsSizeValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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(MarkupElement[] array, int index)
|
||||
{
|
||||
List.CopyTo(array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies contained items to the MarkupElement array.
|
||||
/// </summary>
|
||||
/// <param name="array">Array to copy to.</param>
|
||||
internal void CopyTo(MarkupElement[] array)
|
||||
{
|
||||
List.CopyTo(array,0);
|
||||
}
|
||||
|
||||
protected override void OnClear()
|
||||
{
|
||||
base.OnClear();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
using DevComponents.UI.ContentManager;
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class MarkupLayoutManager : BlockLayoutManager
|
||||
{
|
||||
private MarkupDrawContext m_MarkupDrawContext = null;
|
||||
|
||||
public MarkupDrawContext MarkupDrawContext
|
||||
{
|
||||
get { return m_MarkupDrawContext; }
|
||||
set { m_MarkupDrawContext = value; }
|
||||
}
|
||||
|
||||
public override void Layout(IBlock block, Size availableSize)
|
||||
{
|
||||
if (block is MarkupElement)
|
||||
{
|
||||
MarkupElement m = block as MarkupElement;
|
||||
if(!m.IsSizeValid)
|
||||
m.Measure(availableSize, m_MarkupDrawContext);
|
||||
}
|
||||
}
|
||||
|
||||
public override Rectangle FinalizeLayout(Rectangle containerBounds, Rectangle blocksBounds, ArrayList lines)
|
||||
{
|
||||
return (blocksBounds);
|
||||
}
|
||||
}
|
||||
}
|
256
PROMS/DotNetBar Source Code/TextMarkup/MarkupParser.cs
Normal file
256
PROMS/DotNetBar Source Code/TextMarkup/MarkupParser.cs
Normal file
@@ -0,0 +1,256 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Collections;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class MarkupParser
|
||||
{
|
||||
#region Private Variables
|
||||
private static string TextElementName = "text";
|
||||
private static string BodyTag = "body";
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public static BodyElement Parse(string text)
|
||||
{
|
||||
StringBuilder plainText = new StringBuilder(text.Length);
|
||||
BodyElement root = new BodyElement();
|
||||
root.HasExpandElement = false;
|
||||
MarkupElement currentParent = root;
|
||||
Stack openTags = new Stack();
|
||||
openTags.Push(root);
|
||||
// Input text is not wrapped into the container tag so we wrap it here
|
||||
text = text.Replace(" ", "{ent_nbsp}");
|
||||
text = text.Replace("&zwsp;", "{ent_zwsp}");
|
||||
text = text.Replace("<", "{ent_lt}");
|
||||
text = text.Replace(">", "{ent_gt}");
|
||||
text = text.Replace("&", "{ent_amp}");
|
||||
text = text.Replace("|", "{ent_l}");
|
||||
text = text.Replace("&", "|");
|
||||
text = text.Replace("{ent_nbsp}", " ");
|
||||
text = text.Replace("{ent_zwsp}", "&zwsp;");
|
||||
text = text.Replace("{ent_lt}", "<");
|
||||
text = text.Replace("{ent_gt}", ">");
|
||||
StringReader sr = new StringReader("<"+BodyTag+">" + text + "</"+BodyTag+">");
|
||||
#if !DEBUG
|
||||
try
|
||||
#endif
|
||||
{
|
||||
XmlTextReader reader = new XmlTextReader(sr);
|
||||
//reader.EntityHandling = EntityHandling.ExpandCharEntities;
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.NodeType == XmlNodeType.Element)
|
||||
{
|
||||
if (reader.Name == BodyTag)
|
||||
continue;
|
||||
MarkupElement el = CreateMarkupElement(reader.Name);
|
||||
if (el == null)
|
||||
{
|
||||
reader.Skip();
|
||||
continue;
|
||||
}
|
||||
else if (el is ExpandElement)
|
||||
root.HasExpandElement = true;
|
||||
|
||||
if (el is IActiveMarkupElement)
|
||||
root.ActiveElements.Add(el);
|
||||
|
||||
// Parse any attributes here
|
||||
if (reader.AttributeCount > 0)
|
||||
{
|
||||
el.ReadAttributes(reader);
|
||||
reader.MoveToElement();
|
||||
}
|
||||
|
||||
currentParent.Elements.Add(el);
|
||||
|
||||
if (el is ContainerElement)
|
||||
currentParent = el;
|
||||
|
||||
if (!reader.IsEmptyElement)
|
||||
openTags.Push(el);
|
||||
}
|
||||
else if (reader.NodeType == XmlNodeType.Text)
|
||||
{
|
||||
if (reader.Value.Length == 1)
|
||||
{
|
||||
TextElement el = CreateMarkupElement(TextElementName) as TextElement;
|
||||
if (reader.Value == " ")
|
||||
{
|
||||
el.TrailingSpace = true;
|
||||
plainText.Append(' ');
|
||||
}
|
||||
else
|
||||
{
|
||||
el.Text = reader.Value;
|
||||
el.Text = el.Text.Replace("|", "&");
|
||||
el.Text = el.Text.Replace("{ent_l}", "|");
|
||||
el.Text = el.Text.Replace("{ent_amp}", "&&");
|
||||
plainText.Append(el.Text+" ");
|
||||
}
|
||||
currentParent.Elements.Add(el);
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = reader.Value;
|
||||
if (s.StartsWith("\r\n"))
|
||||
s = s.TrimStart(new char[] { '\r', '\n' });
|
||||
s = s.Replace("\r\n", " ");
|
||||
string[] words = s.Split(' ');
|
||||
bool space = false;
|
||||
if (currentParent.Elements.Count > 0 && currentParent.Elements[currentParent.Elements.Count - 1] is NewLine)
|
||||
space = true;
|
||||
for (int i = 0; i < words.Length; i++)
|
||||
{
|
||||
if (words[i].Length == 0)
|
||||
{
|
||||
if (space)
|
||||
continue;
|
||||
space = true;
|
||||
}
|
||||
else
|
||||
space = false;
|
||||
|
||||
TextElement el = CreateMarkupElement(TextElementName) as TextElement;
|
||||
el.Text = words[i].Replace("|","&");
|
||||
el.Text = el.Text.Replace("{ent_l}", "|");
|
||||
el.Text = el.Text.Replace("{ent_amp}", "&&");
|
||||
plainText.Append(el.Text + " ");
|
||||
if (i < words.Length - 1)
|
||||
{
|
||||
el.TrailingSpace = true;
|
||||
space = true;
|
||||
}
|
||||
|
||||
currentParent.Elements.Add(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (reader.NodeType == XmlNodeType.Whitespace)
|
||||
{
|
||||
if (reader.Value.IndexOf(' ') >= 0)
|
||||
{
|
||||
TextElement el = CreateMarkupElement(TextElementName) as TextElement;
|
||||
el.TrailingSpace = true;
|
||||
currentParent.Elements.Add(el);
|
||||
}
|
||||
}
|
||||
else if (reader.NodeType == XmlNodeType.EntityReference)
|
||||
{
|
||||
TextElement el = CreateMarkupElement(TextElementName) as TextElement;
|
||||
if (reader.Name == "nbsp")
|
||||
{
|
||||
el.TrailingSpace = true;
|
||||
}
|
||||
else if (reader.Name == "zwsp")
|
||||
{
|
||||
el.TrailingSpace = false;
|
||||
}
|
||||
else
|
||||
el.Text = reader.Name;
|
||||
el.EnablePrefixHandling = false;
|
||||
currentParent.Elements.Add(el);
|
||||
}
|
||||
else if (reader.NodeType == XmlNodeType.EndElement)
|
||||
{
|
||||
MarkupElement el = openTags.Pop() as MarkupElement;
|
||||
if (el != currentParent)
|
||||
{
|
||||
currentParent.Elements.Add(new EndMarkupElement(el));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentParent != root)
|
||||
currentParent = currentParent.Parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if !DEBUG
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
root.PlainText = plainText.ToString();
|
||||
return root;
|
||||
}
|
||||
|
||||
public static MarkupElement CreateMarkupElement(string elementName)
|
||||
{
|
||||
if (elementName == "b" || elementName == "strong")
|
||||
return new Strong();
|
||||
else if (elementName == "i" || elementName == "em")
|
||||
return new Italic();
|
||||
else if (elementName == "u")
|
||||
return new Underline();
|
||||
else if (elementName == "br")
|
||||
return new NewLine();
|
||||
else if (elementName == "expand")
|
||||
return new ExpandElement();
|
||||
else if (elementName == "a")
|
||||
return new HyperLink();
|
||||
else if (elementName == "p")
|
||||
return new Paragraph();
|
||||
else if (elementName == "div")
|
||||
return new Div();
|
||||
else if (elementName == "span")
|
||||
return new Span();
|
||||
else if (elementName == "img")
|
||||
return new ImageElement();
|
||||
else if (elementName == "h1")
|
||||
return new Heading();
|
||||
else if (elementName == "h2")
|
||||
return new Heading(2);
|
||||
else if (elementName == "h3")
|
||||
return new Heading(3);
|
||||
else if (elementName == "h4")
|
||||
return new Heading(4);
|
||||
else if (elementName == "h5")
|
||||
return new Heading(5);
|
||||
else if (elementName == "h6")
|
||||
return new Heading(6);
|
||||
else if (elementName == "font")
|
||||
return new FontElement();
|
||||
else if (elementName == "s" || elementName == "strike")
|
||||
return new Strike();
|
||||
else if (elementName == TextElementName)
|
||||
return new TextElement();
|
||||
else if (elementName == "symbol")
|
||||
return new SymbolElement();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether input text could be markup text.
|
||||
/// </summary>
|
||||
/// <param name="text">Text to test.</param>
|
||||
/// <returns>true if text could be markup, otherwise false</returns>
|
||||
public static bool IsMarkup(ref string text)
|
||||
{
|
||||
if (text == null || text.IndexOf("</") < 0 && text.IndexOf("/>") < 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static string RemoveExpand(string text)
|
||||
{
|
||||
return Regex.Replace(text, "<expand.*?>", "", RegexOptions.IgnoreCase);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
189
PROMS/DotNetBar Source Code/TextMarkup/MarkupSettings.cs
Normal file
189
PROMS/DotNetBar Source Code/TextMarkup/MarkupSettings.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
#if FRAMEWORK20
|
||||
public static class MarkupSettings
|
||||
#else
|
||||
public class MarkupSettings
|
||||
#endif
|
||||
{
|
||||
private static HyperlinkStyle _NormalHyperlink = new HyperlinkStyle(Color.Blue, eHyperlinkUnderlineStyle.SolidLine);
|
||||
/// <summary>
|
||||
/// Gets the style of the hyperlink in its default state.
|
||||
/// </summary>
|
||||
public static HyperlinkStyle NormalHyperlink
|
||||
{
|
||||
get { return _NormalHyperlink; }
|
||||
}
|
||||
|
||||
private static HyperlinkStyle _MouseOverHyperlink = new HyperlinkStyle();
|
||||
/// <summary>
|
||||
/// Gets the style of the hyperlink when mouse is over the link.
|
||||
/// </summary>
|
||||
public static HyperlinkStyle MouseOverHyperlink
|
||||
{
|
||||
get { return _MouseOverHyperlink; }
|
||||
}
|
||||
|
||||
private static HyperlinkStyle _VisitedHyperlink = new HyperlinkStyle();
|
||||
/// <summary>
|
||||
/// Gets the style of the visited hyperlink.
|
||||
/// </summary>
|
||||
public static HyperlinkStyle VisitedHyperlink
|
||||
{
|
||||
get { return _VisitedHyperlink; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the ResolveImage event.
|
||||
/// </summary>
|
||||
public delegate void ResolveImageEventHandler(object sender, ResolveImageEventArgs e);
|
||||
// <summary>
|
||||
/// Occurs when DotNetBar is looking for an image for one of the internal img tags that is
|
||||
/// used within the minimarkup. You need to set Handled=true if you want your custom image
|
||||
/// to be used instead of the built-in resource resolving mechanism.
|
||||
/// </summary>
|
||||
public static event ResolveImageEventHandler ResolveImage;
|
||||
internal static void InvokeResolveImage(ResolveImageEventArgs e)
|
||||
{
|
||||
if (ResolveImage != null)
|
||||
ResolveImage(null, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the text-markup hyperlink appearance style.
|
||||
/// </summary>
|
||||
public class HyperlinkStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the HyperlinkStyle class.
|
||||
/// </summary>
|
||||
public HyperlinkStyle()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the HyperlinkStyle class.
|
||||
/// </summary>
|
||||
/// <param name="textColor"></param>
|
||||
/// <param name="underlineStyle"></param>
|
||||
public HyperlinkStyle(Color textColor, eHyperlinkUnderlineStyle underlineStyle)
|
||||
{
|
||||
_TextColor = textColor;
|
||||
_UnderlineStyle = underlineStyle;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the HyperlinkStyle class.
|
||||
/// </summary>
|
||||
/// <param name="textColor"></param>
|
||||
/// <param name="backColor"></param>
|
||||
/// <param name="underlineStyle"></param>
|
||||
public HyperlinkStyle(Color textColor, Color backColor, eHyperlinkUnderlineStyle underlineStyle)
|
||||
{
|
||||
_TextColor = textColor;
|
||||
_BackColor = backColor;
|
||||
_UnderlineStyle = underlineStyle;
|
||||
}
|
||||
private Color _TextColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets hyperlink text color.
|
||||
/// </summary>
|
||||
public Color TextColor
|
||||
{
|
||||
get { return _TextColor; }
|
||||
set
|
||||
{
|
||||
if (_TextColor != value)
|
||||
{
|
||||
_TextColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color _BackColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets hyperlink back color.
|
||||
/// </summary>
|
||||
public Color BackColor
|
||||
{
|
||||
get { return _BackColor; }
|
||||
set
|
||||
{
|
||||
if (_BackColor != value)
|
||||
{
|
||||
_BackColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private eHyperlinkUnderlineStyle _UnderlineStyle = eHyperlinkUnderlineStyle.None;
|
||||
/// <summary>
|
||||
/// Gets or sets the underline style for the hyperlink.
|
||||
/// </summary>
|
||||
public eHyperlinkUnderlineStyle UnderlineStyle
|
||||
{
|
||||
get { return _UnderlineStyle; }
|
||||
set
|
||||
{
|
||||
if (_UnderlineStyle != value)
|
||||
{
|
||||
_UnderlineStyle = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether style has been changed from its default state.
|
||||
/// </summary>
|
||||
public bool IsChanged
|
||||
{
|
||||
get { return !_TextColor.IsEmpty || !_BackColor.IsEmpty || _UnderlineStyle != eHyperlinkUnderlineStyle.None; }
|
||||
}
|
||||
}
|
||||
|
||||
public enum eHyperlinkUnderlineStyle
|
||||
{
|
||||
None,
|
||||
SolidLine,
|
||||
DashedLine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Event arguments for ResolveImage event.
|
||||
/// </summary>
|
||||
public class ResolveImageEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that event has been handled and that ResolvedImage should be used.
|
||||
/// </summary>
|
||||
public bool Handled = false;
|
||||
/// <summary>
|
||||
/// Indicates the string key parameters in url-style for the image that needs to be resolved.
|
||||
/// </summary>
|
||||
public string Key = "";
|
||||
/// <summary>
|
||||
/// Indicates the resolved image value.
|
||||
/// you need to set this value to the resolved image and you need to set Handled property to true.
|
||||
/// </summary>
|
||||
public Image ResolvedImage = null;
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public ResolveImageEventArgs() { }
|
||||
}
|
||||
|
||||
}
|
47
PROMS/DotNetBar Source Code/TextMarkup/NewLine.cs
Normal file
47
PROMS/DotNetBar Source Code/TextMarkup/NewLine.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class NewLine : MarkupElement
|
||||
{
|
||||
#region Internal Implementation
|
||||
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
// Causes layout manager to switch to the new line
|
||||
this.Bounds = new Rectangle(0, 0, 0, d.CurrentFont.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether element size is valid. When size is not valid element Measure method will be called to validate size.
|
||||
/// </summary>
|
||||
public override bool IsSizeValid
|
||||
{
|
||||
get { return false; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d) {}
|
||||
|
||||
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d) { }
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether layout manager switches to new line after processing this element.
|
||||
/// </summary>
|
||||
public override bool IsNewLineAfterElement
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
29
PROMS/DotNetBar Source Code/TextMarkup/Paragraph.cs
Normal file
29
PROMS/DotNetBar Source Code/TextMarkup/Paragraph.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Xml;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
using DevComponents.UI.ContentManager;
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Paragraph : Div
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override void ArrangeInternal(Rectangle bounds, MarkupDrawContext d)
|
||||
{
|
||||
base.ArrangeInternal(bounds, d);
|
||||
this.Bounds = new Rectangle(this.Bounds.X, this.Bounds.Y, this.Bounds.Width , this.Bounds.Height + d.CurrentFont.Height);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
}
|
25
PROMS/DotNetBar Source Code/TextMarkup/Span.cs
Normal file
25
PROMS/DotNetBar Source Code/TextMarkup/Span.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
#if AdvTree
|
||||
using DevComponents.Tree;
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Span : Div
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns whether markup element is an block element that always consumes a whole line in layout.
|
||||
/// </summary>
|
||||
public override bool IsBlockElement
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
36
PROMS/DotNetBar Source Code/TextMarkup/Strike.cs
Normal file
36
PROMS/DotNetBar Source Code/TextMarkup/Strike.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Strike : MarkupElement
|
||||
{
|
||||
public override void Measure(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
Bounds = Rectangle.Empty;
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
d.StrikeOut = true;
|
||||
}
|
||||
|
||||
public override void RenderEnd(MarkupDrawContext d)
|
||||
{
|
||||
d.StrikeOut = false;
|
||||
|
||||
base.RenderEnd(d);
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(Rectangle finalRect, MarkupDrawContext d)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
35
PROMS/DotNetBar Source Code/TextMarkup/Strong.cs
Normal file
35
PROMS/DotNetBar Source Code/TextMarkup/Strong.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Strong : FontChangeElement
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override void SetFont(MarkupDrawContext d)
|
||||
{
|
||||
Font font = d.CurrentFont;
|
||||
FontStyle style = d.CurrentFont.Style | FontStyle.Bold;
|
||||
|
||||
if (!font.Bold && font.FontFamily.IsStyleAvailable(style))
|
||||
d.CurrentFont = new Font(d.CurrentFont, style);
|
||||
else
|
||||
font = null;
|
||||
|
||||
if (font != null)
|
||||
m_OldFont = font;
|
||||
|
||||
base.SetFont(d);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
95
PROMS/DotNetBar Source Code/TextMarkup/SymbolElement.cs
Normal file
95
PROMS/DotNetBar Source Code/TextMarkup/SymbolElement.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Xml;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class SymbolElement : MarkupElement
|
||||
{
|
||||
#region Internal Implementation
|
||||
private Size _DefaultSize = new Size(16, 16);
|
||||
private eSymbol _Symbol = eSymbol.XInCircle;
|
||||
|
||||
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
this.Bounds = new Rectangle(Point.Empty, Dpi.Size(_DefaultSize));
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d) { }
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
Rectangle r = this.Bounds;
|
||||
r.Offset(d.Offset);
|
||||
|
||||
if (!d.ClipRectangle.IsEmpty && !r.IntersectsWith(d.ClipRectangle))
|
||||
return;
|
||||
|
||||
Graphics g = d.Graphics;
|
||||
Color color = d.CurrentForeColor;
|
||||
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
if (_Symbol == eSymbol.XInCircle)
|
||||
{
|
||||
Rectangle sr = new Rectangle(r.X + (r.Width - Dpi.Width14) / 2, r.Y + (r.Height - Dpi.Height14) / 2, Dpi.Width14, Dpi.Height14);
|
||||
using (Pen pen = new Pen(color, 1.51f))
|
||||
{
|
||||
//sr.Width-=2;
|
||||
//sr.Height-=2;
|
||||
g.DrawEllipse(pen, sr);
|
||||
g.DrawLine(pen, sr.X + Dpi.Width4, sr.Y + Dpi.Height4, sr.X + Dpi.Width10, sr.Y + Dpi.Height10);
|
||||
g.DrawLine(pen, sr.X + Dpi.Width10, sr.Y + Dpi.Height4, sr.X + Dpi.Width4, sr.Y + Dpi.Height10);
|
||||
}
|
||||
}
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
|
||||
this.RenderBounds = r;
|
||||
}
|
||||
|
||||
public override void ReadAttributes(XmlTextReader reader)
|
||||
{
|
||||
_Symbol = eSymbol.XInCircle;
|
||||
|
||||
for (int i = 0; i < reader.AttributeCount; i++)
|
||||
{
|
||||
reader.MoveToAttribute(i);
|
||||
if (reader.Name.ToLower() == "type")
|
||||
{
|
||||
string s = reader.Value.ToLower();
|
||||
if (s == "xincircle")
|
||||
_Symbol = eSymbol.XInCircle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private enum eSymbol
|
||||
{
|
||||
XInCircle
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether layout manager can start new line with this element.
|
||||
/// </summary>
|
||||
public override bool CanStartNewLine
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
224
PROMS/DotNetBar Source Code/TextMarkup/TextElement.cs
Normal file
224
PROMS/DotNetBar Source Code/TextMarkup/TextElement.cs
Normal file
@@ -0,0 +1,224 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class TextElement : MarkupElement
|
||||
{
|
||||
private static bool PadText = false;
|
||||
static TextElement()
|
||||
{
|
||||
string lc = System.Windows.Forms.Application.CurrentCulture.TwoLetterISOLanguageName;
|
||||
if (lc == "ja")
|
||||
PadText = true;
|
||||
}
|
||||
#region Private Variables
|
||||
private string m_Text = "";
|
||||
private bool m_TrailingSpace = false;
|
||||
private bool m_EnablePrefixHandling = true;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void Measure(System.Drawing.Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
#if (FRAMEWORK20)
|
||||
if (BarUtilities.UseTextRenderer)
|
||||
{
|
||||
eTextFormat format = eTextFormat.Default | eTextFormat.NoPadding;
|
||||
if (!d.HotKeyPrefixVisible || m_EnablePrefixHandling)
|
||||
format |= eTextFormat.HidePrefix;
|
||||
Size size = Size.Empty;
|
||||
if (m_TrailingSpace)
|
||||
{
|
||||
if (d.CurrentFont.Italic)
|
||||
{
|
||||
size = Size.Ceiling(TextDrawing.MeasureString(d.Graphics, m_Text, d.CurrentFont, 0, format));
|
||||
size.Width += (int)(d.Graphics.MeasureString("||", d.CurrentFont).Width / 4);
|
||||
}
|
||||
else
|
||||
size = Size.Ceiling(TextDrawing.MeasureString(d.Graphics, m_Text + (BarFunctions.IsVista && m_Text.Length > 0 ? "|" : "||"), d.CurrentFont, 0, format));
|
||||
}
|
||||
else
|
||||
size = Size.Ceiling(TextDrawing.MeasureString(d.Graphics, m_Text, d.CurrentFont, 0, format));
|
||||
if (PadText)
|
||||
{
|
||||
size.Width += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
size.Height += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
}
|
||||
this.Bounds = new Rectangle(Point.Empty, size);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
using (StringFormat format = new StringFormat(StringFormat.GenericTypographic))
|
||||
{
|
||||
format.FormatFlags = StringFormatFlags.NoWrap;
|
||||
if (d.HotKeyPrefixVisible || !m_EnablePrefixHandling)
|
||||
format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
|
||||
else
|
||||
format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Hide;
|
||||
|
||||
if (m_TrailingSpace)
|
||||
{
|
||||
if (d.CurrentFont.Italic)
|
||||
{
|
||||
Size size = Size.Ceiling(d.Graphics.MeasureString(m_Text, d.CurrentFont, 0, format));
|
||||
size.Width += (int)(d.Graphics.MeasureString("|", d.CurrentFont).Width / 4);
|
||||
if (PadText)
|
||||
{
|
||||
size.Width += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
size.Height += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
}
|
||||
this.Bounds = new Rectangle(Point.Empty, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
Size size = Size.Ceiling(d.Graphics.MeasureString(m_Text + "|", d.CurrentFont, 0, format));
|
||||
if (PadText)
|
||||
{
|
||||
size.Width += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
size.Height += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
}
|
||||
this.Bounds = new Rectangle(Point.Empty, size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Size size = Size.Ceiling(d.Graphics.MeasureString(m_Text, d.CurrentFont, 0, format));
|
||||
if (PadText)
|
||||
{
|
||||
size.Width += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
size.Height += BarUtilities.TextMarkupCultureSpecificPadding;
|
||||
}
|
||||
this.Bounds = new Rectangle(Point.Empty, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
IsSizeValid = true;
|
||||
}
|
||||
|
||||
public override void Render(MarkupDrawContext d)
|
||||
{
|
||||
Rectangle r = this.Bounds;
|
||||
r.Offset(d.Offset);
|
||||
|
||||
if (!d.ClipRectangle.IsEmpty && !r.IntersectsWith(d.ClipRectangle))
|
||||
return;
|
||||
|
||||
Graphics g = d.Graphics;
|
||||
#if (FRAMEWORK20)
|
||||
if (BarUtilities.UseTextRenderer)
|
||||
{
|
||||
eTextFormat format = eTextFormat.Default | eTextFormat.NoClipping | eTextFormat.NoPadding;
|
||||
if (d.RightToLeft) format |= eTextFormat.RightToLeft;
|
||||
if (!d.HotKeyPrefixVisible)
|
||||
format |= eTextFormat.HidePrefix;
|
||||
|
||||
if (!d.ClipRectangle.IsEmpty && r.Right > d.ClipRectangle.Right)
|
||||
{
|
||||
format|= eTextFormat.EndEllipsis;
|
||||
r.Width -= (r.Right - d.ClipRectangle.Right);
|
||||
}
|
||||
TextDrawing.DrawString(g, m_Text, d.CurrentFont, d.CurrentForeColor, r, format);
|
||||
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
using (StringFormat format = new StringFormat(StringFormat.GenericTypographic))
|
||||
{
|
||||
format.FormatFlags |= StringFormatFlags.NoWrap;
|
||||
if (d.RightToLeft) format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
|
||||
if (d.HotKeyPrefixVisible)
|
||||
format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
|
||||
else
|
||||
format.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Hide;
|
||||
if (!d.ClipRectangle.IsEmpty && r.Right > d.ClipRectangle.Right)
|
||||
{
|
||||
format.Trimming = StringTrimming.EllipsisCharacter;
|
||||
r.Width -= (r.Right - d.ClipRectangle.Right);
|
||||
}
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(d.CurrentForeColor))
|
||||
g.DrawString(m_Text, d.CurrentFont, brush, r, format);
|
||||
}
|
||||
}
|
||||
|
||||
if (d.StrikeOut == true)
|
||||
{
|
||||
// StrikeOut
|
||||
|
||||
float descent = d.CurrentFont.FontFamily.GetCellDescent(d.CurrentFont.Style) *
|
||||
d.CurrentFont.Size / d.CurrentFont.FontFamily.GetEmHeight(d.CurrentFont.Style) + 1;
|
||||
|
||||
using (Pen pen = new Pen(d.CurrentForeColor, 1))
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
|
||||
float y = r.Top + (r.Height + descent) / 2;
|
||||
|
||||
g.DrawLine(pen, r.X, y, r.Right - 1, y);
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
}
|
||||
|
||||
if ((d.HyperLink && (d.HyperlinkStyle == null || d.HyperlinkStyle.UnderlineStyle != eHyperlinkUnderlineStyle.None)) || d.Underline)
|
||||
{
|
||||
// Underline Hyperlink
|
||||
float descent = d.CurrentFont.FontFamily.GetCellDescent(d.CurrentFont.Style) * d.CurrentFont.Size / d.CurrentFont.FontFamily.GetEmHeight(d.CurrentFont.Style);
|
||||
using (Pen pen = new Pen(d.CurrentForeColor, 1))
|
||||
{
|
||||
if (d.HyperLink && d.HyperlinkStyle != null && d.HyperlinkStyle.UnderlineStyle == eHyperlinkUnderlineStyle.DashedLine)
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||
descent -= 1;
|
||||
System.Drawing.Drawing2D.SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
|
||||
g.DrawLine(pen, r.X, r.Bottom - descent, r.Right - 1, r.Bottom - descent);
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
}
|
||||
|
||||
this.RenderBounds = r;
|
||||
}
|
||||
|
||||
protected override void ArrangeCore(System.Drawing.Rectangle finalRect, MarkupDrawContext d) {}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return m_Text; }
|
||||
set
|
||||
{
|
||||
m_Text = value;
|
||||
this.IsSizeValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TrailingSpace
|
||||
{
|
||||
get { return m_TrailingSpace; }
|
||||
set
|
||||
{
|
||||
m_TrailingSpace = value;
|
||||
this.IsSizeValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EnablePrefixHandling
|
||||
{
|
||||
get { return m_EnablePrefixHandling; }
|
||||
set { m_EnablePrefixHandling = value; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
48
PROMS/DotNetBar Source Code/TextMarkup/Underline.cs
Normal file
48
PROMS/DotNetBar Source Code/TextMarkup/Underline.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
#if AdvTree
|
||||
namespace DevComponents.Tree.TextMarkup
|
||||
#elif DOTNETBAR
|
||||
namespace DevComponents.DotNetBar.TextMarkup
|
||||
#elif SUPERGRID
|
||||
namespace DevComponents.SuperGrid.TextMarkup
|
||||
#elif LAYOUT
|
||||
namespace DevComponents.DotNetBar.Layout.TextMarkup
|
||||
#endif
|
||||
{
|
||||
internal class Underline : FontChangeElement
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override void SetFont(MarkupDrawContext d)
|
||||
{
|
||||
d.Underline = true;
|
||||
//Font font = d.CurrentFont;
|
||||
//FontStyle style = d.CurrentFont.Style | FontStyle.Underline;
|
||||
|
||||
//if (!font.Underline && font.FontFamily.IsStyleAvailable(style))
|
||||
// d.CurrentFont = new Font(font, style);
|
||||
//else
|
||||
// font = null;
|
||||
|
||||
//if (font != null)
|
||||
// m_OldFont = font;
|
||||
|
||||
base.SetFont(d);
|
||||
}
|
||||
|
||||
public override void MeasureEnd(Size availableSize, MarkupDrawContext d)
|
||||
{
|
||||
d.Underline = false;
|
||||
base.MeasureEnd(availableSize, d);
|
||||
}
|
||||
|
||||
public override void RenderEnd(MarkupDrawContext d)
|
||||
{
|
||||
d.Underline = false;
|
||||
base.RenderEnd(d);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user