Beispiel #1
0
            public override void PaintValue(PaintValueEventArgs e)
            {
                base.PaintValue(e);
                string s = e.Value as string;

                if (s != null)
                {
                    EntityColor color;
                    if (!EntityColor.TryParse(s, out color))
                    {
                        return;
                    }
                    using (Brush brush = (Brush) new SolidBrush((System.Drawing.Color)color.ToArgbColor(DxfIndexedColorSet.AcadClassicIndexedColors)))
                        e.Graphics.FillRectangle(brush, e.Bounds);
                }
                else
                {
                    if (!(e.Value is EntityColor))
                    {
                        return;
                    }
                    using (Brush brush = (Brush) new SolidBrush((System.Drawing.Color)((EntityColor)e.Value).ToArgbColor(DxfIndexedColorSet.AcadClassicIndexedColors)))
                        e.Graphics.FillRectangle(brush, e.Bounds);
                }
            }
Beispiel #2
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);
        }
Beispiel #3
0
        public static ArgbColor GetColor(
            WW.Cad.Model.Color color,
            EntityColor byBlockColor,
            DxfColor byBlockDxfColor,
            DxfLayer layer)
        {
            switch (color.ColorType)
            {
            case ColorType.ByLayer:
                if (layer != null)
                {
                    return(layer.Color.ToArgbColor());
                }
                return(ArgbColors.White);

            case ColorType.ByBlock:
                if (byBlockDxfColor != null)
                {
                    return(byBlockDxfColor.Color.ToArgbColor());
                }
                return(byBlockColor.ToArgbColor());

            case ColorType.ByColor:
            case ColorType.ByColorIndex:
            case ColorType.ByPenIndex:
            case ColorType.Foreground:
                return(color.ToArgbColor());

            default:
                return(DxfIndexedColor.Color[0]);
            }
        }
Beispiel #4
0
 public DxfMeshFace(EntityColor color, DxfVertex3D v1, DxfVertex3D v2, DxfVertex3D v3)
 {
     this.Color = color;
     this.list_0.Add(new DxfMeshFace.Corner(v1));
     this.list_0.Add(new DxfMeshFace.Corner(v2));
     this.list_0.Add(new DxfMeshFace.Corner(v3));
 }
Beispiel #5
0
 public Dxf3DFace(EntityColor color, WW.Math.Point3D p1, WW.Math.Point3D p2, WW.Math.Point3D p3)
 {
     this.Color = color;
     this.list_0.Add(p1);
     this.list_0.Add(p2);
     this.list_0.Add(p3);
 }
