Example #1
0
        public static void Read(this IPathCommand command, System.IO.BinaryReader reader)
        {
            switch (command.Type)
            {
            case CommandType.MoveTo:
            {
                MoveTo pCommand = command as MoveTo;
                pCommand.X = reader.ReadDouble();
                pCommand.Y = reader.ReadDouble();
            }
            break;

            case CommandType.LineTo:
            {
                LineTo pCommand = command as LineTo;
                pCommand.X = reader.ReadDouble();
                pCommand.Y = reader.ReadDouble();
            }
            break;

            case CommandType.CurveTo:
            {
                CurveTo pCommand = command as CurveTo;
                pCommand.ControlStart = reader.ReadPoint();
                pCommand.ControlEnd   = reader.ReadPoint();
                pCommand.End          = reader.ReadPoint();
            }
            break;

            case CommandType.SmoothCurveTo:
            {
                SmoothCurveTo pCommand = command as SmoothCurveTo;
                pCommand.ControlEnd = reader.ReadPoint();
                pCommand.End        = reader.ReadPoint();
            }
            break;

            case CommandType.EllipticalArcTo:
            {
                EllipticalArcTo pCommand = command as EllipticalArcTo;
                pCommand.Size           = new System.Windows.Size(reader.ReadDouble(), reader.ReadDouble());
                pCommand.End            = reader.ReadPoint();
                pCommand.RotationAngle  = reader.ReadDouble();
                pCommand.IsLargeArc     = reader.ReadBoolean();
                pCommand.SweepDirection = (reader.ReadBoolean() == false ? SweepDirection.Counterclockwise : SweepDirection.Clockwise);
            }
            break;

            case CommandType.QuadraticBeizerCurveTo:
            {
                QuadraticBeizerCurveTo pCommand = command as QuadraticBeizerCurveTo;
                pCommand.Control = reader.ReadPoint();
                pCommand.End     = reader.ReadPoint();
            }
            break;

            case CommandType.SmoothQuadraticBeizerCurveTo:
            {
                SmoothQuadraticBeizerCurveTo pCommand = command as SmoothQuadraticBeizerCurveTo;
                pCommand.End = reader.ReadPoint();
            }
            break;

            case CommandType.ClosePath:
            {
                // Do nothing
            }
            break;
            }
        }