using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using ICSharpCode.Core; using Mesnac.Gui.Workbench; using Mesnac.PlugIn.Pad; namespace Mesnac.Gui.Edit.Pad { public partial class EventWindow : DefaultPadContent { public EventWindow() { InitializeComponent(); } public PropertyGridEx.PropertyGridEx PropertyGrid { get { return this.propertyGridEx1; } } public ComboBox CmbControls { get { return this.comboBox1; } } private void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { ComboBox cmbControls = sender as ComboBox; if (e.Index < 0 || e.Index >= cmbControls.Items.Count) { return; } Graphics g = e.Graphics; Brush stringColor = SystemBrushes.ControlText; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { if ((e.State & DrawItemState.Focus) == DrawItemState.Focus) { g.FillRectangle(SystemBrushes.Highlight, e.Bounds); stringColor = SystemBrushes.HighlightText; } else { g.FillRectangle(SystemBrushes.Window, e.Bounds); } } else { g.FillRectangle(SystemBrushes.Window, e.Bounds); } object item = cmbControls.Items[e.Index]; int xPos = e.Bounds.X; if (item is IComponent) { ISite site = ((IComponent)item).Site; if (site != null) { string name = site.Name; using (Font f = new Font(cmbControls.Font, FontStyle.Bold)) { g.DrawString(name, f, stringColor, xPos, e.Bounds.Y); xPos += (int)g.MeasureString(name + "-", f).Width; } } } string typeString = item.GetType().ToString(); g.DrawString(typeString, cmbControls.Font, stringColor, xPos, e.Bounds.Y); } private void EventWindow_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; this.Hide(); } } }