Beispiel #6
0
        public static bool TryParse(string s, out EntityColor color)
        {
            color = EntityColor.None;
            if (string.IsNullOrEmpty(s))
            {
                return(true);
            }
            if (string.Compare(s, "by layer", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                color = EntityColor.ByLayer;
                return(true);
            }
            if (string.Compare(s, "by block", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                color = EntityColor.ByBlock;
                return(true);
            }
            if (string.Compare(s, "none", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                color = EntityColor.None;
                return(true);
            }
            if (string.Compare(s, "foreground", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                color = EntityColor.smethod_0(3305111552U);
                return(true);
            }
            Dictionary <string, string> properties = StringUtil.GetProperties(s);
            string    s1;
            ColorType result1;

            if (!properties.TryGetValue("color type", out s1) || !EnumUtil.TryParse <ColorType>(s1, true, out result1))
            {
                return(false);
            }
            switch (result1)
            {
            case ColorType.ByColor:
                string s2;
                int    result2;
                if (!properties.TryGetValue("rgb", out s2) || !int.TryParse(s2, NumberStyles.HexNumber, (IFormatProvider)CultureInfo.InvariantCulture, out result2))
                {
                    return(false);
                }
                color = EntityColor.CreateFromRgb(result2);
                break;

            case ColorType.ByColorIndex:
                string s3;
                short  result3;
                if (!properties.TryGetValue("index", out s3) || !short.TryParse(s3, out result3))
                {
                    return(false);
                }
                color = EntityColor.CreateFromColorIndex(result3);
                break;
            }
            return(true);
        }
Beispiel #7
0
 public static EntityColor CreateFromColorIndex(ColorType colorType, short colorIndex)
 {
     if (colorType == ColorType.ByColorIndex)
     {
         return(EntityColor.CreateFromColorIndex(colorIndex));
     }
     return(new EntityColor((uint)colorType << 24 | (uint)colorIndex));
 }
Beispiel #8
0
        public static EntityColor CreateFrom(ArgbColor color)
        {
            int   colorDifference;
            short colorIndex = DxfIndexedColorSet.GetColorIndex(color, out colorDifference);

            if (colorDifference != 0)
            {
                return(EntityColor.CreateFromRgb(color.Argb));
            }
            return(EntityColor.CreateFromColorIndex(colorIndex));
        }
Beispiel #9
0
 public Dxf3DFace(EntityColor color, IList <WW.Math.Point3D> points)
 {
     if (points.Count < 3 || points.Count > 4)
     {
         throw new ArgumentException("Points must contain 3 or 4 points, count is " + (object)points.Count);
     }
     this.Color = color;
     for (int index = 0; index < points.Count; ++index)
     {
         this.list_0.Add(points[index]);
     }
 }
Beispiel #10
0
 internal void method_12(DxfEntity from)
 {
     this.Layer          = from.Layer;
     this.entityColor_0  = from.entityColor_0;
     this.transparency_0 = from.transparency_0;
     this.DxfColor       = from.DxfColor;
     this.LineType       = from.LineType;
     this.double_0       = from.double_0;
     this.short_0        = from.short_0;
     this.bool_0         = from.bool_0;
     this.bool_1         = from.bool_1;
 }
Beispiel #11
0
            public override object ConvertFrom(
                ITypeDescriptorContext context,
                CultureInfo culture,
                object value)
            {
                string      s = value as string;
                EntityColor color;

                if (s != null && EntityColor.TryParse(s, out color))
                {
                    return((object)color);
                }
                return(value);
            }
Beispiel #12
0
        public override void CopyFrom(DxfHandledObject from, CloneContext cloneContext)
        {
            base.CopyFrom(from, cloneContext);
            DxfEntity dxfEntity = (DxfEntity)from;

            this.Layer          = Class906.GetLayer(cloneContext, dxfEntity.Layer);
            this.entityColor_0  = dxfEntity.entityColor_0;
            this.transparency_0 = dxfEntity.transparency_0;
            this.DxfColor       = Class906.smethod_10(cloneContext, dxfEntity.DxfColor);
            this.LineType       = Class906.GetLineType(cloneContext, dxfEntity.LineType);
            this.double_0       = dxfEntity.double_0;
            this.short_0        = dxfEntity.short_0;
            this.bool_0         = dxfEntity.bool_0;
            this.bool_1         = dxfEntity.bool_1;
        }
Beispiel #13
0
 public DxfMeshFace(EntityColor color, params DxfMeshFace.Corner[] corners)
 {
     if (corners == null)
     {
         throw new ArgumentException("corners may not be null.");
     }
     if (corners.Length == 0)
     {
         throw new ArgumentException("corners must contain more than 0 vertices.");
     }
     if (corners.Length > 4)
     {
         throw new ArgumentException("corners may not contain more than 4 vertices.");
     }
     this.Color = color;
     this.list_0.AddRange((IEnumerable <DxfMeshFace.Corner>)corners);
 }
Beispiel #14
0
 public DxfMeshFace(EntityColor color, params DxfVertex3D[] cornerVertices)
 {
     if (cornerVertices == null)
     {
         throw new ArgumentException("cornerVertices may not be null.");
     }
     if (cornerVertices.Length == 0)
     {
         throw new ArgumentException("cornerVertices must contain more than 0 vertices.");
     }
     if (cornerVertices.Length > 4)
     {
         throw new ArgumentException("cornerVertices may not contain more than 4 vertices.");
     }
     this.Color = color;
     for (int index = 0; index < cornerVertices.Length; ++index)
     {
         this.list_0.Add(new DxfMeshFace.Corner(cornerVertices[index]));
     }
 }
Beispiel #15
0
 public bool Equals(EntityColor other)
 {
     return((int)this.uint_0 == (int)other.uint_0);
 }
Beispiel #16
0
            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);
            }
Beispiel #17
0
 public DxfLine(EntityColor color, WW.Math.Point2D start, WW.Math.Point2D end)
 {
     this.Color     = color;
     this.point3D_0 = (WW.Math.Point3D)start;
     this.point3D_1 = (WW.Math.Point3D)end;
 }
Beispiel #18
0
 public DxfPolyline2D(EntityColor color, params WW.Math.Point2D[] vertices)
     : this(color)
 {
     this.dxfVertex2DCollection_0.AddRange(vertices);
 }
Beispiel #19
0
 public DxfPolyline3D(EntityColor color, IEnumerable <WW.Math.Point3D> vertices)
 {
     this.Color = color;
     this.dxfVertex3DCollection_0.AddRange(vertices);
 }
Beispiel #20
0
 public DxfPolyline3D(EntityColor color, params DxfVertex3D[] vertices)
 {
     this.Color = color;
     this.dxfVertex3DCollection_0.AddRange((IEnumerable <DxfVertex3D>)vertices);
 }
Beispiel #21
0
 public DxfMeshFace(EntityColor color, DxfVertex3D v)
 {
     this.Color = color;
     this.list_0.Add(new DxfMeshFace.Corner(v));
 }
Beispiel #22
0
 public DxfPolyfaceMesh(EntityColor color)
 {
     this.Color = color;
 }
Beispiel #23
0
 public DxfPoint(EntityColor color, double x, double y, double z)
 {
     this.point3D_0 = new WW.Math.Point3D(x, y, z);
     this.Color     = color;
 }
Beispiel #24
0
 public DxfPolyline3D(EntityColor color)
 {
     this.Color = color;
 }
Beispiel #25
0
 public DxfPoint(EntityColor color, double x, double y)
 {
     this.Color     = color;
     this.point3D_0 = new WW.Math.Point3D(x, y, 0.0);
 }
Beispiel #26
0
 public DxfPolyline3D(EntityColor color, params WW.Math.Point3D[] vertices)
 {
     this.Color = color;
     this.dxfVertex3DCollection_0.AddRange(vertices);
 }
Beispiel #27
0
 public DxfPoint(EntityColor color, WW.Math.Point2D position)
 {
     this.point3D_0 = (WW.Math.Point3D)position;
     this.Color     = color;
 }
Beispiel #28
0
 public DxfCircle(EntityColor color, WW.Math.Point2D center, double radius)
 {
     this.Color     = color;
     this.point3D_0 = (WW.Math.Point3D)center;
     this.double_1  = radius;
 }
Beispiel #29
0
 public DxfPolyline2D(EntityColor color, IEnumerable <WW.Math.Point2D> vertices)
     : this(color)
 {
     this.dxfVertex2DCollection_0.AddRange(vertices);
 }