コード例 #1
0
        public EntityColor GetEntityColor(DrawContext context)
        {
            EntityColor entityColor;

            if (this.DxfColor == null)
            {
                if (this.entityColor_0 == EntityColor.ByBlock)
                {
                    entityColor = context.ByBlockDxfColor == null ? context.ByBlockColor : EntityColor.CreateFrom(context.ByBlockDxfColor.Color);
                }
                else if (this.entityColor_0 == EntityColor.ByLayer)
                {
                    DxfLayer layer = this.GetLayer(context);
                    entityColor = layer == null?EntityColor.CreateFromColorIndex((short)7) : EntityColor.CreateFrom(layer.GetColor(context.Viewport));
                }
                else
                {
                    entityColor = this.Color;
                }
            }
            else
            {
                entityColor = EntityColor.CreateFrom(this.DxfColor.Color);
            }
            return(entityColor);
        }
コード例 #2
0
ファイル: EntityColor.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 EntityColor || value == null))
                    {
                        EntityColor color   = value == null ? EntityColor.None : (EntityColor)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 (EntityColor standardColor in EntityColor.TypeConverter.StandardColors)
                        {
                            if (standardColor == color)
                            {
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            EntityColor.UITypeEditor.ColorItem colorItem = new EntityColor.UITypeEditor.ColorItem()
                            {
                                Color = color
                            };
                            listBox.Items.Add((object)colorItem);
                        }
                        foreach (EntityColor standardColor in EntityColor.TypeConverter.StandardColors)
                        {
                            EntityColor.UITypeEditor.ColorItem colorItem = new EntityColor.UITypeEditor.ColorItem()
                            {
                                Color = standardColor
                            };
                            listBox.Items.Add((object)colorItem);
                        }
                        EntityColor.UITypeEditor.ColorItem colorItem1 = new EntityColor.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 ((EntityColor.UITypeEditor.ColorItem)listBox.SelectedItem == colorItem1)
                            {
                                CadColorEditorDialog colorEditorDialog = new CadColorEditorDialog();
                                if (value != null)
                                {
                                    colorEditorDialog.Color = WW.Cad.Model.Color.CreateFrom(color);
                                }
                                colorEditorDialog.ShowColorBookTab = false;
                                if (this.iwindowsFormsEditorService_0.ShowDialog((Form)colorEditorDialog) == DialogResult.OK)
                                {
                                    obj = (object)EntityColor.CreateFrom(colorEditorDialog.Color);
                                }
                            }
                            else
                            {
                                obj = (object)((EntityColor.UITypeEditor.ColorItem)listBox.SelectedItem).Color;
                            }
                        }
                    }
                }
                return(obj);
            }