public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { try { System.Windows.Forms.Design.IWindowsFormsEditorService svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (svc != null) { if (value is string) { //RichTextBox box = new RichTextBox(); TextBox box = new TextBox(); box.AcceptsReturn = true; box.Multiline = true; box.Height = 120; box.BorderStyle = BorderStyle.None; box.Text = value as string; svc.DropDownControl(box); return(box.Text); } } } catch (System.Exception) { } return(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)); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null) { throw new System.ArgumentNullException("context"); } if (provider == null) { throw new System.ArgumentNullException("provider"); } System.Windows.Forms.Design.IWindowsFormsEditorService iwindowsFormsEditorService = provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)) as System.Windows.Forms.Design.IWindowsFormsEditorService; if (iwindowsFormsEditorService != null) { ListBoxControl listBoxControl = new ListBoxControl(iwindowsFormsEditorService); listBoxControl.Items.Add("None"); foreach (string s1 in enumFields) { listBoxControl.Items.Add(s1); } string s2 = (string)value; if (System.String.IsNullOrEmpty(s2)) { listBoxControl.SelectedIndex = 0; } else { listBoxControl.SelectedIndex = listBoxControl.FindString(s2); } iwindowsFormsEditorService.DropDownControl(listBoxControl); string s3 = System.String.Empty; int i = listBoxControl.SelectedIndex; if (i > 0) { s3 = listBoxControl.Items[i] as string; } return(s3); } return(value); }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { WinForms = provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)) as System.Windows.Forms.Design.IWindowsFormsEditorService; Skybound.VisualTips.VisualTip visualTip = value as Skybound.VisualTips.VisualTip; System.Windows.Forms.Control control = new System.Windows.Forms.Control(); if (visualTip.ShouldSerialize()) { Layout = visualTip.Provider.Renderer.CreateLayout(visualTip); Layout.Offset(8, 8); CurrentTip = visualTip; control.Size = Layout.GetSize() + (new System.Drawing.Size(16, 16)); control.Paint += new System.Windows.Forms.PaintEventHandler(OnDropDownPaint); control.MouseDown += new System.Windows.Forms.MouseEventHandler(OnDropDownMouseDown); } else { control.Size = new System.Drawing.Size(144, 28); control.Paint += new System.Windows.Forms.PaintEventHandler(OnEmptyDropDownPaint); } WinForms.DropDownControl(control); return value; }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value) { WinForms = provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)) as System.Windows.Forms.Design.IWindowsFormsEditorService; Skybound.VisualTips.VisualTip visualTip = value as Skybound.VisualTips.VisualTip; System.Windows.Forms.Control control = new System.Windows.Forms.Control(); if (visualTip.ShouldSerialize()) { Layout = visualTip.Provider.Renderer.CreateLayout(visualTip); Layout.Offset(8, 8); CurrentTip = visualTip; control.Size = Layout.GetSize() + (new System.Drawing.Size(16, 16)); control.Paint += new System.Windows.Forms.PaintEventHandler(OnDropDownPaint); control.MouseDown += new System.Windows.Forms.MouseEventHandler(OnDropDownMouseDown); } else { control.Size = new System.Drawing.Size(144, 28); control.Paint += new System.Windows.Forms.PaintEventHandler(OnEmptyDropDownPaint); } WinForms.DropDownControl(control); return(value); }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { System.Windows.Forms.Design.IWindowsFormsEditorService editorService = null; if (context != null && context.Instance != null && provider != null) { editorService = (System.Windows.Forms.Design.IWindowsFormsEditorService)provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService)); if (editorService != null) { var type = context.Instance.GetType(); var tMethod = type.GetMethod("GetdataSource"); ListBox comboBox = new ListBox(); comboBox.FormattingEnabled = true; comboBox.Name = "comboBox"; comboBox.Size = new System.Drawing.Size(100, 200); comboBox.DataSource = tMethod.Invoke(context.Instance, null); editorService.DropDownControl(comboBox); value = comboBox.SelectedItem; return(value); } } return(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); }