DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,430 @@
|
||||
#if FRAMEWORK20
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
public class SuperTabCloseBox : BaseItem
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private SuperTabControlBox _ControlBox;
|
||||
private Size _ItemSize = new Size(16, 16);
|
||||
|
||||
private bool _IsMouseOver;
|
||||
private bool _IsMouseDown;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="controlBox">Associated SuperTabControlBox</param>
|
||||
public SuperTabCloseBox(SuperTabControlBox controlBox)
|
||||
{
|
||||
_ControlBox = controlBox;
|
||||
|
||||
Visible = false;
|
||||
}
|
||||
|
||||
#region Public override designer hiding
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool BeginGroup
|
||||
{
|
||||
get { return base.BeginGroup; }
|
||||
set { base.BeginGroup = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool AutoCollapseOnClick
|
||||
{
|
||||
get { return base.AutoCollapseOnClick; }
|
||||
set { base.AutoCollapseOnClick = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool CanCustomize
|
||||
{
|
||||
get { return base.CanCustomize; }
|
||||
set { base.CanCustomize = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Category
|
||||
{
|
||||
get { return base.Category; }
|
||||
set { base.Category = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ClickAutoRepeat
|
||||
{
|
||||
get { return base.ClickAutoRepeat; }
|
||||
set { base.ClickAutoRepeat = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override int ClickRepeatInterval
|
||||
{
|
||||
get { return base.ClickRepeatInterval; }
|
||||
set { base.ClickRepeatInterval = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override Cursor Cursor
|
||||
{
|
||||
get { return base.Cursor; }
|
||||
set { base.Cursor = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool Enabled
|
||||
{
|
||||
get { return base.Enabled; }
|
||||
set { base.Enabled = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool Stretch
|
||||
{
|
||||
get { return base.Stretch; }
|
||||
set { base.Stretch = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set { base.Text = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ThemeAware
|
||||
{
|
||||
get { return base.ThemeAware; }
|
||||
set { base.ThemeAware = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Tooltip
|
||||
{
|
||||
get { return base.Tooltip; }
|
||||
set { base.Tooltip = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override eItemAlignment ItemAlignment
|
||||
{
|
||||
get { return base.ItemAlignment; }
|
||||
set { base.ItemAlignment = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string KeyTips
|
||||
{
|
||||
get { return base.KeyTips; }
|
||||
set { base.KeyTips = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override ShortcutsCollection Shortcuts
|
||||
{
|
||||
get { return base.Shortcuts; }
|
||||
set { base.Shortcuts = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Description
|
||||
{
|
||||
get { return base.Description; }
|
||||
set { base.Description = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool GlobalItem
|
||||
{
|
||||
get { return base.GlobalItem; }
|
||||
set { base.GlobalItem = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ShowSubItems
|
||||
{
|
||||
get { return base.ShowSubItems; }
|
||||
set { base.ShowSubItems = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string GlobalName
|
||||
{
|
||||
get { return base.GlobalName; }
|
||||
set { base.GlobalName = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override Command Command
|
||||
{
|
||||
get { return base.Command; }
|
||||
set { base.Command = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override object CommandParameter
|
||||
{
|
||||
get { return base.CommandParameter; }
|
||||
set { base.CommandParameter = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Visible
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the CloseBox Visible state
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(false), Category("Behavior")]
|
||||
[Description("Indicates CloseBox Visible state.")]
|
||||
public override bool Visible
|
||||
{
|
||||
get { return base.Visible; }
|
||||
|
||||
set
|
||||
{
|
||||
if (base.Visible != value)
|
||||
{
|
||||
base.Visible = value;
|
||||
|
||||
MyRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsMouseDown
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the mouse is down
|
||||
/// </summary>
|
||||
internal bool IsMouseDown
|
||||
{
|
||||
get { return (_IsMouseDown); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsMouseOver
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the mouse is over the CloseBox
|
||||
/// </summary>
|
||||
internal bool IsMouseOver
|
||||
{
|
||||
get { return (_IsMouseOver); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcSize
|
||||
|
||||
/// <summary>
|
||||
/// Performs RecalcSize processing
|
||||
/// </summary>
|
||||
public override void RecalcSize()
|
||||
{
|
||||
base.RecalcSize();
|
||||
|
||||
WidthInternal = _ItemSize.Width;
|
||||
HeightInternal = _ItemSize.Height;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MyRefresh
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the CloseBox
|
||||
/// </summary>
|
||||
private void MyRefresh()
|
||||
{
|
||||
if (_ControlBox.TabDisplay != null)
|
||||
{
|
||||
SuperTabStripItem tsi = _ControlBox.TabDisplay.TabStripItem;
|
||||
|
||||
if (tsi != null)
|
||||
{
|
||||
_ControlBox.NeedRecalcSize = true;
|
||||
_ControlBox.RecalcSize();
|
||||
|
||||
tsi.NeedRecalcSize = true;
|
||||
tsi.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint
|
||||
|
||||
/// <summary>
|
||||
/// Performs control Paint processing
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public override void Paint(ItemPaintArgs p)
|
||||
{
|
||||
Graphics g = p.Graphics;
|
||||
|
||||
using (SuperTabColorTable sct = _ControlBox.TabDisplay.GetColorTable())
|
||||
{
|
||||
|
||||
Color imageColor = sct.ControlBoxDefault.Image;
|
||||
|
||||
if (_IsMouseOver == true)
|
||||
{
|
||||
Rectangle r = Bounds;
|
||||
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
|
||||
if (_IsMouseDown == true && _IsMouseOver == true)
|
||||
{
|
||||
imageColor = sct.ControlBoxPressed.Image;
|
||||
|
||||
using (Brush br = new SolidBrush(sct.ControlBoxPressed.Background))
|
||||
g.FillRectangle(br, r);
|
||||
|
||||
using (Pen pen = new Pen(sct.ControlBoxPressed.Border))
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageColor = sct.ControlBoxMouseOver.Image;
|
||||
|
||||
using (Brush br = new SolidBrush(sct.ControlBoxMouseOver.Background))
|
||||
g.FillRectangle(br, r);
|
||||
|
||||
using (Pen pen = new Pen(sct.ControlBoxMouseOver.Border))
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
|
||||
g.DrawImageUnscaled(
|
||||
_ControlBox.TabDisplay.GetCloseButton(g, imageColor), Bounds);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse support
|
||||
|
||||
#region InternalMouseEnter
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseEnter
|
||||
/// </summary>
|
||||
public override void InternalMouseEnter()
|
||||
{
|
||||
base.InternalMouseEnter();
|
||||
|
||||
_IsMouseOver = true;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseLeave
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseLeave
|
||||
/// </summary>
|
||||
public override void InternalMouseLeave()
|
||||
{
|
||||
base.InternalMouseLeave();
|
||||
|
||||
_IsMouseOver = false;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseDown
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseDown
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
public override void InternalMouseDown(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseDown(objArg);
|
||||
|
||||
if (DesignMode == false && objArg.Button == MouseButtons.Left)
|
||||
_IsMouseDown = true;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseUp
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseUp
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
public override void InternalMouseUp(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseUp(objArg);
|
||||
|
||||
_IsMouseDown = false;
|
||||
|
||||
if (_IsMouseOver == true)
|
||||
{
|
||||
SuperTabItem tab = _ControlBox.TabDisplay.SelectedTab;
|
||||
|
||||
if (tab != null)
|
||||
tab.Close();
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy object support
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of the item
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
SuperTabCloseBox objCopy = new SuperTabCloseBox(_ControlBox);
|
||||
CopyToItem(objCopy);
|
||||
|
||||
return (objCopy);
|
||||
}
|
||||
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
SuperTabCloseBox objCopy = copy as SuperTabCloseBox;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,666 @@
|
||||
#if FRAMEWORK20
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
public class SuperTabControlBox : BaseItem
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private SuperTabStripItem _TabStripItem;
|
||||
|
||||
private SuperTabCloseBox _CloseBox;
|
||||
private SuperTabMenuBox _MenuBox;
|
||||
|
||||
private BaseItem _HotItem;
|
||||
private BaseItem _MouseDownItem;
|
||||
|
||||
private bool _IsMouseOver;
|
||||
private bool _IsMouseDown;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="tabStripItem">Associated SuperTabStripItem</param>
|
||||
public SuperTabControlBox(SuperTabStripItem tabStripItem)
|
||||
{
|
||||
_TabStripItem = tabStripItem;
|
||||
|
||||
MouseDownCapture = true;
|
||||
MouseUpNotification = true;
|
||||
|
||||
Style = eDotNetBarStyle.Office2007;
|
||||
|
||||
_MenuBox = new SuperTabMenuBox(this);
|
||||
_CloseBox = new SuperTabCloseBox(this);
|
||||
|
||||
_MenuBox.Visible = true;
|
||||
_CloseBox.Visible = false;
|
||||
|
||||
SetParent(tabStripItem);
|
||||
SetIsContainer(true);
|
||||
|
||||
SubItems.Add(_MenuBox);
|
||||
SubItems.Add(_CloseBox);
|
||||
}
|
||||
|
||||
#region Public override designer hiding
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool BeginGroup
|
||||
{
|
||||
get { return base.BeginGroup; }
|
||||
set { base.BeginGroup = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool AutoCollapseOnClick
|
||||
{
|
||||
get { return base.AutoCollapseOnClick; }
|
||||
set { base.AutoCollapseOnClick = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool CanCustomize
|
||||
{
|
||||
get { return base.CanCustomize; }
|
||||
set { base.CanCustomize = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Category
|
||||
{
|
||||
get { return base.Category; }
|
||||
set { base.Category = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ClickAutoRepeat
|
||||
{
|
||||
get { return base.ClickAutoRepeat; }
|
||||
set { base.ClickAutoRepeat = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override int ClickRepeatInterval
|
||||
{
|
||||
get { return base.ClickRepeatInterval; }
|
||||
set { base.ClickRepeatInterval = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override Cursor Cursor
|
||||
{
|
||||
get { return base.Cursor; }
|
||||
set { base.Cursor = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool Enabled
|
||||
{
|
||||
get { return base.Enabled; }
|
||||
set { base.Enabled = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool Stretch
|
||||
{
|
||||
get { return base.Stretch; }
|
||||
set { base.Stretch = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set { base.Text = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ThemeAware
|
||||
{
|
||||
get { return base.ThemeAware; }
|
||||
set { base.ThemeAware = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Tooltip
|
||||
{
|
||||
get { return base.Tooltip; }
|
||||
set { base.Tooltip = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override eItemAlignment ItemAlignment
|
||||
{
|
||||
get { return base.ItemAlignment; }
|
||||
set { base.ItemAlignment = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string KeyTips
|
||||
{
|
||||
get { return base.KeyTips; }
|
||||
set { base.KeyTips = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override ShortcutsCollection Shortcuts
|
||||
{
|
||||
get { return base.Shortcuts; }
|
||||
set { base.Shortcuts = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Description
|
||||
{
|
||||
get { return base.Description; }
|
||||
set { base.Description = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool GlobalItem
|
||||
{
|
||||
get { return base.GlobalItem; }
|
||||
set { base.GlobalItem = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ShowSubItems
|
||||
{
|
||||
get { return base.ShowSubItems; }
|
||||
set { base.ShowSubItems = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string GlobalName
|
||||
{
|
||||
get { return base.GlobalName; }
|
||||
set { base.GlobalName = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override Command Command
|
||||
{
|
||||
get { return base.Command; }
|
||||
set { base.Command = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override object CommandParameter
|
||||
{
|
||||
get { return base.CommandParameter; }
|
||||
set { base.CommandParameter = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Bounds
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ControlBox Bounds
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public override Rectangle Bounds
|
||||
{
|
||||
get { return (base.Bounds); }
|
||||
|
||||
set
|
||||
{
|
||||
if (base.Bounds.Equals(value) == false)
|
||||
{
|
||||
base.Bounds = value;
|
||||
|
||||
RecalcLayout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CloseBox
|
||||
|
||||
/// <summary>
|
||||
/// Gets the CloseBox
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public SuperTabCloseBox CloseBox
|
||||
{
|
||||
get { return (_CloseBox); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MenuBox
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MenuBox
|
||||
/// </summary>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public SuperTabMenuBox MenuBox
|
||||
{
|
||||
get { return (_MenuBox); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Visible
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the ControlBox Visible state
|
||||
/// </summary>
|
||||
public override bool Visible
|
||||
{
|
||||
get { return base.Visible; }
|
||||
|
||||
set
|
||||
{
|
||||
if (base.Visible != value)
|
||||
{
|
||||
base.Visible = value;
|
||||
|
||||
MyRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsMouseDown
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MouseDown state
|
||||
/// </summary>
|
||||
internal bool IsMouseDown
|
||||
{
|
||||
get { return (_IsMouseDown); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsMouseOver
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MouseOver state
|
||||
/// </summary>
|
||||
internal bool IsMouseOver
|
||||
{
|
||||
get { return (_IsMouseOver); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TabDisplay
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TabStrip TabDisplay
|
||||
/// </summary>
|
||||
internal SuperTabStripBaseDisplay TabDisplay
|
||||
{
|
||||
get { return (_TabStripItem.TabDisplay); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcSize
|
||||
|
||||
/// <summary>
|
||||
/// Performs RecalcSize processing
|
||||
/// </summary>
|
||||
public override void RecalcSize()
|
||||
{
|
||||
Size size = Size.Empty;
|
||||
|
||||
foreach (BaseItem item in SubItems)
|
||||
size = LayoutItem(item, size, true);
|
||||
|
||||
WidthInternal = size.Width;
|
||||
HeightInternal = size.Height;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcLayout
|
||||
|
||||
/// <summary>
|
||||
/// Performs RecalcLayout processing
|
||||
/// </summary>
|
||||
private void RecalcLayout()
|
||||
{
|
||||
Size size = Size.Empty;
|
||||
|
||||
if (_TabStripItem.IsRightToLeft)
|
||||
{
|
||||
int closeIndex = SubItems.IndexOf(_CloseBox);
|
||||
int menuIndex = SubItems.IndexOf(_MenuBox);
|
||||
|
||||
if (menuIndex >= 0 && closeIndex > menuIndex)
|
||||
{
|
||||
SubItems.Remove(_CloseBox);
|
||||
SubItems.Insert(menuIndex, _CloseBox);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (BaseItem item in SubItems)
|
||||
size = LayoutItem(item, size, false);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LayoutItem
|
||||
|
||||
/// <summary>
|
||||
/// Performs individual running layout processing for the given BaseItem
|
||||
/// </summary>
|
||||
/// <param name="item">Item to Layout</param>
|
||||
/// <param name="size">Running Layout Size</param>
|
||||
/// <param name="recalc">Whether a recalcSize is needed</param>
|
||||
/// <returns>New running Size</returns>
|
||||
private Size LayoutItem(BaseItem item, Size size, bool recalc)
|
||||
{
|
||||
if (item.Visible == true)
|
||||
{
|
||||
// Recalc if requested
|
||||
|
||||
if (recalc == true)
|
||||
item.RecalcSize();
|
||||
|
||||
// If this is the first item, then give
|
||||
// us a little padding around the ControlBox
|
||||
|
||||
if (size.IsEmpty == true)
|
||||
{
|
||||
if (Orientation == eOrientation.Horizontal)
|
||||
size.Width += Dpi.Width5;
|
||||
else
|
||||
size.Height += Dpi.Height5;
|
||||
}
|
||||
|
||||
// Get the item Bounds
|
||||
|
||||
Rectangle r = new Rectangle(Bounds.X, Bounds.Y, item.WidthInternal, item.HeightInternal);
|
||||
|
||||
// Set the item location
|
||||
|
||||
if (_TabStripItem.IsVertical == true)
|
||||
{
|
||||
r.Y += size.Height;
|
||||
r.X += (Bounds.Width - r.Width) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.X += size.Width;
|
||||
r.Y += (Bounds.Height - r.Height) / 2;
|
||||
}
|
||||
|
||||
// Set the Bounds
|
||||
|
||||
item.Bounds = r;
|
||||
|
||||
// Set the item Size
|
||||
|
||||
if (_TabStripItem.IsVertical == true)
|
||||
{
|
||||
size.Height += item.HeightInternal + Dpi.Height2;
|
||||
|
||||
if (item.WidthInternal > size.Width)
|
||||
size.Width = item.WidthInternal;
|
||||
}
|
||||
else
|
||||
{
|
||||
size.Width += item.WidthInternal + Dpi.Width2;
|
||||
|
||||
if (item.HeightInternal > size.Height)
|
||||
size.Height = item.HeightInternal;
|
||||
}
|
||||
|
||||
// Set its display status
|
||||
|
||||
if (DesignMode == false)
|
||||
item.Displayed = true;
|
||||
}
|
||||
|
||||
return (size);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MyRefresh
|
||||
|
||||
/// <summary>
|
||||
/// Refresh code
|
||||
/// </summary>
|
||||
private void MyRefresh()
|
||||
{
|
||||
if (TabDisplay != null)
|
||||
{
|
||||
SuperTabStripItem tsi = TabDisplay.TabStripItem;
|
||||
|
||||
if (tsi != null)
|
||||
{
|
||||
tsi.NeedRecalcSize = true;
|
||||
tsi.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint
|
||||
|
||||
/// <summary>
|
||||
/// Paint processing
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public override void Paint(ItemPaintArgs p)
|
||||
{
|
||||
foreach (BaseItem item in SubItems)
|
||||
{
|
||||
if (item.Visible == true)
|
||||
item.Paint(p);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse support
|
||||
|
||||
#region InternalMouseEnter
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseEnter
|
||||
/// </summary>
|
||||
public override void InternalMouseEnter()
|
||||
{
|
||||
base.InternalMouseEnter();
|
||||
|
||||
_IsMouseOver = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseLeave
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseLeave
|
||||
/// </summary>
|
||||
public override void InternalMouseLeave()
|
||||
{
|
||||
base.InternalMouseLeave();
|
||||
|
||||
_IsMouseOver = false;
|
||||
|
||||
if (_HotItem != null)
|
||||
{
|
||||
_HotItem.InternalMouseLeave();
|
||||
|
||||
_HotItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseMove
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseMove
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
public override void InternalMouseMove(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseMove(objArg);
|
||||
|
||||
_HotItem = GetBoxItemFromPoint(objArg.Location);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseDown
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseDown
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
public override void InternalMouseDown(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseDown(objArg);
|
||||
|
||||
_IsMouseDown = true;
|
||||
_MouseDownItem = _HotItem;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseUp
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseUp
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
public override void InternalMouseUp(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseUp(objArg);
|
||||
|
||||
_IsMouseDown = false;
|
||||
|
||||
if (_MouseDownItem != null)
|
||||
{
|
||||
if (_MouseDownItem != _HotItem)
|
||||
_MouseDownItem.InternalMouseUp(objArg);
|
||||
|
||||
_MouseDownItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetBoxItemFromPoint
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ControlBoxItem from the given Point
|
||||
/// </summary>
|
||||
/// <param name="pt"></param>
|
||||
/// <returns></returns>
|
||||
private BaseItem GetBoxItemFromPoint(Point pt)
|
||||
{
|
||||
foreach (BaseItem item in SubItems)
|
||||
{
|
||||
if (item.Visible == true)
|
||||
{
|
||||
if (item.Bounds.Contains(pt))
|
||||
return (item);
|
||||
}
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnItemAdded
|
||||
|
||||
/// <summary>
|
||||
/// OnItemAdded
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
protected internal override void OnItemAdded(BaseItem item)
|
||||
{
|
||||
base.OnItemAdded(item);
|
||||
|
||||
MyRefresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnAfterItemRemoved
|
||||
|
||||
/// <summary>
|
||||
/// OnAfterItemRemoved
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
protected internal override void OnAfterItemRemoved(BaseItem item, int itemIndex)
|
||||
{
|
||||
base.OnAfterItemRemoved(item, itemIndex);
|
||||
|
||||
MyRefresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RemoveUserItems
|
||||
|
||||
/// <summary>
|
||||
/// Removes all user added items from the ControlBox
|
||||
/// </summary>
|
||||
public void RemoveUserItems()
|
||||
{
|
||||
for (int i = SubItems.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (SubItems[i] != _MenuBox && SubItems[i] != _CloseBox)
|
||||
SubItems._RemoveAt(i);
|
||||
}
|
||||
|
||||
MyRefresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy object support
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of the item.
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
SuperTabControlBox objCopy = new SuperTabControlBox(_TabStripItem);
|
||||
CopyToItem(objCopy);
|
||||
|
||||
return (objCopy);
|
||||
}
|
||||
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
SuperTabControlBox objCopy = copy as SuperTabControlBox;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,805 @@
|
||||
#if FRAMEWORK20
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
public class SuperTabMenuBox : PopupItem
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private SuperTabControlBox _ControlBox;
|
||||
|
||||
private Size _ItemSize = new Size(16, 16);
|
||||
|
||||
private bool _IsMouseOver;
|
||||
private bool _IsMouseDown;
|
||||
|
||||
private bool _AutoHide;
|
||||
private bool _ShowTabsOnly = true;
|
||||
private bool _ShowImages = true;
|
||||
private bool _RaiseClickOnSelection;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="controlBox">Associated SuperTabControlBox</param>
|
||||
public SuperTabMenuBox(SuperTabControlBox controlBox)
|
||||
{
|
||||
_ControlBox = controlBox;
|
||||
|
||||
Style = eDotNetBarStyle.Office2007;
|
||||
}
|
||||
|
||||
#region Public override designer hiding
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool BeginGroup
|
||||
{
|
||||
get { return base.BeginGroup; }
|
||||
set { base.BeginGroup = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool AutoCollapseOnClick
|
||||
{
|
||||
get { return base.AutoCollapseOnClick; }
|
||||
set { base.AutoCollapseOnClick = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool CanCustomize
|
||||
{
|
||||
get { return base.CanCustomize; }
|
||||
set { base.CanCustomize = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Category
|
||||
{
|
||||
get { return base.Category; }
|
||||
set { base.Category = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ClickAutoRepeat
|
||||
{
|
||||
get { return base.ClickAutoRepeat; }
|
||||
set { base.ClickAutoRepeat = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override int ClickRepeatInterval
|
||||
{
|
||||
get { return base.ClickRepeatInterval; }
|
||||
set { base.ClickRepeatInterval = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override Cursor Cursor
|
||||
{
|
||||
get { return base.Cursor; }
|
||||
set { base.Cursor = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool Enabled
|
||||
{
|
||||
get { return base.Enabled; }
|
||||
set { base.Enabled = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool Stretch
|
||||
{
|
||||
get { return base.Stretch; }
|
||||
set { base.Stretch = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Text
|
||||
{
|
||||
get { return base.Text; }
|
||||
set { base.Text = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ThemeAware
|
||||
{
|
||||
get { return base.ThemeAware; }
|
||||
set { base.ThemeAware = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Tooltip
|
||||
{
|
||||
get { return base.Tooltip; }
|
||||
set { base.Tooltip = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override eItemAlignment ItemAlignment
|
||||
{
|
||||
get { return base.ItemAlignment; }
|
||||
set { base.ItemAlignment = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string KeyTips
|
||||
{
|
||||
get { return base.KeyTips; }
|
||||
set { base.KeyTips = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override ShortcutsCollection Shortcuts
|
||||
{
|
||||
get { return base.Shortcuts; }
|
||||
set { base.Shortcuts = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string Description
|
||||
{
|
||||
get { return base.Description; }
|
||||
set { base.Description = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool GlobalItem
|
||||
{
|
||||
get { return base.GlobalItem; }
|
||||
set { base.GlobalItem = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override bool ShowSubItems
|
||||
{
|
||||
get { return base.ShowSubItems; }
|
||||
set { base.ShowSubItems = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override string GlobalName
|
||||
{
|
||||
get { return base.GlobalName; }
|
||||
set { base.GlobalName = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override Command Command
|
||||
{
|
||||
get { return base.Command; }
|
||||
set { base.Command = value; }
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public override object CommandParameter
|
||||
{
|
||||
get { return base.CommandParameter; }
|
||||
set { base.CommandParameter = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AutoHide
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the MenuBox is automatically hidden when the tab items size does not exceed the size of the control
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(false), Category("Behavior")]
|
||||
[Description("Indicates whether the MenuBox is automatically hidden when the tab items size does not exceed the size of the control.")]
|
||||
public bool AutoHide
|
||||
{
|
||||
get { return (_AutoHide); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_AutoHide != value)
|
||||
{
|
||||
_AutoHide = value;
|
||||
|
||||
Visible = (value == true) ? AllItemsVisible() == false : true;
|
||||
|
||||
MyRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RaiseClickOnSelection
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the MenuBox raises a ClickEvent when selected
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(false), Category("Behavior")]
|
||||
[Description("Indicates whether the MenuBox raises a ClickEvent when selected.")]
|
||||
public bool RaiseClickOnSelection
|
||||
{
|
||||
get { return (_RaiseClickOnSelection); }
|
||||
set { _RaiseClickOnSelection = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowTabsOnly
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether MenuBox shows only Tabs entries
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(true), Category("Behavior")]
|
||||
[Description("Indicates whether MenuBox shows only Tabs entries.")]
|
||||
public bool ShowTabsOnly
|
||||
{
|
||||
get { return (_ShowTabsOnly); }
|
||||
set { _ShowTabsOnly = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowImages
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the MenuBox displays each menu entry with its associated Image/Icon
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(true), Category("Behavior")]
|
||||
[Description("Indicates whether the MenuBox displays each menu entry with its associated Image/Icon.")]
|
||||
public bool ShowImages
|
||||
{
|
||||
get { return (_ShowImages); }
|
||||
set { _ShowImages = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Visible
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets MenuBox Visible state
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(true), Category("Behavior")]
|
||||
[Description("Indicates MenuBox Visible state.")]
|
||||
public override bool Visible
|
||||
{
|
||||
get { return base.Visible; }
|
||||
|
||||
set
|
||||
{
|
||||
if (base.Visible != value)
|
||||
{
|
||||
base.Visible = value;
|
||||
|
||||
MyRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region IsMouseDown
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MouseDown state
|
||||
/// </summary>
|
||||
internal bool IsMouseDown
|
||||
{
|
||||
get { return (_IsMouseDown); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IsMouseOver
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MouseOver state
|
||||
/// </summary>
|
||||
internal bool IsMouseOver
|
||||
{
|
||||
get { return (_IsMouseOver); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcSize
|
||||
|
||||
/// <summary>
|
||||
/// RecalcSize
|
||||
/// </summary>
|
||||
public override void RecalcSize()
|
||||
{
|
||||
base.RecalcSize();
|
||||
|
||||
WidthInternal = Dpi.Width(_ItemSize.Width);
|
||||
HeightInternal = Dpi.Height(_ItemSize.Height);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MyRefresh
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the display
|
||||
/// </summary>
|
||||
private void MyRefresh()
|
||||
{
|
||||
if (_ControlBox.TabDisplay != null)
|
||||
{
|
||||
SuperTabStripItem tsi = _ControlBox.TabDisplay.TabStripItem;
|
||||
|
||||
if (tsi != null)
|
||||
{
|
||||
_ControlBox.NeedRecalcSize = true;
|
||||
_ControlBox.RecalcSize();
|
||||
|
||||
tsi.NeedRecalcSize = true;
|
||||
tsi.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Paint
|
||||
|
||||
/// <summary>
|
||||
/// Paint processing
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public override void Paint(ItemPaintArgs p)
|
||||
{
|
||||
Graphics g = p.Graphics;
|
||||
|
||||
using (SuperTabColorTable sct = _ControlBox.TabDisplay.GetColorTable())
|
||||
{
|
||||
Color imageColor = sct.ControlBoxDefault.Image;
|
||||
|
||||
if (IsMouseOver == true)
|
||||
{
|
||||
Rectangle r = Bounds;
|
||||
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
|
||||
imageColor = sct.ControlBoxMouseOver.Image;
|
||||
|
||||
using (Brush br = new SolidBrush(sct.ControlBoxMouseOver.Background))
|
||||
g.FillRectangle(br, r);
|
||||
|
||||
using (Pen pen = new Pen(sct.ControlBoxMouseOver.Border))
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
|
||||
if (AllItemsVisible() == true)
|
||||
g.DrawImageUnscaled(GetMenuButton1(g, imageColor), Bounds);
|
||||
else
|
||||
g.DrawImageUnscaled(GetMenuButton2(g, imageColor), Bounds);
|
||||
}
|
||||
}
|
||||
|
||||
#region AllItemsVisible
|
||||
|
||||
/// <summary>
|
||||
/// Determines if all the items are visible
|
||||
/// </summary>
|
||||
/// <returns>true if all visible</returns>
|
||||
private bool AllItemsVisible()
|
||||
{
|
||||
SubItemsCollection tabs = _ControlBox.TabDisplay.Tabs;
|
||||
|
||||
for (int i = 0; i < tabs.Count; i++)
|
||||
{
|
||||
if (tabs[i].Visible == true && tabs[i].Displayed == false)
|
||||
return (false);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetMenuButton1
|
||||
|
||||
/// <summary>
|
||||
/// Gets MenuButton1
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
private Bitmap GetMenuButton1(Graphics g, Color color)
|
||||
{
|
||||
return (_ControlBox.TabDisplay.GetMenuButton1(g, color));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetMenuButton2
|
||||
|
||||
/// <summary>
|
||||
/// Gets MenuButton2
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="color"></param>
|
||||
/// <returns></returns>
|
||||
private Bitmap GetMenuButton2(Graphics g, Color color)
|
||||
{
|
||||
return (_ControlBox.TabDisplay.GetMenuButton2(g, color));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mouse support
|
||||
|
||||
#region InternalMouseEnter
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseEnter
|
||||
/// </summary>
|
||||
public override void InternalMouseEnter()
|
||||
{
|
||||
base.InternalMouseEnter();
|
||||
|
||||
_IsMouseOver = true;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseLeave
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseLeave
|
||||
/// </summary>
|
||||
public override void InternalMouseLeave()
|
||||
{
|
||||
base.InternalMouseLeave();
|
||||
|
||||
_IsMouseOver = false;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseDown
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseDown
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
public override void InternalMouseDown(MouseEventArgs objArg)
|
||||
{
|
||||
_IsMouseDown = true;
|
||||
|
||||
if (DesignMode == false && objArg.Button == MouseButtons.Left)
|
||||
{
|
||||
LoadTabMenu();
|
||||
|
||||
Point pt = GetPopupPosition();
|
||||
|
||||
Popup(pt);
|
||||
}
|
||||
}
|
||||
|
||||
#region GetPopupPosition
|
||||
|
||||
/// <summary>
|
||||
/// Gets the popup menu position
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Point GetPopupPosition()
|
||||
{
|
||||
Point pt = new Point(Bounds.X, Bounds.Bottom);
|
||||
|
||||
Control c = (Control)_ControlBox.GetContainerControl(true);
|
||||
|
||||
if (c != null)
|
||||
pt = c.PointToScreen(pt);
|
||||
|
||||
return (pt);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadTabMenu
|
||||
|
||||
/// <summary>
|
||||
/// Loads the TabMenu
|
||||
/// </summary>
|
||||
private void LoadTabMenu()
|
||||
{
|
||||
SubItems.Clear();
|
||||
|
||||
SubItemsCollection tabs = _ControlBox.TabDisplay.Tabs;
|
||||
|
||||
if (_ShowTabsOnly == true)
|
||||
LoadTabsMenu(tabs);
|
||||
else
|
||||
LoadItemsMenu(tabs);
|
||||
}
|
||||
|
||||
#region LoadTabsMenu
|
||||
|
||||
/// <summary>
|
||||
/// Loads Tabs only into the TabMenu
|
||||
/// </summary>
|
||||
/// <param name="tabs"></param>
|
||||
private void LoadTabsMenu(SubItemsCollection tabs)
|
||||
{
|
||||
for (int i = 0; i < tabs.Count; i++)
|
||||
{
|
||||
SuperTabItem tab = tabs[i] as SuperTabItem;
|
||||
|
||||
if (tab != null && tab.Visible == true)
|
||||
{
|
||||
ButtonItem bi = new ButtonItem();
|
||||
|
||||
bi.Tag = tab;
|
||||
bi.Text = tab.Text;
|
||||
|
||||
if (tab.Enabled == true)
|
||||
bi.Click += SuperTabMenuBoxClick;
|
||||
else
|
||||
bi.Enabled = false;
|
||||
|
||||
SubItems.Add(bi);
|
||||
|
||||
if (_ShowImages == true)
|
||||
SetMenuImage(bi, tab);
|
||||
|
||||
if (tab.IsSelected == true)
|
||||
bi.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LoadItemsMenu
|
||||
|
||||
/// <summary>
|
||||
/// Loads all items into the TabMenu
|
||||
/// </summary>
|
||||
/// <param name="tabs"></param>
|
||||
private void LoadItemsMenu(SubItemsCollection tabs)
|
||||
{
|
||||
ButtonItem[] items = new ButtonItem[tabs.Count];
|
||||
|
||||
for (int i = 0; i < tabs.Count; i++)
|
||||
{
|
||||
if (tabs[i].Visible == true)
|
||||
{
|
||||
items[i] = new ButtonItem();
|
||||
|
||||
items[i].Tag = tabs[i];
|
||||
items[i].Text = tabs[i].Text;
|
||||
|
||||
if (tabs[i].Enabled == true)
|
||||
items[i].Click += SuperTabMenuBoxClick;
|
||||
else
|
||||
items[i].Enabled = false;
|
||||
|
||||
if (_ShowImages == true)
|
||||
{
|
||||
if (tabs[i] is SuperTabItem)
|
||||
SetMenuImage(items[i], ((SuperTabItem) tabs[i]).GetTabImage());
|
||||
|
||||
else if (tabs[i] is ButtonItem)
|
||||
SetMenuImage(items[i], ((ButtonItem) tabs[i]).GetImage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int index = _ControlBox.TabDisplay.TabStripItem.SelectedTabIndex;
|
||||
|
||||
if (index >= 0 && index < tabs.Count)
|
||||
items[index].Checked = true;
|
||||
|
||||
SubItems.AddRange(items);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetMenuImage
|
||||
|
||||
/// <summary>
|
||||
/// Sets the TabMenu entry image
|
||||
/// </summary>
|
||||
/// <param name="bi"></param>
|
||||
/// <param name="image"></param>
|
||||
private void SetMenuImage(ButtonItem bi, SuperTabItem tab)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tab.SymbolRealized) == false)
|
||||
{
|
||||
bi.Symbol = tab.Symbol;
|
||||
bi.SymbolSize = tab.SymbolSize;
|
||||
bi.SymbolColor = tab.TabItemDisplay.GetSymbolColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
SetMenuImage(bi, tab.GetTabImage());
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMenuImage(ButtonItem bi, CompositeImage image)
|
||||
{
|
||||
if (image != null)
|
||||
{
|
||||
if (image.Icon != null)
|
||||
bi.Icon = image.Icon;
|
||||
|
||||
else if (image.Image != null)
|
||||
{
|
||||
if (ImageAnimator.CanAnimate(image.Image) == true)
|
||||
{
|
||||
FrameDimension frameDimensions =
|
||||
new FrameDimension(image.Image.FrameDimensionsList[0]);
|
||||
|
||||
image.Image.SelectActiveFrame(frameDimensions, 0);
|
||||
|
||||
bi.Image = new Bitmap(image.Image);
|
||||
bi.NeedRecalcSize = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bi.Image = image.Image;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region SuperTabMenuBox_Click
|
||||
|
||||
/// <summary>
|
||||
/// Handles SuperTabMenuBox_Click event
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void SuperTabMenuBoxClick(object sender, EventArgs e)
|
||||
{
|
||||
ButtonItem bi = sender as ButtonItem;
|
||||
|
||||
if (bi != null)
|
||||
{
|
||||
BaseItem item = bi.Tag as BaseItem;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
SuperTabItem tab = bi.Tag as SuperTabItem;
|
||||
|
||||
if (tab != null)
|
||||
_ControlBox.TabDisplay.TabStripItem.SelectedTab = tab;
|
||||
else
|
||||
_ControlBox.TabDisplay.TabStripItem.VisibleTab = item;
|
||||
|
||||
if (_RaiseClickOnSelection == true)
|
||||
item.RaiseClick(eEventSource.Code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region InternalMouseUp
|
||||
|
||||
/// <summary>
|
||||
/// InternalMouseUp
|
||||
/// </summary>
|
||||
/// <param name="objArg"></param>
|
||||
public override void InternalMouseUp(MouseEventArgs objArg)
|
||||
{
|
||||
base.InternalMouseUp(objArg);
|
||||
|
||||
_IsMouseDown = false;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Copy object support
|
||||
|
||||
/// <summary>
|
||||
/// Returns copy of the item.
|
||||
/// </summary>
|
||||
public override BaseItem Copy()
|
||||
{
|
||||
SuperTabMenuBox objCopy = new SuperTabMenuBox(_ControlBox);
|
||||
CopyToItem(objCopy);
|
||||
|
||||
return (objCopy);
|
||||
}
|
||||
|
||||
protected override void CopyToItem(BaseItem copy)
|
||||
{
|
||||
SuperTabMenuBox objCopy = copy as SuperTabMenuBox;
|
||||
base.CopyToItem(objCopy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region enums
|
||||
|
||||
#region TabMenuOpenEventArgs
|
||||
|
||||
public class TabMenuOpenEventArgs : CancelEventArgs
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ButtonItem _TabMenu;
|
||||
|
||||
#endregion
|
||||
|
||||
public TabMenuOpenEventArgs(ButtonItem tabMenu)
|
||||
{
|
||||
_TabMenu = tabMenu;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
public ButtonItem TabMenu
|
||||
{
|
||||
get { return (_TabMenu); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TabMenuCloseEventArgs
|
||||
|
||||
public class TabMenuCloseEventArgs : EventArgs
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private ButtonItem _TabMenu;
|
||||
|
||||
#endregion
|
||||
|
||||
public TabMenuCloseEventArgs(ButtonItem tabMenu)
|
||||
{
|
||||
_TabMenu = tabMenu;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
public ButtonItem TabMenu
|
||||
{
|
||||
get { return (_TabMenu); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user