コード例 #1
0
ファイル: Color.cs プロジェクト: 15831944/WW
            private void method_0(object sender, DrawItemEventArgs e)
            {
                Color.UITypeEditor.ColorItem colorItem = (Color.UITypeEditor.ColorItem)((ListBox)sender).Items[e.Index];
                e.DrawBackground();
                int x      = e.Bounds.Left + 1;
                int y      = e.Bounds.Top + 1;
                int width  = e.Bounds.Height - 2 + 4;
                int height = e.Bounds.Height - 2;

                if (colorItem.Color.ColorType == ColorType.ByColorIndex && colorItem.Color.ColorIndex == (short)7)
                {
                    e.Graphics.FillPolygon(Brushes.Black, new Point[3]
                    {
                        new Point(x, y),
                        new Point(x + width, y),
                        new Point(x, y + height)
                    });
                    e.Graphics.FillPolygon(Brushes.White, new Point[3]
                    {
                        new Point(x, y + height),
                        new Point(x + width, y),
                        new Point(x + width, y + height)
                    });
                    e.Graphics.DrawRectangle(Pens.Black, x, y, width, height);
                }
                else
                {
                    using (Brush brush = (Brush) new SolidBrush((System.Drawing.Color)colorItem.Color.ToArgbColor(DxfIndexedColorSet.AcadClassicIndexedColors)))
                        e.Graphics.FillRectangle(brush, x, y, width, height);
                }
                e.Graphics.DrawString(colorItem.ToString(), SystemFonts.DefaultFont, SystemBrushes.ControlText, new RectangleF((float)(x + width + 3), (float)e.Bounds.Top, (float)(e.Bounds.Right - (x + width) - 3), (float)e.Bounds.Height));
                e.DrawFocusRectangle();
            }
コード例 #2
0
ファイル: Color.cs プロジェクト: 15831944/WW
            public override object EditValue(
                ITypeDescriptorContext context,
                System.IServiceProvider provider,
                object value)
            {
                object obj = value;

                if (provider != null)
                {
                    this.iwindowsFormsEditorService_0 = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    if (this.iwindowsFormsEditorService_0 != null && (value is Color || value == null))
                    {
                        Color   color   = value == null ? Color.None : (Color)value;
                        ListBox listBox = new ListBox();
                        listBox.Click    += new EventHandler(this.method_1);
                        listBox.DrawMode  = DrawMode.OwnerDrawFixed;
                        listBox.DrawItem += new DrawItemEventHandler(this.method_0);
                        listBox.Size      = new Size(220, 150);
                        bool flag = false;
                        foreach (Color standardColor in Color.TypeConverter.StandardColors)
                        {
                            if (standardColor == color)
                            {
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            Color.UITypeEditor.ColorItem colorItem = new Color.UITypeEditor.ColorItem()
                            {
                                Color = color
                            };
                            listBox.Items.Add((object)colorItem);
                        }
                        foreach (Color standardColor in Color.TypeConverter.StandardColors)
                        {
                            Color.UITypeEditor.ColorItem colorItem = new Color.UITypeEditor.ColorItem()
                            {
                                Color = standardColor
                            };
                            listBox.Items.Add((object)colorItem);
                        }
                        Color.UITypeEditor.ColorItem colorItem1 = new Color.UITypeEditor.ColorItem()
                        {
                            Name = Class675.Other
                        };
                        listBox.Items.Add((object)colorItem1);
                        this.iwindowsFormsEditorService_0.DropDownControl((Control)listBox);
                        if (listBox.SelectedItem != null && listBox.SelectedIndices.Count == 1)
                        {
                            if ((Color.UITypeEditor.ColorItem)listBox.SelectedItem == colorItem1)
                            {
                                CadColorEditorDialog colorEditorDialog = new CadColorEditorDialog();
                                if (value != null)
                                {
                                    colorEditorDialog.Color = color;
                                }
                                if (this.iwindowsFormsEditorService_0.ShowDialog((Form)colorEditorDialog) == DialogResult.OK)
                                {
                                    obj = (object)colorEditorDialog.Color;
                                }
                            }
                            else
                            {
                                obj = (object)((Color.UITypeEditor.ColorItem)listBox.SelectedItem).Color;
                            }
                        }
                    }
                }
                return(obj);
            }