private void SelectTool(ToolboxTool tool)
 {
     if (selectedTab != null)
     {
         selectedTab.SelectTool(tool);
     }
 }
Exemple #2
0
        public void SetSelectedToolboxItem(ToolboxItem toolboxItem)
        {
            ToolboxTool tool = toolboxItem as ToolboxTool;

            if (tool != null)
            {
                SelectTool(tool);
            }
        }
Exemple #3
0
        public void SelectTool(ToolboxTool tool)
        {
            if (tool == null)
            {
                return;
            }

            if (tools.ContainsKey(tool))
            {
                ToolboxButton button = tools[tool];
                button.PerformClick();
            }
        }
Exemple #4
0
        private void OnItemAdded(ToolStripItem item)
        {
            ToolboxButton toolboxButton = null;

            if (!(item is ToolboxButton))
            {
                // We deny addition of non ToolboxButton buttons
                toolStrip.Items.Remove(item);
                return;
            }
            else
            {
                toolboxButton = (ToolboxButton)item;
            }

            ToolboxTool tool = toolboxButton.Tool;

            if (tool == null)
            {
                toolStrip.Items.Remove(item);
            }
            else if (tool is ToolboxPointer)
            {
                // We allow only one pointer per tab
                if (pointersCount > 1)
                {
                    toolStrip.Items.Remove(item);
                }
                else
                {
                    tools.Add(tool, toolboxButton);
                    pointersCount++;
                }
            }
            else if (tool is ToolboxTool)
            {
                if (!tools.ContainsKey(tool))
                {
                    tools.Add(tool, toolboxButton);
                }
            }
            else
            {
                toolStrip.Items.Remove(item);
            }
        }
Exemple #5
0
        public void AddTool(ToolboxTool tool, bool dragEnabled)
        {
            refreshLayout = false;
            ToolboxButton toolStripButton = new ToolboxButton();

            toolStripButton.Tool               = tool;
            toolStripButton.DragEnabled        = dragEnabled;
            toolStripButton.Text               = tool.DisplayName;
            toolStripButton.Image              = tool.Bitmap;
            toolStripButton.TextAlign          = System.Drawing.ContentAlignment.MiddleLeft;
            toolStripButton.ImageAlign         = System.Drawing.ContentAlignment.MiddleLeft;
            toolStripButton.Alignment          = ToolStripItemAlignment.Left;
            toolStripButton.DoubleClickEnabled = true;
            toolStripButton.Click             += new EventHandler(OnButtonClick);
            toolStripButton.DoubleClick       += new EventHandler(OnButtonDoubleClick);

            toolStrip.Items.Add(toolStripButton);
            refreshLayout = true;
        }
Exemple #6
0
        private void OnItemRemoved(ToolStripItem item)
        {
            ToolboxButton toolboxButton = null;

            if (!(item is ToolboxButton))
            {
                return;
            }
            else
            {
                toolboxButton = (ToolboxButton)item;
            }

            ToolboxTool tool = toolboxButton.Tool;

            if (tool == null)
            {
            }                     // It's ok, the item is removed
            else if (tool is ToolboxPointer)
            {
                // We don't allow the removal of the pointer tool
                if (pointersCount > 1)
                {
                    toolStrip.Items.Remove(item);
                    pointersCount--;
                }
                else
                {
                    AddPointer();
                }
            }
            else if (tool is ToolboxTool)
            {
                if (tools.ContainsKey(tool))
                {
                    tools.Remove(tool);
                }
            }
            else
            {
            }        // It's ok, the item is removed
        }
Exemple #7
0
        public ToolboxItem GetSelectedToolboxItem(IDesignerHost host)
        {
            ToolboxButton button = SelectedButton;

            if (button != null)
            {
                ToolboxTool tool = button.Tool;
                if (tool is ToolboxPointer)
                {
                    return(null);
                }
                else
                {
                    return(tool);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #8
0
        public ToolboxItem DeserializeToolboxItem(object serializedObject, IDesignerHost host)
        {
            DataObject dataObject = serializedObject as DataObject;

            if (dataObject == null)
            {
                return(null);
            }

            ToolboxTool tool = dataObject.GetData(typeof(ToolboxTool)) as ToolboxTool;

            if (tool == null)
            {
                ToolboxItem item = dataObject.GetData(typeof(ToolboxItem)) as ToolboxItem;
                return(item);
            }
            else
            {
                return(tool);
            }
        }
Exemple #9
0
 public void AddTool(ToolboxTool tool)
 {
     AddTool(tool, true);
 }
 private void SelectTool(ToolboxTool tool) { if (selectedTab != null) selectedTab.SelectTool(tool); }
 public void AddTool(ToolboxTool tool, bool dragEnabled)
 {
     refreshLayout = false;
     ToolboxButton toolStripButton = new ToolboxButton();
     toolStripButton.Tool = tool;
     toolStripButton.DragEnabled = dragEnabled;
     toolStripButton.Text = tool.DisplayName;
     toolStripButton.Image = tool.Bitmap;
     toolStripButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
     toolStripButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     toolStripButton.Alignment = ToolStripItemAlignment.Left;
     toolStripButton.DoubleClickEnabled = true;
     toolStripButton.Click += new EventHandler(OnButtonClick);
     toolStripButton.DoubleClick += new EventHandler(OnButtonDoubleClick);
     
     toolStrip.Items.Add(toolStripButton);            
     refreshLayout = true;
 }
 public void AddTool(ToolboxTool tool) { AddTool(tool, true); }
        public void SelectTool(ToolboxTool tool)
        {
            if (tool == null) return;

            if (tools.ContainsKey(tool))
            {
                ToolboxButton button = tools[tool];
                button.PerformClick();
            }
        }