コード例 #1
0
 /// <summary>
 /// 编辑数据
 /// </summary>
 /// <param name="context">参数</param>
 /// <param name="provider">参数</param>
 /// <param name="Value">旧数值</param>
 /// <returns>新数值</returns>
 public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object Value)
 {
     if (provider == null)
     {
         return(Value);
     }
     System.Windows.Forms.Design.IWindowsFormsEditorService svc =
         (System.Windows.Forms.Design.IWindowsFormsEditorService)
         provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));
     if (svc == null)
     {
         return(Value);
     }
     using (dlgFormatDesigner dlg = new dlgFormatDesigner())
     {
         ValueFormater format = Value as ValueFormater;
         if (format == null)
         {
             format = new ValueFormater();
         }
         else
         {
             format = format.Clone();
         }
         dlg.InputFormater = format;
         if (svc.ShowDialog(dlg) == DialogResult.OK)
         {
             return(dlg.InputFormater);
         }
     }
     return(Value);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
ファイル: SequenceEditor.cs プロジェクト: tracer0707/OpenGLF
        public override Object EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value)
        {
            if ((context != null) && (provider != null))
            {
                System.Windows.Forms.Design.IWindowsFormsEditorService svc = (System.Windows.Forms.Design.IWindowsFormsEditorService)
                                                                             provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));

                if (svc != null)
                {
                    SequenceEditorWindow ipfrm = new SequenceEditorWindow((TextureList)value);
                    ipfrm.ShowDialog();
                }
            }
            return(base.EditValue(context, provider, value));
        }
コード例 #5
0
            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);
            }
コード例 #6
0
 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;
 }
コード例 #7
0
 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);
 }
コード例 #8
0
ファイル: CAttribute.cs プロジェクト: 372285834/GServer
 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);
 }
コード例 #9
0
        public override Object EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value)
        {
            if ((context != null) && (provider != null))
            {
                System.Windows.Forms.Design.IWindowsFormsEditorService svc = (System.Windows.Forms.Design.IWindowsFormsEditorService)
                                                                             provider.GetService(typeof(System.Windows.Forms.Design.IWindowsFormsEditorService));

                if (svc != null)
                {
                    if (value is ComponentList)
                    {
                        ComponentsEditorWindow ipfrm = new ComponentsEditorWindow((ComponentList)value);
                        ipfrm.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Окно компонентов для нескольких объектов сразу не доступно! Выберите один объект", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }

            return(base.EditValue(context, provider, value));
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 public void SetCaller(System.Windows.Forms.Design.IWindowsFormsEditorService wfe)
 {
 }