Exemple #1
0
 public void OnItemClick(ToolboxButton item)
 {
     if (item.IsToggle)
     {
         item.IsToggled = !item.IsToggled;
     }
     else
     {
         itemsCahche = GetComponentsInChildrenFirstLevel <ToolboxButton> ();
         for (int i = 0; i < itemsCahche.Length; i++)
         {
             if (itemsCahche [i].GetType() == typeof(ToolboxButton))
             {
                 ((ToolboxButton)itemsCahche [i]).IsSelected = false;
             }
         }
         item.IsSelected = true;
     }
 }
 public ToolboxButtonEventArgs(ToolboxButton tbb) : base() { button = tbb; }
 private void OnButtonClick(object sender, ToolboxButtonEventArgs e)
 {
     if (lastCheckedButton != null) lastCheckedButton.Checked = false;
     ToolboxButton button = e.Button;
     if (button != null)
     {
     button.Checked = true;
     lastCheckedButton = button;
     }
     pnlMain.Focus();
 }
 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 OnButtonSelected(object sender, EventArgs e)
 {
     selectedButton = sender as ToolboxButton;
     if (SelectedButtonChanged != null) SelectedButtonChanged(this, new ToolboxButtonEventArgs(selectedButton));
 }