DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,562 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ToolboxControlDesigner : ControlDesigner
|
||||
{
|
||||
public void SelectionRefresh()
|
||||
{
|
||||
Message m = new Message();
|
||||
m.Msg = 0x115;
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
|
||||
// If our item is removed we need to clean-up
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
{
|
||||
cc.ComponentRemoved += ComponentRemoved;
|
||||
cc.ComponentRemoving += ComponentRemoving;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _InternalRemoving = false;
|
||||
private void ComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (e.Component != this.Component) return;
|
||||
|
||||
if (!_InternalRemoving)
|
||||
{
|
||||
_InternalRemoving = true;
|
||||
try
|
||||
{
|
||||
// Unhook events
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
cc.ComponentRemoving -= ComponentRemoving;
|
||||
|
||||
ToolboxControl tc = (ToolboxControl) this.Component;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
|
||||
if (dh == null || tc == null)
|
||||
return;
|
||||
|
||||
for (int i = tc.Groups.Count - 1; i >= 0; i--)
|
||||
{
|
||||
BaseItem item = tc.Groups[i];
|
||||
|
||||
// Covers the undo case in designer
|
||||
if (item.Parent == tc.ItemsPanel.GetBaseItemContainer())
|
||||
{
|
||||
DestroySubItems(item, dh);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_InternalRemoving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DestroySubItems(BaseItem parent, IDesignerHost dh)
|
||||
{
|
||||
if (parent is ControlContainerItem)
|
||||
{
|
||||
if (((ControlContainerItem)parent).Control != null)
|
||||
{
|
||||
Control c = ((ControlContainerItem)parent).Control;
|
||||
((ControlContainerItem)parent).Control = null;
|
||||
dh.DestroyComponent(c);
|
||||
}
|
||||
}
|
||||
else if (parent is DockContainerItem)
|
||||
{
|
||||
if (((DockContainerItem)parent).Control != null)
|
||||
{
|
||||
Control c = ((DockContainerItem)parent).Control;
|
||||
((DockContainerItem)parent).Control = null;
|
||||
dh.DestroyComponent(c);
|
||||
}
|
||||
}
|
||||
|
||||
BaseItem[] subitems = new BaseItem[parent.SubItems.Count];
|
||||
parent.SubItems.CopyTo(subitems, 0);
|
||||
foreach (BaseItem item in subitems)
|
||||
{
|
||||
DestroySubItems(item, dh);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void DestroySubItems(BaseItem parent)
|
||||
{
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
DestroySubItems(parent, dh);
|
||||
}
|
||||
|
||||
private void ComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
ToolboxGroup group = e.Component as ToolboxGroup;
|
||||
ToolboxControl tc = (ToolboxControl)this.Control;
|
||||
if (group != null && tc != null)
|
||||
{
|
||||
if (tc.Groups.Contains(group))
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(tc, TypeDescriptor.GetProperties(tc)["Groups"]);
|
||||
tc.Groups.Remove(group);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(tc, TypeDescriptor.GetProperties(tc)["Groups"], null, null);
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
ToolboxControl tc = (ToolboxControl) this.Control;
|
||||
if (tc != null)
|
||||
{
|
||||
foreach (BaseItem item in tc.Groups)
|
||||
{
|
||||
if (item.DesignMode)
|
||||
c.Add(item);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
private void RecalcLayout()
|
||||
{
|
||||
ToolboxControl tc = (ToolboxControl)this.Control;
|
||||
if (tc == null) return;
|
||||
tc.RecalcLayout();
|
||||
}
|
||||
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
SetDefaults();
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
|
||||
private void SetDefaults()
|
||||
{
|
||||
ToolboxGroup group = CreateToolboxGroup(true);
|
||||
CreateToolboxItem(group, true);
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return;
|
||||
this.Control.Size = new Size(200, 200);
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
ToolboxControl tc = this.Control as ToolboxControl;
|
||||
tc.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void CreateGroup()
|
||||
{
|
||||
CreateToolboxGroup(true);
|
||||
}
|
||||
private ToolboxGroup CreateToolboxGroup(bool addToCollections)
|
||||
{
|
||||
ToolboxControl tc = this.Control as ToolboxControl;
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return null;
|
||||
|
||||
ToolboxGroup toolboxGroup = null;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (addToCollections)
|
||||
{
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(tc).Find("Groups", true));
|
||||
}
|
||||
}
|
||||
|
||||
toolboxGroup = dh.CreateComponent(typeof(ToolboxGroup)) as ToolboxGroup;
|
||||
|
||||
if (toolboxGroup != null)
|
||||
{
|
||||
toolboxGroup.TitleText = toolboxGroup.Name;
|
||||
toolboxGroup.Expanded = true;
|
||||
toolboxGroup.LayoutOrientation = eOrientation.Vertical;
|
||||
toolboxGroup.MultiLine = false;
|
||||
toolboxGroup.ResizeItemsToFit = true;
|
||||
if (addToCollections)
|
||||
{
|
||||
tc.Groups.Add(toolboxGroup);
|
||||
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(tc).Find("Groups", true), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return toolboxGroup;
|
||||
}
|
||||
private ToolboxItem CreateToolboxItem(ToolboxGroup parentGroup, bool addToCollections)
|
||||
{
|
||||
ToolboxControl tc = this.Control as ToolboxControl;
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return null;
|
||||
|
||||
if (parentGroup == null)
|
||||
throw new ArgumentNullException("parentGroup", "ToolboxGroup must be specified");
|
||||
|
||||
ToolboxItem item = null;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (addToCollections)
|
||||
{
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(parentGroup).Find("SubItems", true));
|
||||
}
|
||||
}
|
||||
|
||||
item = dh.CreateComponent(typeof(ToolboxItem)) as ToolboxItem;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
item.Text = item.Name;
|
||||
item.Symbol = "\ue251";
|
||||
item.SymbolSet = eSymbolSet.Material;
|
||||
if (addToCollections)
|
||||
{
|
||||
parentGroup.SubItems.Add(item);
|
||||
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(parentGroup).Find("Nodes", true), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override bool GetHitTest(System.Drawing.Point point)
|
||||
{
|
||||
if (base.GetHitTest(point))
|
||||
return true;
|
||||
|
||||
ToolboxControl c = this.Control as ToolboxControl;
|
||||
if (c == null) return false;
|
||||
|
||||
Point pc = c.ItemsPanel.PointToClient(point);
|
||||
if (c.ItemsPanel.VScrollBar != null && c.ItemsPanel.VScrollBar.Visible && c.ItemsPanel.VScrollBar.Bounds.Contains(pc))
|
||||
return true;
|
||||
if (c.ItemsPanel.HScrollBar != null && c.ItemsPanel.HScrollBar.Visible && c.ItemsPanel.HScrollBar.Bounds.Contains(pc))
|
||||
return true;
|
||||
|
||||
return base.GetHitTest(point);
|
||||
}
|
||||
|
||||
private bool IsControlSelected
|
||||
{
|
||||
get
|
||||
{
|
||||
ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (ss == null) return false;
|
||||
ICollection selected = ss.GetSelectedComponents();
|
||||
if (IsSelected(selected, this.Control))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private bool IsSelected(ICollection selectedComponents, object item)
|
||||
{
|
||||
foreach (object o in selectedComponents)
|
||||
{
|
||||
if (o == item) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private System.Windows.Forms.Control _DesignerHost = null;
|
||||
/// <summary>
|
||||
/// Selection support for items on container.
|
||||
/// </summary>
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (_DesignerHost == null)
|
||||
_DesignerHost = System.Windows.Forms.Control.FromHandle(m.HWnd);
|
||||
switch (m.Msg)
|
||||
{
|
||||
case WinApi.WM_LBUTTONDOWN:
|
||||
case WinApi.WM_RBUTTONDOWN:
|
||||
{
|
||||
if (OnMouseDown(ref m, m.Msg == WinApi.WM_LBUTTONDOWN ? MouseButtons.Left : MouseButtons.Right))
|
||||
return;
|
||||
break;
|
||||
}
|
||||
case WinApi.WM_RBUTTONUP:
|
||||
case WinApi.WM_LBUTTONUP:
|
||||
{
|
||||
if (OnMouseUp(ref m, m.Msg == WinApi.WM_LBUTTONDOWN ? MouseButtons.Left : MouseButtons.Right))
|
||||
return;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
protected virtual bool OnMouseUp(ref Message m, MouseButtons param1)
|
||||
{
|
||||
if (_MouseDownSelectionPerformed)
|
||||
{
|
||||
_MouseDownSelectionPerformed = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private bool _MouseDownSelectionPerformed = false;
|
||||
protected virtual bool OnMouseDown(ref Message m, MouseButtons button)
|
||||
{
|
||||
ToolboxControl lc = this.Control as ToolboxControl;
|
||||
if (lc == null) return false;
|
||||
if (m.HWnd != lc.ItemsPanel.Handle)
|
||||
return false;
|
||||
|
||||
Point p = new Point(WinApi.LOWORD(m.LParam), WinApi.HIWORD(m.LParam));
|
||||
BaseItem item = lc.ItemsPanel.HitTest(p);
|
||||
if (item != null)
|
||||
{
|
||||
SelectComponent(item, (Control.ModifierKeys == Keys.Control || Control.ModifierKeys == Keys.Shift) ? SelectionTypes.Add : SelectionTypes.Primary);
|
||||
_MouseDownSelectionPerformed = true;
|
||||
return true;
|
||||
}
|
||||
else if (!IsControlSelected)
|
||||
{
|
||||
SelectComponent(this.Control, SelectionTypes.Replace);
|
||||
//return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected virtual void SelectComponent(IComponent comp, SelectionTypes selectionType)
|
||||
{
|
||||
ISelectionService selection = (ISelectionService)this.GetService(typeof(ISelectionService));
|
||||
if (selection != null && comp != null)
|
||||
{
|
||||
ArrayList arr = new ArrayList(1);
|
||||
arr.Add(comp);
|
||||
selection.SetSelectedComponents(arr, selectionType);
|
||||
}
|
||||
}
|
||||
|
||||
private DesignerActionListCollection _ActionLists = null;
|
||||
public override DesignerActionListCollection ActionLists
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._ActionLists == null)
|
||||
{
|
||||
this._ActionLists = new DesignerActionListCollection();
|
||||
this._ActionLists.Add(new ToolboxControlActionList(this));
|
||||
}
|
||||
return this._ActionLists;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(System.Collections.IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
|
||||
properties["Expanded"] = TypeDescriptor.CreateProperty(
|
||||
this.GetType(),
|
||||
"Expanded",
|
||||
typeof(bool),
|
||||
new Attribute[]
|
||||
{
|
||||
new BrowsableAttribute(true), new DefaultValueAttribute(true),
|
||||
new CategoryAttribute("Appearance"),
|
||||
new DescriptionAttribute(
|
||||
"Indicates whether control is expanded and shows items in full size with images and text")
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether Bar is in auto-hide state.
|
||||
/// </summary>
|
||||
public bool Expanded
|
||||
{
|
||||
set
|
||||
{
|
||||
ShadowProperties["Expanded"] = value;
|
||||
}
|
||||
get
|
||||
{
|
||||
return (bool)ShadowProperties["Expanded"];
|
||||
}
|
||||
}
|
||||
|
||||
private void dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
|
||||
ToolboxControl tc = (ToolboxControl)this.Control;
|
||||
if (key != "" && tc != null && tc.LicenseKey == "" && tc.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(tc)["LicenseKey"].SetValue(tc, key);
|
||||
#endif
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
private string GetLicenseKey()
|
||||
{
|
||||
string key = "";
|
||||
Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.LocalMachine;
|
||||
regkey = regkey.OpenSubKey("Software\\DevComponents\\Licenses", false);
|
||||
if (regkey != null)
|
||||
{
|
||||
object keyValue = regkey.GetValue("DevComponents.DotNetBar.DotNetBarManager2");
|
||||
if (keyValue != null)
|
||||
key = keyValue.ToString();
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region ToolboxItemActionList
|
||||
internal class ToolboxControlActionList : DesignerActionList
|
||||
{
|
||||
private ToolboxControlDesigner _Designer = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AdvTreeActionList class.
|
||||
/// </summary>
|
||||
/// <param name="designer"></param>
|
||||
public ToolboxControlActionList(ToolboxControlDesigner designer)
|
||||
: base(designer.Component)
|
||||
{
|
||||
_Designer = designer;
|
||||
}
|
||||
|
||||
public override DesignerActionItemCollection GetSortedActionItems()
|
||||
{
|
||||
DesignerActionItemCollection items = new DesignerActionItemCollection();
|
||||
items.Add(new DesignerActionHeaderItem("Items"));
|
||||
items.Add(new DesignerActionHeaderItem("Position"));
|
||||
|
||||
items.Add(new DesignerActionMethodItem(this, "CreateGroup", "Create Group", "Items", true));
|
||||
//items.Add(new DesignerActionMethodItem(this, "MoveItemDown", "Move Down", "Position", true));
|
||||
items.Add(new DesignerActionPropertyItem("Expanded", "Toolbox Expanded?", "Behavior", "Indicates whether toolbox control is expanded and displays items at their full size."));
|
||||
items.Add(new DesignerActionPropertyItem("ItemDragDropEnabled", "Item Drag and Drop?", "Behavior", "Indicates whether item drag and drop is enabled."));
|
||||
|
||||
items.Add(new DesignerActionPropertyItem("SearchBoxVisible", "Search Visible?", "Appearance", "Indicates whether search text-box is visible."));
|
||||
items.Add(new DesignerActionPropertyItem("TitleVisible", "Title Visible?", "Appearance", "Indicates whether title bar is visible."));
|
||||
items.Add(new DesignerActionPropertyItem("MenuVisible", "Menu Visible?", "Appearance", "Indicates whether menu bar is visible."));
|
||||
return items;
|
||||
}
|
||||
|
||||
public void CreateGroup()
|
||||
{
|
||||
_Designer.CreateGroup();
|
||||
}
|
||||
public bool Expanded
|
||||
{
|
||||
get { return _Designer.Expanded; }
|
||||
set { _Designer.Expanded = value; }
|
||||
}
|
||||
public bool ItemDragDropEnabled
|
||||
{
|
||||
get { return ToolboxControl.ItemDragDropEnabled; }
|
||||
set { TypeDescriptor.GetProperties(base.Component)["ItemDragDropEnabled"].SetValue(base.Component, value); }
|
||||
}
|
||||
|
||||
public bool SearchBoxVisible
|
||||
{
|
||||
get { return ToolboxControl.SearchBoxVisible; }
|
||||
set { TypeDescriptor.GetProperties(base.Component)["SearchBoxVisible"].SetValue(base.Component, value); }
|
||||
}
|
||||
|
||||
public bool TitleVisible
|
||||
{
|
||||
get { return ToolboxControl.TitleVisible; }
|
||||
set { TypeDescriptor.GetProperties(base.Component)["TitleVisible"].SetValue(base.Component, value); }
|
||||
}
|
||||
|
||||
public bool MenuVisible
|
||||
{
|
||||
get { return ToolboxControl.MenuVisible; }
|
||||
set { TypeDescriptor.GetProperties(base.Component)["MenuVisible"].SetValue(base.Component, value); }
|
||||
}
|
||||
|
||||
public ToolboxControl ToolboxControl
|
||||
{
|
||||
get { return (ToolboxControl)this.Component; }
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Support for TabStrip tabs design-time editor.
|
||||
/// </summary>
|
||||
public class ToolboxControlGroupsEditor : CollectionEditor
|
||||
{
|
||||
public ToolboxControlGroupsEditor(Type type)
|
||||
: base(type)
|
||||
{
|
||||
}
|
||||
protected override Type CreateCollectionItemType()
|
||||
{
|
||||
return typeof(ToolboxGroup);
|
||||
}
|
||||
protected override Type[] CreateNewItemTypes()
|
||||
{
|
||||
return new Type[] { typeof(ToolboxGroup) };
|
||||
}
|
||||
protected override object CreateInstance(Type itemType)
|
||||
{
|
||||
object item = base.CreateInstance(itemType);
|
||||
if (item is ToolboxGroup)
|
||||
{
|
||||
ToolboxGroup tabItem = item as ToolboxGroup;
|
||||
tabItem.Text = "Group";
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,186 @@
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ToolboxGroupDesigner : ComponentDesignerWithAction
|
||||
{
|
||||
#region Implementation
|
||||
private DesignerActionListCollection _ActionLists = null;
|
||||
|
||||
public override DesignerActionListCollection ActionLists
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._ActionLists == null)
|
||||
{
|
||||
this._ActionLists = new DesignerActionListCollection();
|
||||
this._ActionLists.Add(new ToolboxGroupActionList(this));
|
||||
}
|
||||
return this._ActionLists;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ToolboxGroup item = this.Component as ToolboxGroup;
|
||||
if (item.SubItems.Count == 0)
|
||||
return base.AssociatedComponents;
|
||||
ArrayList items = new ArrayList();
|
||||
item.SubItems.CopyTo(items);
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDesignerSelectionChanged(bool isSelected)
|
||||
{
|
||||
ToolboxGroup item = (ToolboxGroup)this.Component;
|
||||
if (isSelected && !item.Expanded)
|
||||
{
|
||||
item.Expanded = true;
|
||||
}
|
||||
base.OnDesignerSelectionChanged(isSelected);
|
||||
}
|
||||
|
||||
public override void RecalcLayout()
|
||||
{
|
||||
ToolboxGroup item = this.Component as ToolboxGroup;
|
||||
if (item != null && item.GetToolboxControl() != null)
|
||||
item.GetToolboxControl().RecalcLayout();
|
||||
}
|
||||
|
||||
public void MoveItemDown()
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
ToolboxGroup item = (ToolboxGroup)this.Component;
|
||||
BaseItem parent = item.Parent;
|
||||
if (parent == null) return;
|
||||
int index = parent.SubItems.IndexOf(item);
|
||||
if (index == parent.SubItems.Count - 1)
|
||||
return;
|
||||
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
parent.SubItems.Insert(index + 1, item);
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
this.RecalcLayout();
|
||||
}
|
||||
public void MoveItemUp()
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
ToolboxGroup item = (ToolboxGroup)this.Component;
|
||||
BaseItem parent = item.Parent;
|
||||
if (parent == null) return;
|
||||
int index = parent.SubItems.IndexOf(item);
|
||||
if (index == 0)
|
||||
return;
|
||||
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
parent.SubItems.Insert(index - 1, item);
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
public void CreateItem()
|
||||
{
|
||||
ToolboxGroup group = (ToolboxGroup)this.Component;
|
||||
ToolboxControl tc = group.GetToolboxControl();
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh == null)
|
||||
return;
|
||||
|
||||
ToolboxItem item = null;
|
||||
|
||||
IComponentChangeService change = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanging(this.Component, TypeDescriptor.GetProperties(group).Find("SubItems", true));
|
||||
}
|
||||
|
||||
item = dh.CreateComponent(typeof(ToolboxItem)) as ToolboxItem;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
item.Text = item.Name;
|
||||
item.Symbol = "\ue251";
|
||||
item.SymbolSet = eSymbolSet.Material;
|
||||
group.SubItems.Add(item);
|
||||
if (change != null)
|
||||
{
|
||||
change.OnComponentChanged(this.Component, TypeDescriptor.GetProperties(group).Find("Nodes", true), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
public override Control GetHostControl()
|
||||
{
|
||||
return GetParentControl().Parent;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ToolboxItemActionList
|
||||
internal class ToolboxGroupActionList : DesignerActionList
|
||||
{
|
||||
private ToolboxGroupDesigner _Designer = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AdvTreeActionList class.
|
||||
/// </summary>
|
||||
/// <param name="designer"></param>
|
||||
public ToolboxGroupActionList(ToolboxGroupDesigner designer)
|
||||
: base(designer.Component)
|
||||
{
|
||||
_Designer = designer;
|
||||
}
|
||||
|
||||
public override DesignerActionItemCollection GetSortedActionItems()
|
||||
{
|
||||
DesignerActionItemCollection items = new DesignerActionItemCollection();
|
||||
items.Add(new DesignerActionHeaderItem("Items"));
|
||||
items.Add(new DesignerActionHeaderItem("Position"));
|
||||
//items.Add(new DesignerActionHeaderItem("Selection"));
|
||||
|
||||
items.Add(new DesignerActionMethodItem(this, "CreateItem", "New Toolbox Item", "Items", true));
|
||||
items.Add(new DesignerActionMethodItem(this, "MoveItemUp", "Move Up", "Position", true));
|
||||
items.Add(new DesignerActionMethodItem(this, "MoveItemDown", "Move Down", "Position", true));
|
||||
//items.Add(new DesignerActionPropertyItem("CellEdit", "Allow node text editing?", "Nodes", "Indicates whether node cells are editable"));
|
||||
|
||||
//items.Add(new DesignerActionMethodItem(this, "EditColumns", "Edit Columns...", "Columns", "Edit Tree Control Columns", true));
|
||||
//items.Add(new DesignerActionPropertyItem("ColumnsVisible", "Column header visible?", "Columns", "Indicates whether tree column header is visible"));
|
||||
//items.Add(new DesignerActionPropertyItem("GridColumnLines", "Show grid column lines?", "Columns", "Indicates whether grid lines are visible"));
|
||||
//items.Add(new DesignerActionPropertyItem("GridRowLines", "Show grid row lines?", "Nodes", "Indicates whether grid lines between nodes are visible"));
|
||||
//items.Add(new DesignerActionPropertyItem("GridLinesColor", "Grid lines color:", "Columns", "Indicates custom color for grid lines"));
|
||||
|
||||
//items.Add(new DesignerActionPropertyItem("SelectionBox", "Show selection?", "Selection", "Indicates whether selection is shown for selected node"));
|
||||
//items.Add(new DesignerActionPropertyItem("SelectionBoxStyle", "Selection style:", "Selection", "Indicates selection style"));
|
||||
//items.Add(new DesignerActionPropertyItem("HotTracking", "Highlight mouse over node?", "Selection", "Indicates whether node that mouse is over is highlighted"));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public void CreateItem()
|
||||
{
|
||||
_Designer.CreateItem();
|
||||
}
|
||||
public void MoveItemUp()
|
||||
{
|
||||
_Designer.MoveItemUp();
|
||||
}
|
||||
|
||||
public void MoveItemDown()
|
||||
{
|
||||
_Designer.MoveItemDown();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
@@ -0,0 +1,291 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Windows.Forms.Design.Behavior;
|
||||
using DevComponents.AdvTree;
|
||||
using DevComponents.AdvTree.Design;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class ToolboxItemDesigner : ComponentDesignerWithAction
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the LayoutItemBaseDesigner class.
|
||||
/// </summary>
|
||||
public ToolboxItemDesigner()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation
|
||||
|
||||
public override void Initialize(System.ComponentModel.IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
|
||||
ToolboxItem item = (ToolboxItem)this.Component;
|
||||
item.Text = item.Name;
|
||||
item.Symbol = "\ue251";
|
||||
item.SymbolSet = eSymbolSet.Material;
|
||||
}
|
||||
|
||||
private DesignerActionListCollection _ActionLists = null;
|
||||
|
||||
public override DesignerActionListCollection ActionLists
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this._ActionLists == null)
|
||||
{
|
||||
this._ActionLists = new DesignerActionListCollection();
|
||||
this._ActionLists.Add(new ToolboxItemActionList(this));
|
||||
}
|
||||
return this._ActionLists;
|
||||
}
|
||||
}
|
||||
|
||||
public void MoveItemUp()
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
ToolboxItem item = (ToolboxItem)this.Component;
|
||||
BaseItem parent = item.Parent;
|
||||
if (parent == null) return;
|
||||
int index = parent.SubItems.IndexOf(item);
|
||||
if (index == 0)
|
||||
{
|
||||
// Move to previous group
|
||||
if (parent.Parent != null && parent.Parent.SubItems.IndexOf(parent) > 0)
|
||||
{
|
||||
int j = parent.Parent.SubItems.IndexOf(parent);
|
||||
for (int i = j; i >= 0; i--)
|
||||
{
|
||||
BaseItem previousItem = parent.Parent.SubItems[i];
|
||||
if (previousItem is ToolboxGroup && previousItem.Visible)
|
||||
{
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
cc.OnComponentChanging(parent.Parent, TypeDescriptor.GetProperties(parent.Parent)["SubItems"]);
|
||||
parent.Parent.SubItems.Add(item);
|
||||
cc.OnComponentChanged(parent.Parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
parent.SubItems.Insert(index - 1, item);
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
public override void RecalcLayout()
|
||||
{
|
||||
ToolboxItem item = this.Component as ToolboxItem;
|
||||
if (item != null && item.GetToolboxControl() != null)
|
||||
item.GetToolboxControl().RecalcLayout();
|
||||
}
|
||||
|
||||
public void MoveItemDown()
|
||||
{
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
ToolboxItem item = (ToolboxItem)this.Component;
|
||||
BaseItem parent = item.Parent;
|
||||
if (parent == null) return;
|
||||
int index = parent.SubItems.IndexOf(item);
|
||||
if (index == parent.SubItems.Count - 1)
|
||||
{
|
||||
// Move to next group
|
||||
if (parent.Parent != null && parent.Parent.SubItems.IndexOf(parent) < parent.Parent.SubItems.Count - 1)
|
||||
{
|
||||
int j = parent.Parent.SubItems.IndexOf(parent);
|
||||
for (int i = j; i < parent.Parent.SubItems.Count; i++)
|
||||
{
|
||||
BaseItem previousItem = parent.Parent.SubItems[i];
|
||||
if (previousItem is ToolboxGroup && previousItem.Visible)
|
||||
{
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
cc.OnComponentChanging(parent.Parent, TypeDescriptor.GetProperties(parent.Parent)["SubItems"]);
|
||||
parent.Parent.SubItems.Add(item);
|
||||
cc.OnComponentChanged(parent.Parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
parent.SubItems.Remove(item);
|
||||
parent.SubItems.Insert(index + 1, item);
|
||||
cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
//private void OnComponentRemoved(object sender, ComponentEventArgs e)
|
||||
//{
|
||||
// if (e.Component == this.Component)
|
||||
// {
|
||||
// ToolboxItem item = e.Component as ToolboxItem;
|
||||
// BaseItem parent = item.Parent;
|
||||
// Controls.ToolboxControl lc = item.GetToolboxControl();
|
||||
// if (parent != null)
|
||||
// {
|
||||
// IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
// if (cc != null)
|
||||
// cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["SubItems"]);
|
||||
// parent.SubItems.Remove(item);
|
||||
// if (cc != null)
|
||||
// cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["SubItems"], null, null);
|
||||
// if (lc != null)
|
||||
// {
|
||||
// lc.Invalidate();
|
||||
// IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
// if (host != null)
|
||||
// {
|
||||
// IDesigner designer = host.GetDesigner(lc);
|
||||
// if (designer is ToolboxControlDesigner)
|
||||
// {
|
||||
// ((ToolboxControlDesigner)designer).SelectionRefresh();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
protected override void OnDesignerSelectionChanged(bool isSelected)
|
||||
{
|
||||
ToolboxItem item = (ToolboxItem)this.Component;
|
||||
item.Checked = isSelected;
|
||||
base.OnDesignerSelectionChanged(isSelected);
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ToolboxItem item = this.Component as ToolboxItem;
|
||||
if (item.SubItems.Count == 0)
|
||||
return base.AssociatedComponents;
|
||||
ArrayList items = new ArrayList();
|
||||
item.SubItems.CopyTo(items);
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Visible"] = TypeDescriptor.CreateProperty(typeof(ToolboxItemDesigner),
|
||||
(PropertyDescriptor)properties["Visible"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Appearance")
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether item is visible.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Browsable(true), Category("Appearance"), Description("Indicates visiblity of the item.")]
|
||||
public bool Visible
|
||||
{
|
||||
get { return (bool)ShadowProperties["Visible"]; }
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control
|
||||
this.ShadowProperties["Visible"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override Control GetHostControl()
|
||||
{
|
||||
return GetParentControl().Parent;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
#region ToolboxItemActionList
|
||||
internal class ToolboxItemActionList : DesignerActionList
|
||||
{
|
||||
private ToolboxItemDesigner _Designer = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the AdvTreeActionList class.
|
||||
/// </summary>
|
||||
/// <param name="designer"></param>
|
||||
public ToolboxItemActionList(ToolboxItemDesigner designer)
|
||||
: base(designer.Component)
|
||||
{
|
||||
_Designer = designer;
|
||||
}
|
||||
|
||||
public override DesignerActionItemCollection GetSortedActionItems()
|
||||
{
|
||||
DesignerActionItemCollection items = new DesignerActionItemCollection();
|
||||
items.Add(new DesignerActionHeaderItem("Position"));
|
||||
//items.Add(new DesignerActionHeaderItem("Columns"));
|
||||
//items.Add(new DesignerActionHeaderItem("Selection"));
|
||||
|
||||
items.Add(new DesignerActionMethodItem(this, "MoveItemUp", "Move Up", "Position", true));
|
||||
items.Add(new DesignerActionMethodItem(this, "MoveItemDown", "Move Down", "Position", true));
|
||||
//items.Add(new DesignerActionPropertyItem("CellEdit", "Allow node text editing?", "Nodes", "Indicates whether node cells are editable"));
|
||||
|
||||
//items.Add(new DesignerActionMethodItem(this, "EditColumns", "Edit Columns...", "Columns", "Edit Tree Control Columns", true));
|
||||
//items.Add(new DesignerActionPropertyItem("ColumnsVisible", "Column header visible?", "Columns", "Indicates whether tree column header is visible"));
|
||||
//items.Add(new DesignerActionPropertyItem("GridColumnLines", "Show grid column lines?", "Columns", "Indicates whether grid lines are visible"));
|
||||
//items.Add(new DesignerActionPropertyItem("GridRowLines", "Show grid row lines?", "Nodes", "Indicates whether grid lines between nodes are visible"));
|
||||
//items.Add(new DesignerActionPropertyItem("GridLinesColor", "Grid lines color:", "Columns", "Indicates custom color for grid lines"));
|
||||
|
||||
//items.Add(new DesignerActionPropertyItem("SelectionBox", "Show selection?", "Selection", "Indicates whether selection is shown for selected node"));
|
||||
//items.Add(new DesignerActionPropertyItem("SelectionBoxStyle", "Selection style:", "Selection", "Indicates selection style"));
|
||||
//items.Add(new DesignerActionPropertyItem("HotTracking", "Highlight mouse over node?", "Selection", "Indicates whether node that mouse is over is highlighted"));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
public void MoveItemUp()
|
||||
{
|
||||
_Designer.MoveItemUp();
|
||||
}
|
||||
|
||||
public void MoveItemDown()
|
||||
{
|
||||
_Designer.MoveItemDown();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
Reference in New Issue
Block a user