Ejemplo n.º 1
0
		/*Draw Point*/
		public static void DrawPoint(netDxf.Entities.Point xPoint, Canvas mainCanvas)
		{
			double size = 15.0;
			AciColor myColor = xPoint.getColor();
			Canvas canvas1 = DrawUtils.GetPoint(TypeConverter.ToMediaColor(myColor.ToColor()), size, 0);
			getMaxPt(xPoint.Position);
			Canvas.SetLeft(canvas1, xPoint.Position.X - size);
			Canvas.SetTop(canvas1, mainCanvas.Height - (xPoint.Position.Y + size));
			mainCanvas.Children.Add(canvas1);

		}
        public static void Entity2Shape(netDxf.Entities.EntityObject xEntity, System.Windows.Shapes.Shape wShape)
        {
            double dThickness = xEntity.getLineweightValue();
            double dScale     = xEntity.LinetypeScale;

            /* By Block */
            if (dThickness == -2)
            {
                dThickness = xEntity.Owner.Layer.getLineweightValue();
            }
            if (dScale == -2)
            {
                dScale = 1;
            }


            /* By Default */
            if (dThickness == -3)
            {
                dThickness = defaultThickness;
            }
            if (dScale == -3)
            {
                dScale = 1;
            }

            /*Debug.WriteLine("dThickness="+dThickness);*/
            /*Debug.WriteLine("dThickness="+dThickness+" dScale="+dScale);*/

            wShape.StrokeThickness = (dThickness > 0) ? dThickness * dScale * 3.4 : 0.1;

            DoubleCollection myCollec = new DoubleCollection(xEntity.Linetype.Segments.ToArray());

            wShape.StrokeDashArray = myCollec;

            AciColor myColor = xEntity.getColor();

            wShape.Stroke = new SolidColorBrush(TypeConverter.ToMediaColor(myColor.ToColor()));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取颜色
        /// </summary>
        /// <param name="aciColor">当前颜色</param>
        /// <param name="layer">图层颜色</param>
        /// <param name="type"></param>
        /// <returns></returns>
        private SolidBrush GetBrush(AciColor aciColor, Layer layer, int type)
        {
            if (aciColor.Index == 256)
            {
                aciColor = layer.Color;
            }

            if (type.Equals((int)Type.One))
            {
                if (aciColor.Index == AciColor.Default.Index)
                {
                    return(new SolidBrush(Color.White));
                }
            }
            else
            {
                if (aciColor.Index == AciColor.Default.Index)
                {
                    return(new SolidBrush(Color.Black));
                }
            }
            return(new SolidBrush(aciColor.ToColor()));
        }
        public static void Entity2Shape(EntityObject xEntity, System.Windows.Shapes.Shape wShape)
        {
            //double dThickness = xEntity.getLineweightValue();
            //double dScale = xEntity.LinetypeScale;

            var    it         = xEntity.Lineweight;
            double dThickness = 0;

            switch (it)
            {
            case Lineweight.ByBlock:
                dThickness = -2;
                break;

            case Lineweight.ByLayer:
                dThickness = -1;
                break;

            case Lineweight.Default:
                dThickness = -3;
                break;

            default:
                var LW = xEntity.Lineweight.ToString().Replace("W", "");
                dThickness = double.Parse(LW);
                break;
            }


            double dScale = xEntity.LinetypeScale;

            /* By Block */
            if (dThickness == -2)
            {
                dThickness = double.Parse(xEntity.Owner.Layer.Lineweight.ToString());   //xEntity.Owner.Layer.getLineweightValue();
            }
            if (dScale == -2)
            {
                dScale = 1;
            }


            /* By Default */
            if (dThickness == -3)
            {
                dThickness = defaultThickness;
            }
            if (dScale == -3)
            {
                dScale = 1;
            }

            /*Debug.WriteLine("dThickness="+dThickness);*/
            /*Debug.WriteLine("dThickness="+dThickness+" dScale="+dScale);*/

            wShape.StrokeThickness = (dThickness > 0) ? dThickness * dScale * 3.4 : 0.1;

            List <double> listdouble = new List <double>();//改写

            for (int i = 0; i < xEntity.Linetype.Segments.Count; i++)
            {
                Double T = xEntity.Linetype.Segments[i].Length;
                listdouble.Add(T);
            }
            DoubleCollection myCollec = new DoubleCollection(listdouble.ToArray());

            wShape.StrokeDashArray = myCollec;

            AciColor myColor = xEntity.Color;

            wShape.Stroke = new SolidColorBrush(TypeConverter.ToMediaColor(myColor.ToColor()));
        }
 public static System.Windows.Media.SolidColorBrush AciColorToBrush(AciColor myColor)
 {
     return(new SolidColorBrush(TypeConverter.ToMediaColor(myColor.ToColor())));
 }
Ejemplo n.º 6
0
        public static SolidColorBrush GetFillBrush(AciColor myColor, short transparency)
        {
            SolidColorBrush fillBrush = new SolidColorBrush(TypeConverter.ToMediaColor(myColor.ToColor()));

            if (transparency != 100 && transparency != -1)
            {
                double dOpacity = ((double)transparency) / 90;
                /*if(dOpacity < 0) dOpacity = 0.0;*/
                fillBrush.Opacity = 1 - dOpacity;
            }
            return(fillBrush);
        }