public PanelIcon AddIcon(string caption, Image imgPanel, Image imgDrag, Object IconData, EventHandler onClickEvent, PanelIcon.DoubleClickIconEvent onDoubleClickEvent) { int index = Controls.Count / 2; // two entries per icon if (imgPanel == null) { throw new System.Exception("The image associated with the icon '" + caption + "' is not defined."); } if (imgDrag == null) { throw new System.Exception("The drag image associated with the icon '" + caption + "' is not defined."); } if (IconData == null) { throw new System.Exception("The IconData associated with the icon '" + caption + "' is not defined."); } PanelIcon panelIcon = new PanelIcon(this, imgPanel, imgDrag, index, IconData, onClickEvent, onDoubleClickEvent); Controls.Add(panelIcon); Label label = new Label(); label.Text = caption; label.Visible = true; label.Location = new Point(0, margin + imgPanel.Size.Height + index * iconSpacing); label.Size = new Size(Size.Width, 15); label.TextAlign = ContentAlignment.TopCenter; label.Click += onClickEvent; label.Tag = panelIcon; Controls.Add(label); return(panelIcon); }
public PanelIcon AddIcon(string caption, Image imgPanel, Image imgDrag, Object IconData, EventHandler onClickEvent, PanelIcon.DoubleClickIconEvent onDoubleClickEvent) { int index=Controls.Count/2; // two entries per icon if(imgPanel == null) throw new System.Exception("The image associated with the icon '" + caption + "' is not defined."); if(imgDrag == null) throw new System.Exception("The drag image associated with the icon '" + caption + "' is not defined."); if(IconData == null) throw new System.Exception("The IconData associated with the icon '" + caption + "' is not defined."); PanelIcon panelIcon=new PanelIcon(this, imgPanel, imgDrag, index, IconData, onClickEvent, onDoubleClickEvent); Controls.Add(panelIcon); Label label=new Label(); label.Text=caption; label.Visible=true; label.Location=new Point(0, margin+imgPanel.Size.Height+index*iconSpacing); label.Size=new Size(Size.Width, 15); label.TextAlign=ContentAlignment.TopCenter; label.Click+=onClickEvent; label.Tag=panelIcon; Controls.Add(label); return panelIcon; }