Example #1
0
 private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
 {
     e.DrawBackground();
     if (e.Index >= 0)
     {
         if ((e.State & DrawItemState.Selected) != 0)
         {
             e.DrawFocusRectangle();
         }
         string sName = listBox1.Items[e.Index] as string;
         Type   t     = _types[sName];
         Image  img;
         if (!imgs.TryGetValue(t, out img))
         {
             img = VPLUtil.GetTypeIcon(t);
             imgs.Add(t, img);
         }
         System.Drawing.Rectangle rc = new System.Drawing.Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
         e.Graphics.DrawImage(img, rc.X, rc.Y);
         rc.X += 16;
         if (rc.Width > 16)
         {
             rc.Width -= 16;
         }
         e.Graphics.DrawString(sName, this.Font, Brushes.Black, rc);
     }
 }
        void _button_Click(object sender, EventArgs e)
        {
            ContextMenu cm = new ContextMenu();
            Dictionary <string, Type> jsTypes = WebClientData.GetJavascriptTypes();

            foreach (KeyValuePair <string, Type> kv in jsTypes)
            {
                Image img             = VPLUtil.GetTypeIcon(kv.Value);
                MenuItemWithBitmap mi = new MenuItemWithBitmap(kv.Key, mi_click, img);
                mi.Tag = kv.Value;
                cm.MenuItems.Add(mi);
            }
            cm.Show(dataGridView1, _button.Location);
        }
Example #3
0
            public TypeList(IWindowsFormsEditorService service, Type t)
            {
                this.DrawMode = DrawMode.OwnerDrawFixed;
                _service      = service;
                Dictionary <string, Type> types = WebPhpData.GetPhpTypes();

                foreach (KeyValuePair <string, Type> kv in types)
                {
                    int n = Items.Add(new NamedImage(kv.Key, kv.Value, VPLUtil.GetTypeIcon(kv.Value)));
                    if (t != null && t.Equals(kv.Value))
                    {
                        this.SelectedIndex = n;
                    }
                }
            }