DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Rendering
|
||||
{
|
||||
internal class MetroStepItemPainter : StepItemPainter
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines color table for the StepItem.
|
||||
/// </summary>
|
||||
public class OfficeStepItemColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the default state StepItem colors.
|
||||
/// </summary>
|
||||
public OfficeStepItemStateColorTable Default = new OfficeStepItemStateColorTable();
|
||||
/// <summary>
|
||||
/// Gets or sets the mouse over state StepItem colors.
|
||||
/// </summary>
|
||||
public OfficeStepItemStateColorTable MouseOver = new OfficeStepItemStateColorTable();
|
||||
/// <summary>
|
||||
/// Gets or sets the StepItem colors when mouse is pressed over the item.
|
||||
/// </summary>
|
||||
public OfficeStepItemStateColorTable Pressed = new OfficeStepItemStateColorTable();
|
||||
/// <summary>
|
||||
/// Gets or sets the StepItem colors when Value property is greater than Minimum property value, i.e. item is reporting progress.
|
||||
/// Note that only Background color is used when progress indicator is drawn.
|
||||
/// </summary>
|
||||
public OfficeStepItemStateColorTable Progress = new OfficeStepItemStateColorTable();
|
||||
}
|
||||
}
|
@@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Rendering
|
||||
{
|
||||
internal class OfficeStepItemPainter : StepItemPainter
|
||||
{
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Paints StepItem.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides arguments for the operation.</param>
|
||||
public override void Paint(StepItemRendererEventArgs e)
|
||||
{
|
||||
StepItem item = e.Item;
|
||||
OfficeStepItemColorTable table = ColorTable.StepItem;
|
||||
OfficeStepItemStateColorTable ct = table.Default;
|
||||
if (item.HotTracking && item.IsMouseDown)
|
||||
ct = table.Pressed;
|
||||
else if (item.HotTracking && item.IsMouseOver)
|
||||
ct = table.MouseOver;
|
||||
|
||||
OfficeStepItemStateColorTable ctProgress = table.Progress;
|
||||
Rectangle clip = Rectangle.Empty;
|
||||
|
||||
Rectangle r = item.Bounds;
|
||||
int pointerSize = item.GetPointerSize();
|
||||
Graphics g = e.ItemPaintArgs.Graphics;
|
||||
GraphicsPath path = GetPath(item, pointerSize);
|
||||
item.ItemPath = path;
|
||||
using (Brush brush = DisplayHelp.CreateBrush(path.GetBounds(), (item.BackColors != null && item.BackColors.Length > 0) ? item.BackColors : ct.BackColors, ct.BackColorsGradientAngle, ct.BackColorsPositions))
|
||||
{
|
||||
g.FillPath(brush, path);
|
||||
}
|
||||
if (item.Value > item.Minimum) // Render progress marker
|
||||
{
|
||||
float percent = Math.Min(1, (item.Value / (float)(item.Maximum - item.Minimum)));
|
||||
if (percent > 0)
|
||||
{
|
||||
clip = item.Bounds;
|
||||
clip.Width = (int)(clip.Width * percent);
|
||||
}
|
||||
if (!clip.IsEmpty)
|
||||
{
|
||||
Region oldClip = g.Clip;
|
||||
g.SetClip(clip, CombineMode.Intersect);
|
||||
using (Brush brush = DisplayHelp.CreateBrush(path.GetBounds(),
|
||||
(item.ProgressColors != null && item.ProgressColors.Length > 0) ? item.ProgressColors : ctProgress.BackColors, ctProgress.BackColorsGradientAngle, ctProgress.BackColorsPositions))
|
||||
{
|
||||
g.FillPath(brush, path);
|
||||
}
|
||||
g.Clip = oldClip;
|
||||
oldClip.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
if (ct.BorderColors.Length > 0)
|
||||
{
|
||||
for (int i = ct.BorderColors.Length - 1; i > 0; i--)
|
||||
{
|
||||
Rectangle rb = item.Bounds;
|
||||
rb.Inflate(-i, -i);
|
||||
using (GraphicsPath borderPath = GetPath(item, pointerSize, rb))
|
||||
{
|
||||
using (Pen pen = new Pen(ct.BorderColors[i]))
|
||||
g.DrawPath(pen, borderPath);
|
||||
}
|
||||
}
|
||||
using (Pen pen = new Pen(ct.BorderColors[0]))
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
|
||||
// Render content
|
||||
r.X += item.Padding.Left;
|
||||
r.Y += item.Padding.Top;
|
||||
r.Width -= item.Padding.Horizontal;
|
||||
r.Height -= item.Padding.Vertical;
|
||||
|
||||
if (!item.IsFirst)
|
||||
{
|
||||
r.X += pointerSize;
|
||||
r.Width -= pointerSize;
|
||||
}
|
||||
|
||||
Color textColor = ct.TextColor;
|
||||
if (!string.IsNullOrEmpty(item.SymbolRealized))
|
||||
{
|
||||
Color symbolColor = item.SymbolColor;
|
||||
if (symbolColor.IsEmpty) symbolColor = textColor;
|
||||
TextDrawing.DrawStringLegacy(g, item.SymbolRealized, Symbols.GetFont(item.SymbolSize, item.SymbolSet), symbolColor, new Rectangle(r.X, r.Y + r.Height / 2, 0, 0), eTextFormat.Default | eTextFormat.VerticalCenter);
|
||||
int imageSize = item.ActualSymbolSize.Width + item.ImageTextSpacing;
|
||||
r.Width -= imageSize;
|
||||
r.X += imageSize;
|
||||
}
|
||||
else if (item.Image != null)
|
||||
{
|
||||
g.DrawImage(item.Image, new Rectangle(r.X, r.Y + (r.Height - item.Image.Height) / 2, item.Image.Width, item.Image.Height));
|
||||
int imageSize = item.Image.Width + item.ImageTextSpacing;
|
||||
r.Width -= imageSize;
|
||||
r.X += imageSize;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(item.Text))
|
||||
{
|
||||
if (!item.TextColor.IsEmpty) textColor = item.TextColor;
|
||||
Font font = e.ItemPaintArgs.Font;
|
||||
if (item.TextMarkupBody == null)
|
||||
{
|
||||
eTextFormat textFormat = eTextFormat.Default | eTextFormat.VerticalCenter;
|
||||
if (item.TextAlignment == eButtonTextAlignment.Center)
|
||||
{
|
||||
textFormat |= eTextFormat.HorizontalCenter;
|
||||
if (!item.IsLast)
|
||||
r.Width -= pointerSize;
|
||||
}
|
||||
else if (item.TextAlignment == eButtonTextAlignment.Right)
|
||||
{
|
||||
textFormat |= eTextFormat.Right;
|
||||
if (!item.IsLast)
|
||||
r.Width -= pointerSize;
|
||||
}
|
||||
TextDrawing.DrawString(g, item.Text, font, textColor, r, textFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
TextMarkup.MarkupDrawContext d = new TextMarkup.MarkupDrawContext(g, font, textColor, e.ItemPaintArgs.RightToLeft);
|
||||
d.HotKeyPrefixVisible = false;
|
||||
d.ContextObject = item;
|
||||
Rectangle mr = new Rectangle(r.X, r.Y + (r.Height - item.TextMarkupBody.Bounds.Height) / 2, item.TextMarkupBody.Bounds.Width, item.TextMarkupBody.Bounds.Height);
|
||||
item.TextMarkupBody.Bounds = mr;
|
||||
item.TextMarkupBody.Render(d);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private GraphicsPath GetPath(StepItem item, int arrowSize)
|
||||
{
|
||||
Rectangle r = item.Bounds;
|
||||
return GetPath(item, arrowSize, r);
|
||||
}
|
||||
|
||||
private GraphicsPath GetPath(StepItem item, int arrowSize, Rectangle r)
|
||||
{
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
if (item.IsFirst)
|
||||
return GetFirstItemPath(r, arrowSize);
|
||||
else if (item.IsLast)
|
||||
return GetLastItemPath(r, arrowSize);
|
||||
else
|
||||
return GetItemPath(r, arrowSize);
|
||||
}
|
||||
private GraphicsPath GetItemPath(Rectangle r, int arrowSize)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLine(r.X, r.Y, r.X + arrowSize, r.Y + r.Height / 2);
|
||||
path.AddLine(r.X + arrowSize, r.Y + r.Height / 2, r.X, r.Bottom);
|
||||
path.AddLine(r.X, r.Bottom, r.Right - arrowSize, r.Bottom);
|
||||
path.AddLine(r.Right - arrowSize, r.Bottom, r.Right, r.Y + r.Height / 2);
|
||||
path.AddLine(r.Right, r.Y + r.Height / 2, r.Right - arrowSize, r.Y);
|
||||
path.CloseAllFigures();
|
||||
|
||||
return path;
|
||||
}
|
||||
private GraphicsPath GetLastItemPath(Rectangle r, int arrowSize)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
ArcData ad = ElementStyleDisplay.GetCornerArc(r, 2, eCornerArc.TopRight);
|
||||
path.AddArc(ad.X, ad.Y, ad.Width, ad.Height, ad.StartAngle, ad.SweepAngle);
|
||||
ad = ElementStyleDisplay.GetCornerArc(r, 2, eCornerArc.BottomRight);
|
||||
path.AddArc(ad.X, ad.Y, ad.Width, ad.Height, ad.StartAngle, ad.SweepAngle);
|
||||
|
||||
path.AddLine(r.X, r.Bottom, r.X + arrowSize, r.Y + r.Height / 2);
|
||||
path.AddLine(r.X + arrowSize, r.Y + r.Height / 2, r.X, r.Y);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
return path;
|
||||
}
|
||||
private GraphicsPath GetFirstItemPath(Rectangle r, int arrowSize)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
ArcData ad = ElementStyleDisplay.GetCornerArc(r, 2, eCornerArc.BottomLeft);
|
||||
path.AddArc(ad.X, ad.Y, ad.Width, ad.Height, ad.StartAngle, ad.SweepAngle);
|
||||
ad = ElementStyleDisplay.GetCornerArc(r, 2, eCornerArc.TopLeft);
|
||||
path.AddArc(ad.X, ad.Y, ad.Width, ad.Height, ad.StartAngle, ad.SweepAngle);
|
||||
path.AddLine(r.Right - arrowSize, r.Y, r.Right, r.Y + r.Height / 2);
|
||||
path.AddLine(r.Right, r.Y + r.Height / 2, r.Right - arrowSize, r.Bottom);
|
||||
path.CloseAllFigures();
|
||||
return path;
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Rendering
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the color table for StepItem single state.
|
||||
/// </summary>
|
||||
public class OfficeStepItemStateColorTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the OfficeStepItemStateColorTable class.
|
||||
/// </summary>
|
||||
public OfficeStepItemStateColorTable()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the OfficeStepItemStateColorTable class.
|
||||
/// </summary>
|
||||
/// <param name="backColors"></param>
|
||||
/// <param name="textColor"></param>
|
||||
/// <param name="borderColors"></param>
|
||||
public OfficeStepItemStateColorTable(Color[] backColors, Color textColor, Color[] borderColors)
|
||||
{
|
||||
BackColors = backColors;
|
||||
TextColor = textColor;
|
||||
BorderColors = borderColors;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the OfficeStepItemStateColorTable class.
|
||||
/// </summary>
|
||||
/// <param name="backColors"></param>
|
||||
/// <param name="backColorsGradientAngle"></param>
|
||||
/// <param name="backColorsPositions"></param>
|
||||
/// <param name="textColor"></param>
|
||||
/// <param name="borderColors"></param>
|
||||
public OfficeStepItemStateColorTable(Color[] backColors, int backColorsGradientAngle, float[] backColorsPositions, Color textColor, Color[] borderColors)
|
||||
{
|
||||
BackColors = backColors;
|
||||
BackColorsGradientAngle = backColorsGradientAngle;
|
||||
BackColorsPositions = backColorsPositions;
|
||||
TextColor = textColor;
|
||||
BorderColors = borderColors;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the background colors for the step item.
|
||||
/// </summary>
|
||||
public Color[] BackColors= new Color[0];
|
||||
/// <summary>
|
||||
/// Gets or sets the back colors gradient angle if there is more than one color in BackColors array.
|
||||
/// </summary>
|
||||
public int BackColorsGradientAngle = 90;
|
||||
/// <summary>
|
||||
/// Gets or sets the gradient colors positions if there is more than one color in BackColors array.
|
||||
/// </summary>
|
||||
public float[] BackColorsPositions = new float[0];
|
||||
/// <summary>
|
||||
/// Gets or sets the text color for the step item.
|
||||
/// </summary>
|
||||
public Color TextColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets the border colors of the step item.
|
||||
/// </summary>
|
||||
public Color[] BorderColors = new Color[0];
|
||||
}
|
||||
}
|
@@ -0,0 +1,304 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the progress steps control.
|
||||
/// </summary>
|
||||
[ToolboxBitmap(typeof(ProgressSteps), "ProgressSteps.ico"), ToolboxItem(true), Designer("DevComponents.DotNetBar.Design.ProgressStepsDesigner, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf"), System.Runtime.InteropServices.ComVisible(false), DefaultEvent("ItemClick")]
|
||||
public class ProgressSteps : ItemControl
|
||||
{
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ProgressSteps class.
|
||||
/// </summary>
|
||||
public ProgressSteps()
|
||||
: base()
|
||||
{
|
||||
_ViewContainer = new StepItemContainer();
|
||||
_ViewContainer.GlobalItem = false;
|
||||
_ViewContainer.ContainerControl = this;
|
||||
_ViewContainer.Displayed = true;
|
||||
_ViewContainer.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
_ViewContainer.SetOwner(this);
|
||||
this.SetBaseItemContainer(_ViewContainer);
|
||||
}
|
||||
private StepItemContainer _ViewContainer = null;
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Returns collection of items on a bar.
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content), Browsable(false)]
|
||||
public SubItemsCollection Items
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ViewContainer.SubItems;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the visual style for items and color scheme.
|
||||
/// </summary>
|
||||
[Browsable(true), DevCoBrowsable(true), Category("Appearance"), Description("Specifies the visual style of the control."), DefaultValue(eDotNetBarStyle.StyleManagerControlled)]
|
||||
public eDotNetBarStyle Style
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ViewContainer.Style;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.ColorScheme.SwitchStyle(value);
|
||||
_ViewContainer.Style = value;
|
||||
this.Invalidate();
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private Size _PreferredSize = Size.Empty;
|
||||
[Localizable(true), Browsable(false)]
|
||||
public new System.Windows.Forms.Padding Padding
|
||||
{
|
||||
get { return base.Padding; }
|
||||
set { base.Padding = value; }
|
||||
}
|
||||
|
||||
public override Size GetPreferredSize(Size proposedSize)
|
||||
{
|
||||
if (!_PreferredSize.IsEmpty) return _PreferredSize;
|
||||
|
||||
if (!BarFunctions.IsHandleValid(this))
|
||||
return base.GetPreferredSize(proposedSize);
|
||||
|
||||
if (this.Items.Count == 0 || !BarFunctions.IsHandleValid(this) || _ViewContainer.SubItems.Count == 0)
|
||||
return new Size(base.GetPreferredSize(proposedSize).Width, Dpi.Height22);
|
||||
|
||||
int height = GetAutoSizePreferredHeight();
|
||||
|
||||
_PreferredSize = new Size(proposedSize.Width, height);
|
||||
return _PreferredSize;
|
||||
}
|
||||
|
||||
private int GetAutoSizePreferredHeight()
|
||||
{
|
||||
int height = ElementStyleLayout.VerticalStyleWhiteSpace(this.GetBackgroundStyle());
|
||||
height += _ViewContainer.CalculatedHeight > 0 ? _ViewContainer.CalculatedHeight : 20;
|
||||
return height;
|
||||
}
|
||||
protected override void RecalcSize()
|
||||
{
|
||||
base.RecalcSize();
|
||||
if (this.AutoSize && this.IsHandleCreated && GetAutoSizePreferredHeight() != this.Height)
|
||||
{
|
||||
InvalidateAutoSize();
|
||||
this.AdjustSize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the control is automatically resized to display its entire contents. You can set MaximumSize.Width property to set the maximum width used by the control.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(false), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
public override bool AutoSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.AutoSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this.AutoSize != value)
|
||||
{
|
||||
base.AutoSize = value;
|
||||
InvalidateAutoSize();
|
||||
AdjustSize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InvalidateAutoSize()
|
||||
{
|
||||
_PreferredSize = Size.Empty;
|
||||
}
|
||||
|
||||
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
|
||||
{
|
||||
if (this.AutoSize)
|
||||
{
|
||||
Size preferredSize = base.PreferredSize;
|
||||
if (preferredSize.Width > 0)
|
||||
width = preferredSize.Width;
|
||||
if (preferredSize.Height > 0)
|
||||
height = preferredSize.Height;
|
||||
}
|
||||
base.SetBoundsCore(x, y, width, height, specified);
|
||||
}
|
||||
|
||||
private void AdjustSize()
|
||||
{
|
||||
if (this.AutoSize)
|
||||
{
|
||||
System.Drawing.Size prefSize = base.PreferredSize;
|
||||
if (prefSize.Width > 0 && prefSize.Height > 0)
|
||||
this.Size = base.PreferredSize;
|
||||
else if (prefSize.Height > 0)
|
||||
this.Size = new Size(this.Width, base.PreferredSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override Image BackgroundImage
|
||||
{
|
||||
get { return base.BackgroundImage; }
|
||||
set { base.BackgroundImage = value; }
|
||||
}
|
||||
|
||||
protected override void OnHandleCreated(EventArgs e)
|
||||
{
|
||||
base.OnHandleCreated(e);
|
||||
if (this.AutoSize)
|
||||
this.AdjustSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the arrow pointer width for the StepItem objects hosted within this container.
|
||||
/// </summary>
|
||||
[DefaultValue(10), Category("Appearance"), Description("Gets or sets the arrow pointer width for the StepItem objects hosted within this container.")]
|
||||
public int PointerSize
|
||||
{
|
||||
get { return _ViewContainer.PointerSize; }
|
||||
set
|
||||
{
|
||||
_ViewContainer.PointerSize = value;
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Property Hiding
|
||||
[Browsable(false)]
|
||||
public override eBarImageSize ImageSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImageSize = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override System.Windows.Forms.ImageList ImagesLarge
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImagesLarge;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImagesLarge = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override System.Windows.Forms.ImageList ImagesMedium
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ImagesMedium;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ImagesMedium = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override Font KeyTipsFont
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.KeyTipsFont;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.KeyTipsFont = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override bool ShowShortcutKeysInToolTips
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ShowShortcutKeysInToolTips;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ShowShortcutKeysInToolTips = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false)]
|
||||
public override bool ThemeAware
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ThemeAware;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ThemeAware = value;
|
||||
}
|
||||
}
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Licensing
|
||||
#if !TRIAL
|
||||
private string m_LicenseKey = "";
|
||||
[Browsable(false), DefaultValue("")]
|
||||
public string LicenseKey
|
||||
{
|
||||
get { return m_LicenseKey; }
|
||||
set
|
||||
{
|
||||
if (NativeFunctions.ValidateLicenseKey(value))
|
||||
return;
|
||||
m_LicenseKey = (!NativeFunctions.CheckLicenseKey(value) ? "9dsjkhds7" : value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
#if !TRIAL
|
||||
if (NativeFunctions.keyValidated2 != 266)
|
||||
TextDrawing.DrawString(e.Graphics, "Invalid License", this.Font, Color.FromArgb(180, Color.Red), this.ClientRectangle, eTextFormat.Bottom | eTextFormat.HorizontalCenter);
|
||||
#else
|
||||
if (NativeFunctions.ColorExpAlt() || !NativeFunctions.CheckedThrough)
|
||||
{
|
||||
e.Graphics.Clear(SystemColors.Control);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
845
PROMS/DotNetBar Source Code/Controls/ProgressStepper/StepItem.cs
Normal file
845
PROMS/DotNetBar Source Code/Controls/ProgressStepper/StepItem.cs
Normal file
@@ -0,0 +1,845 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a step item which is used to show single step in multi-step progress control.
|
||||
/// </summary>
|
||||
[ToolboxItem(false), DefaultEvent("Click")]
|
||||
public class StepItem : BaseItem
|
||||
{
|
||||
#region Constructor, Copy
|
||||
/// <summary>
|
||||
/// Creates new instance of StepItem.
|
||||
/// </summary>
|
||||
public StepItem() : this("", "") { }
|
||||
/// <summary>
|
||||
/// Creates new instance of StepItem and assigns the name to it.
|
||||
/// </summary>
|
||||
/// <param name="sItemName">Item name.</param>
|
||||
public StepItem(string sItemName) : this(sItemName, "") { }
|
||||
/// <summary>
|
||||
/// Creates new instance of StepItem and assigns the name and text to it.
|
||||
/// </summary>
|
||||
/// <param name="sItemName">Item name.</param>
|
||||
/// <param name="ItemText">item text.</param>
|
||||
public StepItem(string sItemName, string ItemText)
|
||||
: base(sItemName, ItemText)
|
||||
{
|
||||
//this.ClickRepeatInterval = 200;
|
||||
this.MouseUpNotification = true;
|
||||
//this.MouseDownCapture = true;
|
||||
_Padding.PropertyChanged += PaddingPropertyChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of the item.
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
StepItem objCopy = new StepItem(m_Name);
|
||||
this.CopyToItem(objCopy);
|
||||
return objCopy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the StepItem specific properties to new instance of the item.
|
||||
/// </summary>
|
||||
/// <param name="copy">New StepItem instance.</param>
|
||||
internal void InternalCopyToItem(StepItem copy)
|
||||
{
|
||||
CopyToItem(copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the StepItem specific properties to new instance of the item.
|
||||
/// </summary>
|
||||
/// <param name="copy">New StepItem instance.</param>
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
StepItem c = copy as StepItem;
|
||||
c.Symbol = _Symbol;
|
||||
c.SymbolSet = _SymbolSet;
|
||||
c.SymbolColor = _SymbolColor;
|
||||
c.SymbolSize = _SymbolSize;
|
||||
|
||||
base.CopyToItem(c);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (_ItemPath != null)
|
||||
{
|
||||
_ItemPath.Dispose();
|
||||
_ItemPath = null;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void Paint(ItemPaintArgs p)
|
||||
{
|
||||
Rendering.BaseRenderer renderer = p.Renderer;
|
||||
if (renderer != null)
|
||||
{
|
||||
StepItemRendererEventArgs e = new StepItemRendererEventArgs(this, p.Graphics);
|
||||
e.ItemPaintArgs = p;
|
||||
renderer.DrawStepItem(e);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rendering.StepItemPainter painter = PainterFactory.CreateStepItemPainter(this);
|
||||
if (painter != null)
|
||||
{
|
||||
StepItemRendererEventArgs e = new StepItemRendererEventArgs(this, p.Graphics);
|
||||
e.ItemPaintArgs = p;
|
||||
painter.Paint(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.DesignMode && this.Focused)
|
||||
{
|
||||
Rectangle r = Rectangle.Round(_ItemPath.GetBounds());
|
||||
r.Inflate(-1, -1);
|
||||
DesignTime.DrawDesignTimeSelection(p.Graphics, r, p.Colors.ItemDesignTimeBorder);
|
||||
}
|
||||
|
||||
this.DrawInsertMarker(p.Graphics);
|
||||
}
|
||||
|
||||
public override void RecalcSize()
|
||||
{
|
||||
Font font = GetFont(null);
|
||||
Size size = Size.Empty;
|
||||
|
||||
Control objCtrl = this.ContainerControl as Control;
|
||||
if (objCtrl == null || objCtrl.Disposing || objCtrl.IsDisposed)
|
||||
return;
|
||||
Graphics g = BarFunctions.CreateGraphics(objCtrl);
|
||||
if (g == null) return;
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_Symbol))
|
||||
{
|
||||
_ActualSymbolSize = GetSymbolSize(g);
|
||||
size = _ActualSymbolSize;
|
||||
}
|
||||
else if (_Image != null)
|
||||
{
|
||||
size = _Image.Size;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.Text))
|
||||
{
|
||||
Size textSize = ButtonItemLayout.MeasureItemText(this, g, 0, objCtrl.Font, eTextFormat.Default, objCtrl.RightToLeft == RightToLeft.Yes);
|
||||
size.Width += textSize.Width;
|
||||
size.Height = Math.Max(size.Height, textSize.Height);
|
||||
if (_Image != null || !string.IsNullOrEmpty(_Symbol))
|
||||
size.Width += Dpi.Width(_ImageTextSpacing);
|
||||
}
|
||||
else if (string.IsNullOrEmpty(_Symbol) && _Image == null)
|
||||
size = new System.Drawing.Size(Dpi.Width16, Dpi.Height16);
|
||||
|
||||
size.Width += GetPointerSize();
|
||||
if(!_IsFirst && !_IsLast)
|
||||
size.Width += Dpi.Width(GetPointerSize());
|
||||
|
||||
size.Width += Dpi.Width(_Padding.Horizontal);
|
||||
size.Height += Dpi.Height(_Padding.Vertical);
|
||||
|
||||
base.RecalcSize();
|
||||
}
|
||||
finally
|
||||
{
|
||||
g.Dispose();
|
||||
}
|
||||
|
||||
if (!_MinimumSize.IsEmpty)
|
||||
{
|
||||
if (size.Width < _MinimumSize.Width) size.Width = _MinimumSize.Width;
|
||||
if (size.Height < _MinimumSize.Height) size.Height = _MinimumSize.Height;
|
||||
}
|
||||
|
||||
m_Rect.Size = size;
|
||||
}
|
||||
|
||||
internal int GetPointerSize()
|
||||
{
|
||||
if (this.Parent is StepItemContainer)
|
||||
return ((StepItemContainer)this.Parent).PointerSize;
|
||||
return 10;
|
||||
}
|
||||
|
||||
private Size GetSymbolSize(Graphics g)
|
||||
{
|
||||
Size symbolSize = Size.Empty;
|
||||
if (g == null || string.IsNullOrEmpty(_Symbol)) return symbolSize;
|
||||
Font symFont = Symbols.GetFont(this.SymbolSize, this.SymbolSet);
|
||||
symbolSize = TextDrawing.MeasureString(g, "\uF00A", symFont); // Need to do this to get consistent size for the symbol since they are not all the same width we pick widest
|
||||
int descent = (int)Math.Ceiling((symFont.FontFamily.GetCellDescent(symFont.Style) *
|
||||
symFont.Size / symFont.FontFamily.GetEmHeight(symFont.Style)));
|
||||
symbolSize.Height -= descent;
|
||||
return symbolSize;
|
||||
}
|
||||
|
||||
private Size _ActualSymbolSize = Size.Empty;
|
||||
internal Size ActualSymbolSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ActualSymbolSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the Font object to be used for drawing the item text.
|
||||
/// </summary>
|
||||
/// <returns>Font object.</returns>
|
||||
private Font GetFont(ItemPaintArgs pa)
|
||||
{
|
||||
System.Drawing.Font font = null;
|
||||
|
||||
if (pa != null)
|
||||
font = pa.Font;
|
||||
|
||||
if (font == null)
|
||||
{
|
||||
System.Windows.Forms.Control objCtrl = null;
|
||||
if (pa != null)
|
||||
objCtrl = pa.ContainerControl;
|
||||
if (objCtrl == null)
|
||||
objCtrl = this.ContainerControl as System.Windows.Forms.Control;
|
||||
if (objCtrl != null && objCtrl.Font != null)
|
||||
font = (Font)objCtrl.Font;
|
||||
else
|
||||
font = SystemFonts.DefaultFont; // (Font)System.Windows.Forms.SystemInformation.MenuFont;
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
private GraphicsPath _ItemPath = null;
|
||||
/// <summary>
|
||||
/// Gets the render path of the item.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public GraphicsPath ItemPath
|
||||
{
|
||||
get { return _ItemPath; }
|
||||
internal set
|
||||
{
|
||||
if (_ItemPath != null)
|
||||
_ItemPath.Dispose();
|
||||
_ItemPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsFirst;
|
||||
private int _Minimum = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value of the range of the control.
|
||||
/// </summary>
|
||||
[Browsable(true), Description("Gets or sets the minimum value of the range of the control."), Category("Behavior"), DefaultValue(0)]
|
||||
public int Minimum
|
||||
{
|
||||
get { return _Minimum; }
|
||||
set
|
||||
{
|
||||
if (value != _Minimum)
|
||||
{
|
||||
int oldValue = _Minimum;
|
||||
_Minimum = value;
|
||||
OnMinimumChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when Minimum property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnMinimumChanged(int oldValue, int newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("Minimum"));
|
||||
this.OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private int _Maximum = 100;
|
||||
[Browsable(true), Description("Gets or sets the maximum value of the range of the control."), Category("Behavior"), DefaultValue(100)]
|
||||
public int Maximum
|
||||
{
|
||||
get { return _Maximum; }
|
||||
set
|
||||
{
|
||||
if (value != _Maximum)
|
||||
{
|
||||
int oldValue = _Maximum;
|
||||
_Maximum = value;
|
||||
OnMaximumChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when Maximum property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnMaximumChanged(int oldValue, int newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("Maximum"));
|
||||
this.OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private int _Value = 0;
|
||||
[Browsable(true), Description("Gets or sets the current position of the progress bar."), Category("Behavior"), DefaultValue(0)]
|
||||
public int Value
|
||||
{
|
||||
get { return _Value; }
|
||||
set
|
||||
{
|
||||
if (value != _Value)
|
||||
{
|
||||
int oldValue = _Value;
|
||||
_Value = value;
|
||||
OnValueChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when Value property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnValueChanged(int oldValue, int newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("Value"));
|
||||
this.OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private Color _SymbolColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the Symbol.
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates color of the Symbol.")]
|
||||
public Color SymbolColor
|
||||
{
|
||||
get { return _SymbolColor; }
|
||||
set { _SymbolColor = value; this.Refresh(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeSymbolColor()
|
||||
{
|
||||
return !_SymbolColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetSymbolColor()
|
||||
{
|
||||
this.SymbolColor = Color.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the realized symbol string.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public string SymbolRealized
|
||||
{
|
||||
get { return _SymbolRealized; }
|
||||
}
|
||||
private string _Symbol = "", _SymbolRealized = "";
|
||||
/// <summary>
|
||||
/// Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.
|
||||
/// </summary>
|
||||
[DefaultValue(""), Category("Appearance"), Description("Indicates the symbol displayed on face of the button instead of the image. Setting the symbol overrides the image setting.")]
|
||||
[Editor("DevComponents.DotNetBar.Design.SymbolTypeEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public string Symbol
|
||||
{
|
||||
get { return _Symbol; }
|
||||
set
|
||||
{
|
||||
if (value != _Symbol)
|
||||
{
|
||||
string oldValue = _Symbol;
|
||||
_Symbol = value;
|
||||
OnSymbolChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when Symbol property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnSymbolChanged(string oldValue, string newValue)
|
||||
{
|
||||
if (string.IsNullOrEmpty(newValue))
|
||||
_SymbolRealized = "";
|
||||
else
|
||||
_SymbolRealized = Symbols.GetSymbol(newValue);
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("Symbol"));
|
||||
NeedRecalcSize = true;
|
||||
OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private eSymbolSet _SymbolSet = eSymbolSet.Awesome;
|
||||
/// <summary>
|
||||
/// Gets or sets the symbol set used to represent the Symbol.
|
||||
/// </summary>
|
||||
[Browsable(false), DefaultValue(eSymbolSet.Awesome)]
|
||||
public eSymbolSet SymbolSet
|
||||
{
|
||||
get { return _SymbolSet; }
|
||||
set
|
||||
{
|
||||
if (_SymbolSet != value)
|
||||
{
|
||||
eSymbolSet oldValue = _SymbolSet;
|
||||
_SymbolSet = value;
|
||||
OnSymbolSetChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when SymbolSet property value changes.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Indciates old value</param>
|
||||
/// <param name="newValue">Indicates new value</param>
|
||||
protected virtual void OnSymbolSetChanged(eSymbolSet oldValue, eSymbolSet newValue)
|
||||
{
|
||||
NeedRecalcSize = true;
|
||||
OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private float _SymbolSize = 13f;
|
||||
/// <summary>
|
||||
/// Indicates the size of the symbol in points.
|
||||
/// </summary>
|
||||
[DefaultValue(12f), Category("Appearance"), Description("Indicates the size of the symbol in points.")]
|
||||
public float SymbolSize
|
||||
{
|
||||
get { return _SymbolSize; }
|
||||
set
|
||||
{
|
||||
if (value != _SymbolSize)
|
||||
{
|
||||
float oldValue = _SymbolSize;
|
||||
_SymbolSize = value;
|
||||
OnSymbolSizeChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when SymbolSize property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnSymbolSizeChanged(float oldValue, float newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("SymbolSize"));
|
||||
NeedRecalcSize = true;
|
||||
OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private Image _Image = null;
|
||||
/// <summary>
|
||||
/// Indicates the image that is displayed next to the item text label.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Description("Indicates the image that is displayed next to the item text label.")]
|
||||
public Image Image
|
||||
{
|
||||
get { return _Image; }
|
||||
set
|
||||
{
|
||||
if (value != _Image)
|
||||
{
|
||||
Image oldValue = _Image;
|
||||
_Image = value;
|
||||
OnImageChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when Image property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnImageChanged(Image oldValue, Image newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("Image"));
|
||||
NeedRecalcSize = true;
|
||||
OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether this is first item in StepControl.
|
||||
/// </summary>
|
||||
internal bool IsFirst
|
||||
{
|
||||
get { return _IsFirst; }
|
||||
set
|
||||
{
|
||||
_IsFirst = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsLast = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether this is laste item in StepControl.
|
||||
/// </summary>
|
||||
internal bool IsLast
|
||||
{
|
||||
get { return _IsLast; }
|
||||
set
|
||||
{
|
||||
_IsLast = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Size _MinimumSize = Size.Empty;
|
||||
/// <summary>
|
||||
/// Indicates minimum size of the item
|
||||
/// </summary>
|
||||
[Category("Appearance"), Description("Indicates minimum size of the item")]
|
||||
public Size MinimumSize
|
||||
{
|
||||
get { return _MinimumSize; }
|
||||
set
|
||||
{
|
||||
if (value != _MinimumSize)
|
||||
{
|
||||
Size oldValue = _MinimumSize;
|
||||
_MinimumSize = value;
|
||||
OnMinimumSizeChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when MinimumSize property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnMinimumSizeChanged(Size oldValue, Size newValue)
|
||||
{
|
||||
// OnPropertyChanged(new PropertyChangedEventArgs("MinimumSize"));
|
||||
NeedRecalcSize = true;
|
||||
OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeMinimumSize()
|
||||
{
|
||||
return !_MinimumSize.IsEmpty;
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetMinimumSize()
|
||||
{
|
||||
this.Size = Size.Empty;
|
||||
}
|
||||
|
||||
private bool _HotTracking = true;
|
||||
/// <summary>
|
||||
/// Specifies whether item changes its appearance when mouse is moved over the item
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Behavior"), Description("Specifies whether item changes its appearance when mouse is moved over the item")]
|
||||
public bool HotTracking
|
||||
{
|
||||
get { return _HotTracking; }
|
||||
set
|
||||
{
|
||||
if (value != _HotTracking)
|
||||
{
|
||||
bool oldValue = _HotTracking;
|
||||
_HotTracking = value;
|
||||
OnHotTrackingChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when HotTracking property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnHotTrackingChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("HotTracking"));
|
||||
}
|
||||
|
||||
private bool _MouseOver = false, _MouseDown = false;
|
||||
public override void InternalMouseEnter()
|
||||
{
|
||||
base.InternalMouseEnter();
|
||||
if (!this.DesignMode)
|
||||
{
|
||||
_MouseOver = true;
|
||||
if (this.GetEnabled() && _HotTracking)
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void InternalMouseLeave()
|
||||
{
|
||||
base.InternalMouseLeave();
|
||||
if (!this.DesignMode)
|
||||
{
|
||||
_MouseOver = false;
|
||||
_MouseDown = false;
|
||||
if (this.GetEnabled() && _HotTracking)
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void InternalMouseDown(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseDown(objArg);
|
||||
if (objArg.Button == MouseButtons.Left && !this.DesignMode)
|
||||
{
|
||||
_MouseDown = true;
|
||||
if (this.GetEnabled() && _HotTracking)
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public override void InternalMouseUp(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseUp(objArg);
|
||||
|
||||
if (_MouseDown && !this.DesignMode)
|
||||
{
|
||||
_MouseDown = false;
|
||||
if (this.GetEnabled() && _HotTracking)
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether mouse is over the item.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool IsMouseOver
|
||||
{
|
||||
get { return _MouseOver; }
|
||||
internal set { _MouseOver = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether left mouse button is pressed on the item.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool IsMouseDown
|
||||
{
|
||||
get { return _MouseDown; }
|
||||
internal set { _MouseDown = value; }
|
||||
}
|
||||
|
||||
|
||||
private int _ImageTextSpacing = 4;
|
||||
/// <summary>
|
||||
/// Indicates the spacing between image and text.
|
||||
/// </summary>
|
||||
[DefaultValue(4), Category("Appearance"), Description("Indicates the spacing between image and text.")]
|
||||
public int ImageTextSpacing
|
||||
{
|
||||
get { return _ImageTextSpacing; }
|
||||
set
|
||||
{
|
||||
if (value != _ImageTextSpacing)
|
||||
{
|
||||
int oldValue = _ImageTextSpacing;
|
||||
_ImageTextSpacing = value;
|
||||
OnImageTextSpacingChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when ImageTextSpacing property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnImageTextSpacingChanged(int oldValue, int newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("ImageTextSpacing"));
|
||||
NeedRecalcSize = true;
|
||||
OnAppearanceChanged();
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private const int DefaultPadding = 4;
|
||||
private Padding _Padding = new Padding(DefaultPadding);
|
||||
/// <summary>
|
||||
/// Gets or sets padding around content of the item.
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), Description("Gets or sets padding around content of the item."), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public Padding Padding
|
||||
{
|
||||
get { return _Padding; }
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializePadding()
|
||||
{
|
||||
return _Padding.Bottom != DefaultPadding || _Padding.Top != DefaultPadding || _Padding.Left != DefaultPadding || _Padding.Right != DefaultPadding;
|
||||
}
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetPadding()
|
||||
{
|
||||
_Padding.All = DefaultPadding;
|
||||
}
|
||||
private void PaddingPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
NeedRecalcSize = true;
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private Color[] _ProgressColors = null;
|
||||
/// <summary>
|
||||
/// Indicates the array of colors that when set are used to draw the current progress, i.e. Value>Minimum
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Description("Indicates the array of colors that when set are used to draw the current progress, i.e. Value>Minimum"), TypeConverter(typeof(ArrayConverter))]
|
||||
public Color[] ProgressColors
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ProgressColors;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_ProgressColors != value)
|
||||
{
|
||||
_ProgressColors = value;
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("Colors"));
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color[] _BackColors = null;
|
||||
/// <summary>
|
||||
/// Indicates the array of colors that when set are used to draw the background of the item.
|
||||
/// </summary>
|
||||
[DefaultValue(null), Category("Appearance"), Description("Indicates the array of colors that when set are used to draw the background of the item."), TypeConverter(typeof(ArrayConverter))]
|
||||
public Color[] BackColors
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BackColors;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_BackColors != value)
|
||||
{
|
||||
_BackColors = value;
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("Colors"));
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private eButtonTextAlignment _TextAlignment = eButtonTextAlignment.Left;
|
||||
/// <summary>
|
||||
/// Gets or sets the text alignment. Default value is left.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(eButtonTextAlignment.Left), Category("Appearance"), Description("Indicates text alignment.")]
|
||||
public eButtonTextAlignment TextAlignment
|
||||
{
|
||||
get { return _TextAlignment; }
|
||||
set
|
||||
{
|
||||
_TextAlignment = value;
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text associated with this item.
|
||||
/// </summary>
|
||||
[System.ComponentModel.Browsable(true), DevCoBrowsable(true), Editor("DevComponents.DotNetBar.Design.TextMarkupUIEditor, DevComponents.DotNetBar.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=90f470f34c89ccaf", typeof(System.Drawing.Design.UITypeEditor)), System.ComponentModel.Category("Appearance"), System.ComponentModel.Description("The text contained in the item."), System.ComponentModel.Localizable(true), System.ComponentModel.DefaultValue("")]
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Color _TextColor = Color.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the text.
|
||||
/// </summary>
|
||||
[Category("Columns"), Description("Indicates color of text.")]
|
||||
public Color TextColor
|
||||
{
|
||||
get { return _TextColor; }
|
||||
set { _TextColor = value; this.Refresh(); }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets whether property should be serialized.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeTextColor()
|
||||
{
|
||||
return !_TextColor.IsEmpty;
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets property to its default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetTextColor()
|
||||
{
|
||||
this.TextColor = Color.Empty;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Markup Implementation
|
||||
/// <summary>
|
||||
/// Gets whether item supports text markup. Default is false.
|
||||
/// </summary>
|
||||
protected override bool IsMarkupSupported
|
||||
{
|
||||
get { return _EnableMarkup; }
|
||||
}
|
||||
|
||||
private bool _EnableMarkup = true;
|
||||
/// <summary>
|
||||
/// Gets or sets whether text-markup support is enabled for items Text property. Default value is true.
|
||||
/// Set this property to false to display HTML or other markup in the item instead of it being parsed as text-markup.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance"), Description("Indicates whether text-markup support is enabled for items Text property.")]
|
||||
public bool EnableMarkup
|
||||
{
|
||||
get { return _EnableMarkup; }
|
||||
set
|
||||
{
|
||||
if (_EnableMarkup != value)
|
||||
{
|
||||
_EnableMarkup = value;
|
||||
NeedRecalcSize = true;
|
||||
OnTextChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,221 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Container for the StepItem objects.
|
||||
/// </summary>
|
||||
public class StepItemContainer : ImageItem, IDesignTimeProvider
|
||||
{
|
||||
#region Implementation
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the StepContainer class.
|
||||
/// </summary>
|
||||
public StepItemContainer()
|
||||
{
|
||||
m_IsContainer = true;
|
||||
this.AutoCollapseOnClick = true;
|
||||
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Grouping;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns copy of the item.
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
StepItemContainer objCopy = new StepItemContainer();
|
||||
objCopy.Name = this.Name;
|
||||
this.CopyToItem(objCopy);
|
||||
return objCopy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the StepContainer specific properties to new instance of the item.
|
||||
/// </summary>
|
||||
/// <param name="copy">New StepContainer instance.</param>
|
||||
internal void InternalCopyToItem(StepItemContainer copy)
|
||||
{
|
||||
CopyToItem(copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the StepContainer specific properties to new instance of the item.
|
||||
/// </summary>
|
||||
/// <param name="copy">New StepContainer instance.</param>
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
StepItemContainer c = copy as StepItemContainer;
|
||||
base.CopyToItem(c);
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override void RecalcSize()
|
||||
{
|
||||
bool first = true;
|
||||
Point loc = this.Bounds.Location;
|
||||
Size totalSize = Size.Empty;
|
||||
bool uniformHeight = true;
|
||||
SubItemsCollection subItems = this.SubItems;
|
||||
bool last = true;
|
||||
int startIndex = subItems.Count - 1;
|
||||
for (int i = startIndex; i >= 0; i--)
|
||||
{
|
||||
StepItem item = subItems[i] as StepItem;
|
||||
if (item != null && item.Visible)
|
||||
{
|
||||
item.IsLast = last;
|
||||
last = false;
|
||||
}
|
||||
}
|
||||
foreach (BaseItem item in subItems)
|
||||
{
|
||||
item.DesignMarkerOrientation = eDesignMarkerOrientation.Horizontal;
|
||||
StepItem si = item as StepItem;
|
||||
if (!item.Visible)
|
||||
{
|
||||
item.Displayed = false;
|
||||
if (si != null)
|
||||
{
|
||||
si.IsLast = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
item.Displayed = true;
|
||||
if (si != null)
|
||||
{
|
||||
si.IsFirst = first;
|
||||
first = false;
|
||||
si.RecalcSize();
|
||||
si.SetDisplayRectangle(new Rectangle(loc, si.Size));
|
||||
int stepWidth = (si.Size.Width - _PointerSize - 1); // 1 is so right hand line overlaps
|
||||
loc.X += stepWidth;
|
||||
totalSize.Width += stepWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
first = true;
|
||||
item.RecalcSize();
|
||||
item.SetDisplayRectangle(new Rectangle(loc, item.Size));
|
||||
loc.X += item.WidthInternal;
|
||||
totalSize.Width += item.WidthInternal;
|
||||
}
|
||||
if (uniformHeight && totalSize.Height > 0 && totalSize.Height != item.HeightInternal)
|
||||
uniformHeight = false;
|
||||
totalSize.Height = Math.Max(totalSize.Height, item.HeightInternal);
|
||||
}
|
||||
totalSize.Width += _PointerSize;
|
||||
|
||||
// Vertically center items if they are all not of same height
|
||||
if (!uniformHeight)
|
||||
{
|
||||
foreach (BaseItem item in subItems)
|
||||
{
|
||||
if (!item.Visible)
|
||||
continue;
|
||||
if (item.HeightInternal < totalSize.Height)
|
||||
item.TopInternal = (totalSize.Height - item.HeightInternal) / 2;
|
||||
}
|
||||
}
|
||||
m_Rect.Size = totalSize;
|
||||
_CalculatedHeight = totalSize.Height;
|
||||
_CalculatedWidth = totalSize.Width;
|
||||
base.RecalcSize();
|
||||
}
|
||||
|
||||
public override void Paint(ItemPaintArgs p)
|
||||
{
|
||||
ItemDisplay display = GetItemDisplay();
|
||||
display.Paint(this, p);
|
||||
}
|
||||
|
||||
private ItemDisplay m_ItemDisplay = null;
|
||||
internal ItemDisplay GetItemDisplay()
|
||||
{
|
||||
if (m_ItemDisplay == null)
|
||||
{
|
||||
m_ItemDisplay = new ItemDisplay();
|
||||
}
|
||||
return m_ItemDisplay;
|
||||
}
|
||||
|
||||
private int _PointerSize = 10;
|
||||
/// <summary>
|
||||
/// Gets or sets the arrow pointer width for the StepItem objects hosted within this container.
|
||||
/// </summary>
|
||||
[DefaultValue(10), Category("Appearance"), Description("Gets or sets the arrow pointer width for the StepItem objects hosted within this container.")]
|
||||
public int PointerSize
|
||||
{
|
||||
get { return _PointerSize; }
|
||||
set
|
||||
{
|
||||
if (value != _PointerSize)
|
||||
{
|
||||
int oldValue = _PointerSize;
|
||||
_PointerSize = value;
|
||||
OnPointerSizeChanged(oldValue, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Called when PointerSize property has changed.
|
||||
/// </summary>
|
||||
/// <param name="oldValue">Old property value</param>
|
||||
/// <param name="newValue">New property value</param>
|
||||
protected virtual void OnPointerSizeChanged(int oldValue, int newValue)
|
||||
{
|
||||
//OnPropertyChanged(new PropertyChangedEventArgs("PointerSize"));
|
||||
|
||||
}
|
||||
|
||||
private int _CalculatedWidth;
|
||||
internal int CalculatedWidth
|
||||
{
|
||||
get { return _CalculatedWidth; }
|
||||
set
|
||||
{
|
||||
_CalculatedWidth = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int _CalculatedHeight;
|
||||
internal int CalculatedHeight
|
||||
{
|
||||
get { return _CalculatedHeight; }
|
||||
set
|
||||
{
|
||||
_CalculatedHeight = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDesignTimeProvider Implementation
|
||||
protected virtual InsertPosition GetContainerInsertPosition(Point pScreen, BaseItem dragItem)
|
||||
{
|
||||
return DesignTimeProviderContainer.GetInsertPosition(this, pScreen, dragItem);
|
||||
}
|
||||
InsertPosition IDesignTimeProvider.GetInsertPosition(Point pScreen, BaseItem dragItem)
|
||||
{
|
||||
return GetContainerInsertPosition(pScreen, dragItem);
|
||||
}
|
||||
void IDesignTimeProvider.DrawReversibleMarker(int iPos, bool Before)
|
||||
{
|
||||
DesignTimeProviderContainer.DrawReversibleMarker(this, iPos, Before);
|
||||
}
|
||||
void IDesignTimeProvider.InsertItemAt(BaseItem objItem, int iPos, bool Before)
|
||||
{
|
||||
DesignTimeProviderContainer.InsertItemAt(this, objItem, iPos, Before);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Rendering
|
||||
{
|
||||
internal class StepItemPainter: IOffice2007Painter
|
||||
{
|
||||
/// <summary>
|
||||
/// Paints StepItem.
|
||||
/// </summary>
|
||||
/// <param name="e">Provides arguments for the operation.</param>
|
||||
public virtual void Paint(StepItemRendererEventArgs e) { }
|
||||
|
||||
#region IOffice2007Painter Members
|
||||
private Office2007ColorTable _ColorTable = null; //new Office2007ColorTable();
|
||||
public Office2007ColorTable ColorTable
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ColorTable;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ColorTable = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for the Slider item rendering events.
|
||||
/// </summary>
|
||||
public class StepItemRendererEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the reference to the item being rendered.
|
||||
/// </summary>
|
||||
public StepItem Item = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the reference to graphics object.
|
||||
/// </summary>
|
||||
public Graphics Graphics = null;
|
||||
|
||||
internal ItemPaintArgs ItemPaintArgs = null;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object and initializes it with default values.
|
||||
/// </summary>
|
||||
/// <param name="overflowItem">Reference to the Slider item being rendered.</param>
|
||||
/// <param name="g">Reference to the graphics object.</param>
|
||||
public StepItemRendererEventArgs(StepItem item, Graphics g)
|
||||
{
|
||||
this.Item = item;
|
||||
this.Graphics = g;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user