protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e) { Skybound.ComponentModel.EnumTypeEditor.EnumValue enumValue = e.Index == -1 ? null : Items[e.Index] as Skybound.ComponentModel.EnumTypeEditor.EnumValue; e.DrawBackground(); System.Drawing.Rectangle rectangle1 = e.Bounds; rectangle1.X++; rectangle1.Width -= 2; if (enumValue.Description.Length > 0) { rectangle1.Height >>= 1; } if (enumValue.Image != null) { e.Graphics.DrawImage(enumValue.Image, rectangle1.X + 3, rectangle1.Y + 2, enumValue.Image.Width, enumValue.Image.Height); rectangle1.X += enumValue.Image.Width + 8; rectangle1.Width -= enumValue.Image.Width + 8; } using (System.Drawing.Font font = new System.Drawing.Font(e.Font, CurrentValue == enumValue.Name ? System.Drawing.FontStyle.Bold : System.Drawing.FontStyle.Regular)) { Skybound.Windows.Forms.TextRenderer.DrawText(e.Graphics, enumValue.Name, font, e.ForeColor, System.Drawing.Color.Transparent, rectangle1, Skybound.Windows.Forms.TextFormatFlags.SingleLine | Skybound.Windows.Forms.TextFormatFlags.VerticalCenter); } if (enumValue.Description.Length > 0) { rectangle1.Y += rectangle1.Height; Skybound.Windows.Forms.TextRenderer.DrawText(e.Graphics, enumValue.Description, e.Font, System.Windows.Forms.ControlPaint.LightLight(e.ForeColor), System.Drawing.Color.Transparent, rectangle1, Skybound.Windows.Forms.TextFormatFlags.EndEllipsis | Skybound.Windows.Forms.TextFormatFlags.SingleLine | Skybound.Windows.Forms.TextFormatFlags.VerticalCenter); } System.Drawing.Rectangle rectangle2 = e.Bounds; System.Drawing.Rectangle rectangle3 = e.Bounds; System.Drawing.Rectangle rectangle4 = e.Bounds; System.Drawing.Rectangle rectangle5 = e.Bounds; e.Graphics.DrawLine(System.Drawing.SystemPens.Control, rectangle2.X, rectangle3.Bottom - 1, rectangle4.Right - 1, rectangle5.Bottom - 1); }
protected override void OnMeasureItem(System.Windows.Forms.MeasureItemEventArgs e) { Skybound.ComponentModel.EnumTypeEditor.EnumValue enumValue = e.Index == -1 ? null : Items[e.Index] as Skybound.ComponentModel.EnumTypeEditor.EnumValue; System.Drawing.Size size = enumValue.Measure(e.Graphics, Font); e.ItemWidth = size.Width; e.ItemHeight = size.Height; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { object obj; EditorService = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (EditorService != null) { System.Type type = value.GetType(); string[] sArr1 = System.Enum.GetNames(type); using (Skybound.ComponentModel.EnumTypeEditor.ResizableDropDown resizableDropDown = new Skybound.ComponentModel.EnumTypeEditor.ResizableDropDown()) using (Skybound.ComponentModel.EnumTypeEditor.EnumValueList enumValueList = new Skybound.ComponentModel.EnumTypeEditor.EnumValueList()) { enumValueList.CurrentValue = value.ToString(); resizableDropDown.Controls.Add(enumValueList); int i1 = 0, i2 = 0; using (System.Drawing.Graphics graphics = resizableDropDown.CreateGraphics()) { string[] sArr2 = sArr1; for (int i3 = 0; i3 < sArr2.Length; i3++) { string s = sArr2[i3]; Skybound.ComponentModel.EnumTypeEditor.EnumValue enumValue = GetEnumValue(context, type, s); enumValueList.Items.Add(enumValue); if (s == value.ToString()) { enumValueList.SelectedIndex = enumValueList.Items.Count - 1; } System.Drawing.Size size = enumValue.Measure(graphics, resizableDropDown.Font); i1 = System.Math.Max(i1, size.Width + 6 + System.Windows.Forms.SystemInformation.VerticalScrollBarWidth); i2 += size.Height; } } System.Drawing.Rectangle rectangle1 = System.Windows.Forms.Screen.PrimaryScreen.Bounds; if (i1 < (rectangle1.Width / 4)) { resizableDropDown.Width = i1; } else { resizableDropDown.Width = rectangle1.Width / 4; resizableDropDown.HasSizeGrip = true; i2 += 16; } resizableDropDown.Height = System.Math.Min(rectangle1.Height / 4, i2); System.Drawing.Rectangle rectangle2 = System.Windows.Forms.Screen.PrimaryScreen.Bounds; resizableDropDown.HasSizeGrip |= i2 > (rectangle2.Height / 4); enumValueList.MouseUp += new System.Windows.Forms.MouseEventHandler(list_MouseUp); EditorService.DropDownControl(resizableDropDown); return(enumValueList.SelectedItem == null ? value : System.Enum.Parse(type, (enumValueList.SelectedItem as Skybound.ComponentModel.EnumTypeEditor.EnumValue).Name, false)); } } return(base.EditValue(context, provider, value)); }