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)); }
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); }