Esempio n. 1
0
 private void OnButtonSelected(object sender, EventArgs e)
 {
     selectedButton = sender as ToolboxButton;
     if (SelectedButtonChanged != null)
     {
         SelectedButtonChanged(this, new ToolboxButtonEventArgs(selectedButton));
     }
 }
Esempio n. 2
0
        public void SelectTool(ToolboxTool tool)
        {
            if (tool == null)
            {
                return;
            }

            if (tools.ContainsKey(tool))
            {
                ToolboxButton button = tools[tool];
                button.PerformClick();
            }
        }
        private void OnButtonDoubleClick(object sender, ToolboxButtonEventArgs e)
        {
            ToolboxButton button = e.Button;

            if (button != null)
            {
                button.Checked = true;
            }
            if (lastCheckedButton != button)
            {
                lastCheckedButton.Checked = false;
            }
            pnlMain.Focus();
        }
Esempio n. 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);
            }
        }
Esempio n. 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;
        }
Esempio n. 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
        }
Esempio n. 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);
            }
        }
Esempio n. 8
0
 public ToolboxButtonEventArgs(ToolboxButton tbb) : base()
 {
     button = tbb;
 }