Ejemplo n.º 1
0
        public IShape Build(IList <string> parameters, DrawingContext context)
        {
            if (parameters.Count != ParamCount)
            {
                throw new ArgumentException($"Invalid number of arguments: {parameters.Count}. Expected {ParamCount}.");
            }
            Match textMatch = StringRegex.Match(parameters[0]);
            var   text      = textMatch.Success
                ? textMatch.Groups["text"].Value
                : throw new ArgumentException($"The string {parameters[0]} is in incorrect format.");
            var intParams = parameters
                            .Skip(1)
                            .Take(2)
                            .Select(int.Parse)
                            .ToList();
            var point = new Point(intParams[0], intParams[1]);

            return(new StringShape(text, point, context.CreateBrushBillet(), context.CreateFontBillet()));
        }
Ejemplo n.º 2
0
        public static IShape GetShape()
        {
            var context = new DrawingContext();

            return(new AggregateShape(new IShape[]
            {
                new LineShape(new Point(10, 10), new Point(150, 10), context.CreatePenBillet()),
                new EllipseShape(new Point(10, 40), new Point(150, 80), context.CreatePenBillet()),
                new ArcShape(new Rectangle(100, 100, 100, 150), 90, 90, context.CreatePenBillet()),
                new RectangleShape(new Point(10, 80), new Point(150, 120), context.CreatePenBillet()),
                new StringShape("shaaaapes", new Point(10, 100), context.CreateBrushBillet(), context.CreateFontBillet()),
                new CurveShape(new []
                {
                    new Point(10, 120), new Point(80, 150), new Point(150, 120)
                }, context.CreatePenBillet()),
            }));
        }