private iconLabel createIcon(Type type) { Bitmap bmp = null; iconLabel icon = new iconLabel(); icon.Text = ""; icon.Tag = type; icon.ImageAlign = ContentAlignment.MiddleCenter; System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { bmp = (System.Drawing.Bitmap)tba.GetImage(type); } if (bmp != null) { icon.Image = bmp; } else { icon.Text = type.Name; } icon.Size = new Size(22, 22); icon.Click += new EventHandler(TypeIcons_Click); return(icon); }
protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter(e); for (int i = 0; i < this.Parent.Controls.Count; i++) { iconLabel l = this.Parent.Controls[i] as iconLabel; if (l != null) { l.BorderStyle = BorderStyle.None; l.Selected = false; } } this.BorderStyle = BorderStyle.Fixed3D; this.Selected = true; }
public void SetIconVisible(Type t, bool visible) { for (int i = 0; i < this.Controls.Count; i++) { iconLabel l = this.Controls[i] as iconLabel; if (l != null) { if (t.Equals(l.Tag)) { l.Visible = visible; break; } } } }
public bool Contains(Type type) { for (int i = 0; i < Controls.Count; i++) { iconLabel icon = Controls[i] as iconLabel; if (icon != null) { Type t = icon.Tag as Type; if (t.Equals(type)) { return(true); } } } return(false); }
public void LoadIcons() { if (!_iconsLoaded) { _iconsLoaded = true; Graphics g = this.CreateGraphics(); g.DrawString("Loading operators, please wait ,,,", this.Font, Brushes.Red, (float)10, (float)10); g.Dispose(); iconLabel[] lbls = new iconLabel[_types.Count]; for (int i = 0; i < _types.Count; i++) { Type type = _types[i] as Type; lbls[i] = createIcon(type); } this.Controls.AddRange(lbls); TypeIcons_Resize(null, null); } }