private void OnButtonSelected(object sender, EventArgs e) { selectedButton = sender as ToolboxButton; if (SelectedButtonChanged != null) { SelectedButtonChanged(this, new ToolboxButtonEventArgs(selectedButton)); } }
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(); }
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); } }
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; }
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 }
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); } }
public ToolboxButtonEventArgs(ToolboxButton tbb) : base() { button = tbb; }