示例#1
0
        private static StrokeData StrokeToData(Stroke stroke, System.Windows.Size size)
        {
            StrokeData data = new StrokeData();
            string     type = "";

            if (stroke is ArrowStroke)
            {
                type = StrokeTypes.Arrow;
            }
            if (stroke is CircleStroke)
            {
                type = StrokeTypes.Circle;
            }
            if (stroke is StraightStroke)
            {
                type = StrokeTypes.Line;
            }
            if (stroke is RectangleStroke)
            {
                type = StrokeTypes.Rectangle;
            }
            if (stroke is TriangleStroke)
            {
                type = StrokeTypes.Triangle;
            }
            data.Type = type;

            data.Points = StrokeDataEx.ToPoints(stroke.StylusPoints, size);
            data.Atts   = DrawingAttributesDataEx.ToData(stroke.DrawingAttributes);
            data.ID     = StrokeEx.GetID(stroke);

            return(data);
        }
示例#2
0
        private static Stroke DataToStroke(StrokeData data, System.Windows.Size size)
        {
            Stroke stroke = null;

            switch (data.Type)
            {
            case StrokeTypes.Arrow:
                stroke = new ArrowStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Circle:
                CircleStroke cs = new CircleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                stroke = cs;
                break;

            case StrokeTypes.Line:
                stroke = new StraightStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Rectangle:
                stroke = new RectangleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Triangle:
                stroke = new TriangleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            default:
                stroke = new Stroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;
            }


            StrokeEx.SetID(stroke, data.ID);
            stroke.DrawingAttributes = DrawingAttributesDataEx.ToDrawingAttributes(data.Atts);
            if (stroke is ShapeStroke)
            {
                stroke.DrawingAttributes.FitToCurve = false;
            }
            return(stroke);
        }