/// <summary> /// Builder /// </summary> /// <param name="tools">List of tools to display in the panel</param> /// <param name="settings">Configuration of the group for the visual part</param> public ToolGroupPanel(List <Tool> tools, CategoryColorSettings settings) { InitializeComponent(); this.BackColor = settings.BackColor; this.borderColor = settings.ActionButtonOverColor; //To avoid the effect of the button being selected this.SetStyle(ControlStyles.UserPaint, true); //Shows 1 button for each tool for (int i = 0; i < tools.Count; i++) { ToolButton button = new ToolButton(tools[i], settings); button.InitInsert += new ToolEventHandler(Button_InitInsert); button.DoInsert += new PointEventHandler(Button_DoInsert); button.CancelInsert += new EventHandler(Button_CancelInsert); button.MouseEnter += new EventHandler(Button_MouseEnter); button.MouseLeave += new EventHandler(Button_MouseLeave); button.Location = new Point(INIT_X, INIT_Y + (i * ToolPanel.BUTTON_SEPARATION)); button.Size = new Size(BUTTON_WIDTH, button.Height); this.toolTip.SetToolTip(button, tools[i].ToolTipText); this.Controls.Add(button); } //The size of the panel is dynamically calculated this.Size = new Size(this.Width, INIT_Y + 3 + (tools.Count * ToolPanel.BUTTON_SEPARATION)); }
/// <summary> /// Group Panel Builder /// </summary> /// <param name="category">Group to which it represents</param> /// <param name="tools">List of actions of the group</param> /// <param name="parentLocation">Location of the container</param> public ToolPanel(Category category, List <Tool> tools, Point parentLocation) { InitializeComponent(); this.BackColor = category.GuiSetting.BackColor; this.borderColor = category.GuiSetting.BorderColor; //The category title and background color are set this.lCategory.Text = category.Label; this.lCategory.BackColor = category.GuiSetting.BorderColor; //To avoid the focus effect this.SetStyle(ControlStyles.UserPaint, true); //The position of the container is saved this.parentLocation = parentLocation; //The action buttons are created int toolLevel1Counter = 0; Hashtable groupButtons = new Hashtable(); foreach (Tool tool in tools) { //Check whether the action should be contained in a group Group group = Group.GetGroup(tool.Group); if (group == null) { //A normal tool button is created ToolButton toolButton = new ToolButton(tool, category.GuiSetting); toolButton.InitInsert += new ToolEventHandler(toolButton_InitInsert); toolButton.DoInsert += new PointEventHandler(toolButton_DoInsert); toolButton.CancelInsert += new EventHandler(toolButton_CancelInsert); toolButton.Location = new Point(INIT_X, INIT_Y + (toolLevel1Counter * BUTTON_SEPARATION)); this.toolTip.SetToolTip(toolButton, tool.ToolTipText); this.Controls.Add(toolButton); toolLevel1Counter++; } else { //Check if the group button already exists ToolGroupButton groupButton = (ToolGroupButton)groupButtons[group]; if (groupButton == null) { //Creates a new button group and is saved so that it does not create two equal groupButton = new ToolGroupButton(group, category.GuiSetting); groupButtons.Add(group, groupButton); groupButton.InitInsert += new ToolEventHandler(toolButton_InitInsert); groupButton.DoInsert += new PointEventHandler(toolButton_DoInsert); groupButton.CancelInsert += new EventHandler(toolButton_CancelInsert); groupButton.ShowPanel += new GroupPanelEventHandler(button_ShowPanel); groupButton.ClosePanel += new EventHandler(button_ClosePanel); //The tool is added to the group groupButton.AddTool(tool); groupButton.Location = new Point(INIT_X, INIT_Y + (toolLevel1Counter * BUTTON_SEPARATION)); this.toolTip.SetToolTip(groupButton, group.ToolTipText); this.Controls.Add(groupButton); toolLevel1Counter++; } else { //A new action is added to the group button groupButton.AddTool(tool); } } } this.Size = new Size(this.Width, INIT_Y + 3 + (toolLevel1Counter * BUTTON_SEPARATION)); }