예제 #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 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);
        }
예제 #3
0
파일: EntityColor.cs 프로젝트: 15831944/WW
 public static EntityColor CreateFromColorIndex(ColorType colorType, short colorIndex)
 {
     if (colorType == ColorType.ByColorIndex)
     {
         return(EntityColor.CreateFromColorIndex(colorIndex));
     }
     return(new EntityColor((uint)colorType << 24 | (uint)colorIndex));
 }
예제 #4
0
파일: EntityColor.cs 프로젝트: 15831944/WW
        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));
        }