Ejemplo n.º 1
0
        private AM.Pen ToPen(BaseStyle style, Func <double, float> scale)
        {
            var lineCap   = default(AM.PenLineCap);
            var dashStyle = default(AM.DashStyle);

            switch (style.LineCap)
            {
            case LineCap.Flat:
                lineCap = AM.PenLineCap.Flat;
                break;

            case LineCap.Square:
                lineCap = AM.PenLineCap.Square;
                break;

            case LineCap.Round:
                lineCap = AM.PenLineCap.Round;
                break;
            }

            if (style.Dashes != null)
            {
                dashStyle = new AM.DashStyle(
                    ShapeStyle.ConvertDashesToDoubleArray(style.Dashes),
                    style.DashOffset);
            }

            var pen = new AM.Pen(
                ToBrush(style.Stroke),
                scale(style.Thickness / State.ZoomX),
                dashStyle, lineCap,
                lineCap, lineCap);

            return(pen);
        }
Ejemplo n.º 2
0
        private static Pen CreatePen(BaseStyle style, double thickness)
        {
            var brush = CreateBrush(style.Stroke);
            var pen   = new Pen(brush, thickness);

            switch (style.LineCap)
            {
            case LineCap.Flat:
                pen.StartLineCap = PenLineCap.Flat;
                pen.EndLineCap   = PenLineCap.Flat;
                pen.DashCap      = PenLineCap.Flat;
                break;

            case LineCap.Square:
                pen.StartLineCap = PenLineCap.Square;
                pen.EndLineCap   = PenLineCap.Square;
                pen.DashCap      = PenLineCap.Square;
                break;

            case LineCap.Round:
                pen.StartLineCap = PenLineCap.Round;
                pen.EndLineCap   = PenLineCap.Round;
                pen.DashCap      = PenLineCap.Round;
                break;
            }
            pen.DashStyle = new DashStyle(
                ShapeStyle.ConvertDashesToDoubleArray(style.Dashes),
                style.DashOffset);
            pen.DashStyle.Offset = style.DashOffset;
            pen.Freeze();
            return(pen);
        }
Ejemplo n.º 3
0
        private static XPen ToXPen(BaseStyle style, Func <double, double> scale, double sourceDpi, double targetDpi)
        {
            var pen = new XPen(ToXColor(style.Stroke), scale(style.Thickness * targetDpi / sourceDpi));

            switch (style.LineCap)
            {
            case LineCap.Flat:
                pen.LineCap = XLineCap.Flat;
                break;

            case LineCap.Square:
                pen.LineCap = XLineCap.Square;
                break;

            case LineCap.Round:
                pen.LineCap = XLineCap.Round;
                break;
            }
            if (style.Dashes != null)
            {
                // TODO: Convert to correct dash values.
                pen.DashPattern = ShapeStyle.ConvertDashesToDoubleArray(style.Dashes);
            }
            pen.DashOffset = style.DashOffset;
            return(pen);
        }