Пример #1
0
        public Shape Draw(DrawPackage drawpackage)
        {
            Rectangle rectangle = new Rectangle();

            rectangle.Height = drawpackage.height;
            rectangle.Width  = drawpackage.width;
            rectangle.Name   = "Rectangle";
            rectangle.Tag    = drawpackage.id;
            Canvas.SetLeft(rectangle, drawpackage.x);
            Canvas.SetTop(rectangle, drawpackage.y);
            return(rectangle);
        }
Пример #2
0
        public Shape Draw(DrawPackage drawpackage)
        {
            Ellipse ellipse = new Ellipse();

            ellipse.Height = drawpackage.height;
            ellipse.Width  = drawpackage.width;
            ellipse.Name   = "Ellipse";
            ellipse.Tag    = drawpackage.id;
            Canvas.SetLeft(ellipse, drawpackage.x);
            Canvas.SetTop(ellipse, drawpackage.y);
            return(ellipse);
        }
Пример #3
0
        public override Shape Draw(DrawPackage drawpackage)
        {
            Shape     shape   = _strategy.Draw(drawpackage);
            TextBlock element = new TextBlock();

            element.Text     = _ornament;
            element.FontSize = 25;
            element.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
            Canvas.SetLeft(element, drawpackage.x + drawpackage.width);
            Canvas.SetTop(element, drawpackage.y + ((drawpackage.height - element.DesiredSize.Height) / 2));
            drawpackage.paintSurface.Children.Add(element);
            return(shape);
        }
Пример #4
0
        //Update after undo/redo or changes made
        public void Update(bool change)
        {
            //true means that an actual change has been made and needs to be stored in the history
            if (change)
            {
                timeindex++;;
                if (history.timeline.Count >= timeindex)
                {
                    history.timeline.RemoveRange(timeindex, history.timeline.Count - timeindex);
                }
                history.timeline.Add(new Snapshot(group.Copy(), itemcount));
            }
            //false means that the history needs to be read and written to the paintsurface
            else
            {
                group     = history.timeline[timeindex].composite.Copy();
                itemcount = history.timeline[timeindex].itemcount;
                paintSurface.Children.Clear();
                List <Composite> tosurface = history.timeline[timeindex].composite.Concatenate();
                foreach (Composite c in tosurface)
                {
                    if (c.type != "Group")
                    {
                        Strategy strategy = DrawEllipse.getInstance();
                        if (c.type == "Rectangle")
                        {
                            strategy = DrawRectangle.getInstance();
                        }
                        foreach (Ornament o in c.ornaments)
                        {
                            switch (o.position)
                            {
                            case "top":
                                strategy = new UpperOrnamentDecorator(strategy, o.ornament);
                                break;

                            case "bottom":
                                strategy = new LowerOrnamentDecorator(strategy, o.ornament);
                                break;

                            case "left":
                                strategy = new LeftOrnamentDecorator(strategy, o.ornament);
                                break;

                            case "right":
                                strategy = new RightOrnamentDecorator(strategy, o.ornament);
                                break;
                            }
                        }
                        DrawPackage drawpackage = new DrawPackage();
                        drawpackage.x            = c.x;
                        drawpackage.y            = c.y;
                        drawpackage.height       = c.height;
                        drawpackage.width        = c.width;
                        drawpackage.id           = c.id;
                        drawpackage.paintSurface = paintSurface;
                        Context context = new Context(strategy);
                        context.drawpackage = drawpackage;
                        Shape           shape = context.Draw();
                        SolidColorBrush brush = new SolidColorBrush();
                        if (IsSelected(c))
                        {
                            brush.Color = Colors.DarkSlateGray;
                        }
                        else
                        {
                            brush.Color = Colors.SlateGray;
                        }
                        shape.Fill                 = brush;
                        shape.PointerPressed      += mouseDown;
                        shape.PointerMoved        += mouseMove;
                        shape.PointerReleased     += mouseUp;
                        shape.PointerWheelChanged += mouseScroll;
                        paintSurface.Children.Add(shape);
                    }
                    else
                    {
                        Strategy strategy = DrawEllipse.getInstance();
                        foreach (Ornament o in c.ornaments)
                        {
                            switch (o.position)
                            {
                            case "top":
                                strategy = new UpperOrnamentDecorator(strategy, o.ornament);
                                break;

                            case "bottom":
                                strategy = new LowerOrnamentDecorator(strategy, o.ornament);
                                break;

                            case "left":
                                strategy = new LeftOrnamentDecorator(strategy, o.ornament);
                                break;

                            case "right":
                                strategy = new RightOrnamentDecorator(strategy, o.ornament);
                                break;
                            }
                        }
                        DrawPackage drawpackage = new DrawPackage();
                        XYXY        xyxy        = c.GetGroupXYHW();
                        drawpackage.x            = xyxy.sx;
                        drawpackage.y            = xyxy.sy;
                        drawpackage.height       = xyxy.ey - xyxy.sy;
                        drawpackage.width        = xyxy.ex - xyxy.sx;
                        drawpackage.id           = c.id;
                        drawpackage.paintSurface = paintSurface;
                        Context context = new Context(strategy);
                        context.drawpackage = drawpackage;
                        Shape shape = context.Draw();
                    }
                }
            }
        }
Пример #5
0
 public abstract Shape Draw(DrawPackage drawpackage);