DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,391 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for SuperTabControlDesigner
|
||||
/// </summary>
|
||||
public class SuperTabControlDesigner : SuperTabStripDesigner
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private SuperTabControl _TabControl;
|
||||
|
||||
#endregion
|
||||
|
||||
public SuperTabControlDesigner()
|
||||
{
|
||||
TabsVisible = true;
|
||||
}
|
||||
|
||||
#region Initialize
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
if (component.Site.DesignMode == true)
|
||||
{
|
||||
_TabControl = component as SuperTabControl;
|
||||
|
||||
if (_TabControl != null)
|
||||
{
|
||||
TabStrip = _TabControl.TabStrip;
|
||||
|
||||
if (Inherited == true)
|
||||
{
|
||||
if (_TabControl.TabsVisible == false)
|
||||
_TabControl.TabsVisible = true;
|
||||
|
||||
if (_TabControl.SelectedPanel != null)
|
||||
_TabControl.SelectedPanel.BringToFront();
|
||||
}
|
||||
_TabControl.TabStrip.GetBaseItemContainer().SetDesignMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override BaseItem GetItemContainer()
|
||||
{
|
||||
return _TabControl.TabStrip.GetBaseItemContainer();
|
||||
}
|
||||
|
||||
protected override Control GetItemContainerControl()
|
||||
{
|
||||
return _TabControl.TabStrip;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PreFilterProperties
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
|
||||
properties["SelectedTabIndex"] = TypeDescriptor.CreateProperty(typeof(SuperTabControlDesigner),
|
||||
(PropertyDescriptor)properties["SelectedTabIndex"], new Attribute[]
|
||||
{
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Behavior")
|
||||
});
|
||||
|
||||
properties["TabsVisible"] = TypeDescriptor.CreateProperty(typeof(SuperTabControlDesigner),
|
||||
(PropertyDescriptor)properties["TabsVisible"], new Attribute[]
|
||||
{
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Behavior")
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item is visible.
|
||||
/// </summary>
|
||||
[Browsable(true), DevCoBrowsable(true), Category("Behavior")]
|
||||
[Description("Indicates the index of selected tab.")]
|
||||
public int SelectedTabIndex
|
||||
{
|
||||
get { return (int)ShadowProperties["SelectedTabIndex"]; }
|
||||
set { this.ShadowProperties["SelectedTabIndex"] = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether tabs are visible. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Category("Appearance")]
|
||||
[Description("Indicates whether tabs are visible")]
|
||||
public bool TabsVisible
|
||||
{
|
||||
get { return ((bool)ShadowProperties["TabsVisible"]); }
|
||||
set { ShadowProperties["TabsVisible"] = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PostFilterEvents
|
||||
|
||||
protected override void PostFilterEvents(IDictionary events)
|
||||
{
|
||||
events.Remove("MouseUp");
|
||||
events.Remove("MouseDown");
|
||||
events.Remove("MouseMove");
|
||||
events.Remove("MouseClick");
|
||||
events.Remove("MouseDoubleClick");
|
||||
|
||||
events.Remove("MouseEnter");
|
||||
events.Remove("MouseHover");
|
||||
events.Remove("MouseLeave");
|
||||
|
||||
base.PostFilterEvents(events);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateNewTab
|
||||
|
||||
public override SuperTabItem CreateNewTab()
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
|
||||
if (dh == null)
|
||||
return null;
|
||||
SuperTabItem tab = null;
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
IComponentChangeService change =
|
||||
GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
tab = dh.CreateComponent(typeof(SuperTabItem)) as SuperTabItem;
|
||||
SuperTabControlPanel panel = dh.CreateComponent(typeof(SuperTabControlPanel)) as SuperTabControlPanel;
|
||||
|
||||
if (tab != null && panel != null)
|
||||
{
|
||||
tab.Text = tab.Name;
|
||||
_TabControl.CreateTab(tab, panel, -1);
|
||||
_TabControl.SelectedTab = tab;
|
||||
}
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(panel, null);
|
||||
change.OnComponentChanged(panel, null, null, null);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled)
|
||||
dt.Commit();
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectNextTab
|
||||
|
||||
protected override void SelectNextTab(object sender, EventArgs e)
|
||||
{
|
||||
if (_TabControl.SelectedTabIndex < _TabControl.Tabs.Count - 1)
|
||||
_TabControl.SelectNextTab();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectPreviousTab
|
||||
|
||||
protected override void SelectPreviousTab(object sender, EventArgs e)
|
||||
{
|
||||
if (_TabControl.SelectedTabIndex > 0)
|
||||
_TabControl.SelectPreviousTab();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetTabStrip
|
||||
|
||||
protected SuperTabStrip GetTabStrip()
|
||||
{
|
||||
return (_TabControl.TabStrip);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetIOwner
|
||||
|
||||
protected override IOwner GetIOwner()
|
||||
{
|
||||
return (GetTabStrip());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CanParent
|
||||
|
||||
public override bool CanParent(Control c)
|
||||
{
|
||||
return (c is SuperTabControlPanel);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AssociatedComponents
|
||||
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList list = new ArrayList(base.AssociatedComponents);
|
||||
|
||||
foreach (BaseItem item in _TabControl.Tabs)
|
||||
list.Add(item);
|
||||
|
||||
return (list);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ComponentChangeComponentAdded
|
||||
|
||||
protected override void ComponentChangeComponentAdded(object sender, ComponentEventArgs e)
|
||||
{
|
||||
ISelectionService ss = this.GetService(typeof (ISelectionService)) as ISelectionService;
|
||||
|
||||
if (ss != null && ss.PrimarySelection == _TabControl)
|
||||
{
|
||||
if (m_InsertItemTransaction == null)
|
||||
{
|
||||
IDesignerHost dh = sender as IDesignerHost;
|
||||
|
||||
if (dh != null)
|
||||
m_InsertItemTransaction = dh.CreateTransaction("Adding Item Clip");
|
||||
}
|
||||
|
||||
IComponentChangeService cc =
|
||||
GetService(typeof (IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if (cc != null)
|
||||
{
|
||||
if (e.Component is BaseItem)
|
||||
{
|
||||
cc.OnComponentChanging(_TabControl, null);
|
||||
_TabControl.Tabs.Add(e.Component as BaseItem);
|
||||
cc.OnComponentChanged(_TabControl, null, null, null);
|
||||
|
||||
if (e.Component is SuperTabItem)
|
||||
_TabControl.SelectedTab = e.Component as SuperTabItem;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_InsertItemTransaction != null)
|
||||
{
|
||||
m_InsertItemTransaction.Commit();
|
||||
m_InsertItemTransaction = null;
|
||||
}
|
||||
|
||||
RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OtherComponentRemoving
|
||||
|
||||
protected override void OtherComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (InternalRemove == true)
|
||||
return;
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
|
||||
if (dh == null)
|
||||
return;
|
||||
|
||||
if (e.Component is SuperTabControlPanel &&
|
||||
_TabControl.Controls.Contains(e.Component as Control))
|
||||
{
|
||||
SuperTabControlPanel panel = e.Component as SuperTabControlPanel;
|
||||
|
||||
_TabControl.Controls.Remove(panel);
|
||||
|
||||
if (panel.TabItem != null)
|
||||
{
|
||||
if (_TabControl.Tabs.Contains(panel.TabItem))
|
||||
_TabControl.Tabs.Remove(panel.TabItem);
|
||||
if (!Inherited)
|
||||
dh.DestroyComponent(panel.TabItem);
|
||||
}
|
||||
}
|
||||
else if (e.Component is BaseItem &&
|
||||
_TabControl.Tabs.Contains(e.Component as BaseItem))
|
||||
{
|
||||
if (dh.TransactionDescription.StartsWith("Deleting") == false)
|
||||
{
|
||||
BaseItem item = e.Component as BaseItem;
|
||||
|
||||
_TabControl.Tabs.Remove(item);
|
||||
|
||||
SuperTabItem tab = item as SuperTabItem;
|
||||
|
||||
if (tab != null)
|
||||
{
|
||||
if (tab.AttachedControl != null &&
|
||||
_TabControl.Controls.Contains(tab.AttachedControl))
|
||||
{
|
||||
_TabControl.Controls.Remove(tab.AttachedControl);
|
||||
|
||||
dh.DestroyComponent(tab.AttachedControl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Component == this.Control)
|
||||
{
|
||||
InternalRemove = true;
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = _TabControl.Tabs.Count - 1; i >= 0; i--)
|
||||
dh.DestroyComponent(_TabControl.Tabs[i]);
|
||||
}
|
||||
finally
|
||||
{
|
||||
InternalRemove = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetClientPoint
|
||||
|
||||
protected override Point GetClientPoint(int x, int y)
|
||||
{
|
||||
Point p = _TabControl.TabStrip.PointToClient(new Point(x, y));
|
||||
return p;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Backstage Support
|
||||
protected override void OnitemCreated(BaseItem item)
|
||||
{
|
||||
if (item is ButtonItem && IsBackstageTab)
|
||||
{
|
||||
ButtonItem button = (ButtonItem)item;
|
||||
button.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText;
|
||||
button.ColorTable = DevComponents.DotNetBar.eButtonColor.Blue;
|
||||
button.ImagePaddingVertical = 10;
|
||||
button.ImagePaddingHorizontal = 18;
|
||||
button.Stretch = true;
|
||||
}
|
||||
base.OnitemCreated(item);
|
||||
}
|
||||
internal bool IsBackstageTab
|
||||
{
|
||||
get
|
||||
{
|
||||
SuperTabControl tab = (SuperTabControl)this.Control;
|
||||
if (tab != null && tab.TabStrip != null)
|
||||
return (tab.TabStrip.ApplicationButton != null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Designer for Tab Control Panel.
|
||||
/// </summary>
|
||||
public class SuperTabControlPanelDesigner : PanelControlDesigner
|
||||
{
|
||||
#region SelectionRules
|
||||
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get { return (SelectionRules.Locked | SelectionRules.Visible); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InitializeNewComponent
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetDesignTimeDefaults
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
PanelControl p = this.Control as PanelControl;
|
||||
|
||||
if (p != null)
|
||||
{
|
||||
p.ApplyLabelStyle();
|
||||
p.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Verbs
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Next Tab", SelectNextTab),
|
||||
new DesignerVerb("Previous Tab", SelectPreviousTab),
|
||||
new DesignerVerb("Create New Tab", CreateNewTab)
|
||||
};
|
||||
|
||||
return (new DesignerVerbCollection(verbs));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateNewTab
|
||||
|
||||
protected virtual void CreateNewTab(object sender, EventArgs e)
|
||||
{
|
||||
SuperTabControlPanel cp = this.Control as SuperTabControlPanel;
|
||||
|
||||
if (cp == null || !(cp.Parent is SuperTabControl))
|
||||
return;
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
SuperTabControl tabControl = cp.Parent as SuperTabControl;
|
||||
|
||||
if (tabControl == null || dh == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
IComponentChangeService change =
|
||||
GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanging(this.Component, null);
|
||||
|
||||
SuperTabItem tab = dh.CreateComponent(typeof(SuperTabItem)) as SuperTabItem;
|
||||
SuperTabControlPanel panel = dh.CreateComponent(typeof(SuperTabControlPanel)) as SuperTabControlPanel;
|
||||
|
||||
if (tab != null && panel != null)
|
||||
{
|
||||
tab.Text = tab.Name;
|
||||
tabControl.CreateTab(tab, panel, -1);
|
||||
tabControl.SelectedTab = tab;
|
||||
}
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(this.Component, null, null, null);
|
||||
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(panel, null);
|
||||
change.OnComponentChanged(panel, null, null, null);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectNextTab
|
||||
|
||||
private void SelectNextTab(object sender, EventArgs e)
|
||||
{
|
||||
SuperTabControlPanel panel = Control as SuperTabControlPanel;
|
||||
|
||||
if (panel == null || !(panel.Parent is SuperTabControl))
|
||||
return;
|
||||
|
||||
SuperTabControl tc = panel.Parent as SuperTabControl;
|
||||
|
||||
tc.SelectNextTab();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectPreviousTab
|
||||
|
||||
private void SelectPreviousTab(object sender, EventArgs e)
|
||||
{
|
||||
SuperTabControlPanel panel = Control as SuperTabControlPanel;
|
||||
|
||||
if (panel == null || !(panel.Parent is SuperTabControl))
|
||||
return;
|
||||
|
||||
SuperTabControl tc = panel.Parent as SuperTabControl;
|
||||
|
||||
tc.SelectPreviousTab();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Support for SuperTabStrip tabs design-time editor
|
||||
/// </summary>
|
||||
public class SuperTabControlTabsEditor : SuperTabStripTabsEditor
|
||||
{
|
||||
public SuperTabControlTabsEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
|
||||
#region CreateInstance
|
||||
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
|
||||
if (item is SuperTabItem)
|
||||
{
|
||||
SuperTabItem tab = item as SuperTabItem;
|
||||
|
||||
tab.Text = String.IsNullOrEmpty(tab.Name) ? "My Tab" : tab.Name;
|
||||
|
||||
CreateNewTab(tab);
|
||||
}
|
||||
else if (item is ButtonItem)
|
||||
{
|
||||
ButtonItem bi = item as ButtonItem;
|
||||
|
||||
bi.Text = String.IsNullOrEmpty(bi.Name) ? "My Button" : bi.Name;
|
||||
}
|
||||
|
||||
return (item);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateNewTab
|
||||
|
||||
private void CreateNewTab(SuperTabItem tab)
|
||||
{
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
SuperTabControl tabControl = Context.Instance as SuperTabControl;
|
||||
|
||||
if (dh == null || tabControl == null)
|
||||
return;
|
||||
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
IComponentChangeService change =
|
||||
GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanging(Context.Container, null);
|
||||
|
||||
SuperTabControlPanel panel = dh.CreateComponent(typeof(SuperTabControlPanel)) as SuperTabControlPanel;
|
||||
|
||||
if (tab != null && panel != null)
|
||||
{
|
||||
tab.AttachedControl = panel;
|
||||
panel.TabItem = tab;
|
||||
|
||||
tabControl.Controls.Add(panel);
|
||||
tabControl.Tabs.Add(tab);
|
||||
|
||||
panel.Dock = DockStyle.Fill;
|
||||
panel.BringToFront();
|
||||
|
||||
tabControl.ApplyPanelStyle(panel);
|
||||
|
||||
tabControl.SelectedTab = tab;
|
||||
}
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(Context.Container, null, null, null);
|
||||
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(panel, null);
|
||||
change.OnComponentChanged(panel, null, null, null);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled)
|
||||
dt.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
class SuperTabItemColorTableEditor
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class SuperTabItemDesigner : BaseItemDesigner
|
||||
{
|
||||
#region GetTabItem
|
||||
|
||||
protected virtual SuperTabItem GetTabItem()
|
||||
{
|
||||
return (Component as SuperTabItem);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Verbs
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = new DesignerVerb[] { };
|
||||
|
||||
return (new DesignerVerbCollection(verbs));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AssociatedComponents
|
||||
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
|
||||
SuperTabItem tab = GetTabItem();
|
||||
|
||||
if (tab != null)
|
||||
{
|
||||
if (tab.AttachedControl != null)
|
||||
c.Add(tab.AttachedControl);
|
||||
}
|
||||
|
||||
return (c);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ComponentChangeComponentAdding
|
||||
|
||||
protected override void ComponentChangeComponentAdding(object sender, ComponentEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,378 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for SuperTabStripDesigner
|
||||
/// </summary>
|
||||
public class SuperTabStripDesigner : BarBaseControlDesigner
|
||||
{
|
||||
#region Protected variables
|
||||
|
||||
protected bool InternalRemove;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private SuperTabStrip _TabStrip;
|
||||
private SuperTabItem _SelectItem;
|
||||
|
||||
#endregion
|
||||
|
||||
public SuperTabStripDesigner()
|
||||
{
|
||||
EnableItemDragDrop = true;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
public SuperTabStrip TabStrip
|
||||
{
|
||||
get { return (_TabStrip); }
|
||||
set { _TabStrip = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Initialize
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
if (component.Site.DesignMode == true)
|
||||
{
|
||||
_TabStrip = component as SuperTabStrip;
|
||||
|
||||
ISelectionService ss =
|
||||
(ISelectionService) GetService(typeof (ISelectionService));
|
||||
|
||||
if (ss != null)
|
||||
ss.SelectionChanged += OnSelectionChanged;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InitializeNewComponent
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
base.OnSetComponentDefaults();
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region SetDesignTimeDefaults
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
if (Component != null && Component.Site != null && Component.Site.DesignMode == true)
|
||||
{
|
||||
_TabStrip.TabStyle = eSuperTabStyle.Office2007;
|
||||
_TabStrip.TabFont = _TabStrip.Font;
|
||||
_TabStrip.SelectedTabFont = new System.Drawing.Font(_TabStrip.TabFont, FontStyle.Bold);
|
||||
CreateNewTab(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Verbs
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Next Tab", SelectNextTab),
|
||||
new DesignerVerb("Previous Tab", SelectPreviousTab),
|
||||
new DesignerVerb("Create New Tab", CreateNewTab),
|
||||
|
||||
new DesignerVerb("Add Button", CreateButton),
|
||||
new DesignerVerb("Add Text Box", CreateTextBox),
|
||||
new DesignerVerb("Add Combo Box", CreateComboBox),
|
||||
new DesignerVerb("Add Label", CreateLabel),
|
||||
new DesignerVerb("Add Color Picker", CreateColorPicker),
|
||||
new DesignerVerb("Add Progress bar", CreateProgressBar),
|
||||
new DesignerVerb("Add Check box", CreateCheckBox),
|
||||
new DesignerVerb("Add Switch Button", CreateSwitch),
|
||||
new DesignerVerb("Add Micro-Chart", CreateMicroChart)
|
||||
};
|
||||
|
||||
return (new DesignerVerbCollection(verbs));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateNewTab
|
||||
public virtual SuperTabItem CreateNewTab()
|
||||
{
|
||||
IDesignerHost dh =
|
||||
(IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
SuperTabItem tab = null;
|
||||
if (dh != null)
|
||||
{
|
||||
DesignerTransaction dt = dh.CreateTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
IComponentChangeService change =
|
||||
GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanging(Component, null);
|
||||
|
||||
tab =
|
||||
dh.CreateComponent(typeof(SuperTabItem)) as SuperTabItem;
|
||||
|
||||
if (tab != null)
|
||||
{
|
||||
tab.Text = tab.Name;
|
||||
|
||||
_TabStrip.Tabs.Add(tab);
|
||||
}
|
||||
|
||||
if (change != null)
|
||||
change.OnComponentChanged(Component, null, null, null);
|
||||
OnitemCreated(tab);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (dt.Canceled == false)
|
||||
dt.Commit();
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
private void CreateNewTab(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewTab();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SelectNextTab
|
||||
|
||||
protected virtual void SelectNextTab(object sender, EventArgs e)
|
||||
{
|
||||
if (_TabStrip.SelectedTabIndex < _TabStrip.Tabs.Count - 1)
|
||||
_TabStrip.SelectNextTab();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SelectPreviousTab
|
||||
|
||||
protected virtual void SelectPreviousTab(object sender, EventArgs e)
|
||||
{
|
||||
if (_TabStrip.SelectedTabIndex > 0)
|
||||
_TabStrip.SelectPreviousTab();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnSelectionChanged
|
||||
|
||||
private void OnSelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (_TabStrip != null && _TabStrip.IsDisposed == false)
|
||||
{
|
||||
ISelectionService ss = (ISelectionService) sender;
|
||||
BaseItem item = null;
|
||||
|
||||
if (ss != null && ss.PrimarySelection != Control)
|
||||
{
|
||||
item = ss.PrimarySelection as BaseItem;
|
||||
|
||||
if (item != null && _TabStrip.Tabs.Contains(item) == false)
|
||||
item = null;
|
||||
}
|
||||
|
||||
if (_TabStrip.DesignTimeSelection != item)
|
||||
{
|
||||
_TabStrip.DesignTimeSelection = item;
|
||||
|
||||
if (item != null)
|
||||
ClosePopups();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ComponentChangeComponentAdded
|
||||
|
||||
protected override void ComponentChangeComponentAdded(object sender, ComponentEventArgs e)
|
||||
{
|
||||
ISelectionService ss = this.GetService(typeof (ISelectionService)) as ISelectionService;
|
||||
|
||||
if (ss != null && ss.PrimarySelection == _TabStrip)
|
||||
{
|
||||
if (e.Component is BaseItem)
|
||||
{
|
||||
if (m_InsertItemTransaction == null)
|
||||
{
|
||||
IDesignerHost dh = sender as IDesignerHost;
|
||||
|
||||
if (dh != null)
|
||||
m_InsertItemTransaction = dh.CreateTransaction("Adding Item Clip");
|
||||
}
|
||||
|
||||
IComponentChangeService cc =
|
||||
GetService(typeof (IComponentChangeService)) as IComponentChangeService;
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(_TabStrip, TypeDescriptor.GetProperties(_TabStrip)["SubItems"]);
|
||||
|
||||
_TabStrip.Tabs.Add(e.Component as BaseItem);
|
||||
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(_TabStrip, TypeDescriptor.GetProperties(_TabStrip)["SubItems"], null, null);
|
||||
|
||||
if (m_InsertItemTransaction != null)
|
||||
{
|
||||
m_InsertItemTransaction.Commit();
|
||||
m_InsertItemTransaction = null;
|
||||
}
|
||||
|
||||
RecalcLayout();
|
||||
|
||||
if (e.Component is SuperTabItem)
|
||||
_TabStrip.SelectedTab = e.Component as SuperTabItem;
|
||||
}
|
||||
else if (e.Component is SuperTabControlPanel)
|
||||
{
|
||||
throw new Exception("Invalid component addition");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OtherComponentRemoving
|
||||
|
||||
protected override void OtherComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
BaseItem item = e.Component as BaseItem;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (item.Parent != null && item.Parent.SubItems.Contains(item))
|
||||
item.Parent.SubItems.Remove(item);
|
||||
|
||||
DestroySubItems(item);
|
||||
|
||||
RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region AssociatedComponents
|
||||
|
||||
public override ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList list = new ArrayList(base.AssociatedComponents);
|
||||
|
||||
foreach (BaseItem tab in _TabStrip.Tabs)
|
||||
list.Add(tab);
|
||||
|
||||
return (list);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DragInProgress
|
||||
|
||||
protected override bool DragInProgress
|
||||
{
|
||||
get { return (base.DragInProgress); }
|
||||
|
||||
set
|
||||
{
|
||||
if (value == true)
|
||||
{
|
||||
if (_TabStrip != null)
|
||||
_SelectItem = _TabStrip.SelectedTab;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_TabStrip != null)
|
||||
_TabStrip.SelectedTab = _SelectItem;
|
||||
}
|
||||
|
||||
base.DragInProgress = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnMouseDragBegin
|
||||
|
||||
protected override void OnMouseDragBegin(int x, int y)
|
||||
{
|
||||
base.OnMouseDragBegin(x, y);
|
||||
|
||||
if (DragInProgress == true)
|
||||
_SelectItem = _TabStrip.SelectedTab;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
ISelectionService ss =
|
||||
(ISelectionService)GetService(typeof(ISelectionService));
|
||||
|
||||
if (ss != null)
|
||||
ss.SelectionChanged -= OnSelectionChanged;
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region GetHitTest
|
||||
private const string SysBackstageBackButtonName = "sys_backstage_back_button";
|
||||
protected override bool GetHitTest(Point pt)
|
||||
{
|
||||
if (_TabStrip.TabStyle == eSuperTabStyle.Office2010BackstageBlue)
|
||||
{
|
||||
Point clientPt = _TabStrip.PointToClient(pt);
|
||||
BaseItem item = _TabStrip.HitTest(clientPt.X, clientPt.Y);
|
||||
if (item != null && item.Name == SysBackstageBackButtonName)
|
||||
return true;
|
||||
}
|
||||
return base.GetHitTest(pt);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Support for SuperTabStrip tabs design-time editor
|
||||
/// </summary>
|
||||
public class SuperTabStripTabsEditor : CollectionEditor
|
||||
{
|
||||
public SuperTabStripTabsEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
|
||||
#region CreateCollectionItemType
|
||||
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(SuperTabItem);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateNewItemTypes
|
||||
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[]
|
||||
{
|
||||
typeof(SuperTabItem),
|
||||
typeof(ButtonItem),
|
||||
typeof(TextBoxItem),
|
||||
typeof(ComboBoxItem),
|
||||
typeof(LabelItem),
|
||||
typeof(ColorPickerDropDown),
|
||||
typeof(ProgressBarItem),
|
||||
typeof(CheckBoxItem),
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CreateInstance
|
||||
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
|
||||
if (item is SuperTabItem)
|
||||
{
|
||||
SuperTabItem tabItem = item as SuperTabItem;
|
||||
|
||||
tabItem.Text = String.IsNullOrEmpty(tabItem.Name) ? "My Tab" : tabItem.Name;
|
||||
}
|
||||
else if (item is ButtonItem)
|
||||
{
|
||||
ButtonItem bi = item as ButtonItem;
|
||||
|
||||
bi.Text = String.IsNullOrEmpty(bi.Name) ? "My Button" : bi.Name;
|
||||
}
|
||||
else if (item is TextBoxItem)
|
||||
{
|
||||
TextBoxItem tbi = item as TextBoxItem;
|
||||
|
||||
tbi.Text = String.IsNullOrEmpty(tbi.Name) ? "My TextBox" : tbi.Name;
|
||||
}
|
||||
else if (item is ComboBoxItem)
|
||||
{
|
||||
ComboBoxItem cbi = item as ComboBoxItem;
|
||||
|
||||
cbi.Text = String.IsNullOrEmpty(cbi.Name) ? "My ComboBox" : cbi.Name;
|
||||
}
|
||||
else if (item is LabelItem)
|
||||
{
|
||||
LabelItem lbi = item as LabelItem;
|
||||
|
||||
lbi.Text = String.IsNullOrEmpty(lbi.Name) ? "My Label" : lbi.Name;
|
||||
}
|
||||
else if (item is ColorItem)
|
||||
{
|
||||
ColorItem ci = item as ColorItem;
|
||||
|
||||
ci.Text = String.IsNullOrEmpty(ci.Name) ? "My Color" : ci.Name;
|
||||
}
|
||||
else if (item is ProgressBarItem)
|
||||
{
|
||||
ProgressBarItem pbi = item as ProgressBarItem;
|
||||
|
||||
pbi.Text = String.IsNullOrEmpty(pbi.Name) ? "My ProgressBar" : pbi.Name;
|
||||
}
|
||||
else if (item is CheckBoxItem)
|
||||
{
|
||||
CheckBoxItem cbi = item as CheckBoxItem;
|
||||
|
||||
cbi.Text = String.IsNullOrEmpty(cbi.Name) ? "My CheckBox" : cbi.Name;
|
||||
}
|
||||
|
||||
return (item);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user