187 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			187 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
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
 | 
						|
}
 |