Beispiel #1
0
        public void SetUp()
        {
            // Reference case instantiation
            IShape circle = new Circle();
            IShape rect   = new Rectangle();

            IGraphics ig = new CsGraphics();
            var       m  = Mediator.Instance;

            m.GetType().GetField("_g", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static).SetValue(m, ig);
            Mediator.Instance.ToolBar.Add(circle);
            Mediator.Instance.ToolBar.Add(rect);
            Mediator.Instance.LoadCurrentShape(0);
            Mediator.Instance.DrawCurrentShape(50, 50);
            Mediator.Instance.LoadCurrentShape(1);
            Mediator.Instance.DrawCurrentShape(100, 100);
            Mediator.Instance.LoadCurrentShape(0);
            Mediator.Instance.DrawCurrentShape(150, 150);
            Mediator.Instance.LoadCurrentShape(1);
            Mediator.Instance.DrawCurrentShape(200, 200);
            Mediator.Instance.AddRemoveSelectedShape(Mediator.Instance.DrawnShapes[2].X, Mediator.Instance.DrawnShapes[2].Y);
            Mediator.Instance.AddRemoveSelectedShape(Mediator.Instance.DrawnShapes[3].X, Mediator.Instance.DrawnShapes[3].Y);

            /*There, we have :
             * Toolbar : 1 circle, 1 rect
             * DrawnShapes : 1 circle, 1 rect, 1 group (made of 1 circle and 1 rect)
             * every add of these shapes has created a Memento
             */
            reference = CareTaker.Instance.GetCurrentMemento();
        }
Beispiel #2
0
        public void VisitRectangle(Rectangle rect)
        {
            var b = new SolidBrush(rect.Color);

            _drawingRect = new System.Drawing.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
            _drawingRect = ReplaceShape(_drawingRect);

            g.FillRectangle(b, _drawingRect);
        }
Beispiel #3
0
        public void VisitRectangle(Rectangle rect)
        {
            var brush = new SolidBrush(rect.Color);

            _e.Graphics.FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
            if (Mediator.Instance.SelectedShapes.Contains(rect) || _amISelected)
            {
                _e.Graphics.DrawRectangle(new Pen(Color.Black), rect.X, rect.Y, rect.Width, rect.Height);
            }
        }
Beispiel #4
0
        public void VisitRectangle(Rectangle rect)
        {
            var x      = (int)_params[0];
            var y      = (int)_params[1];
            var width  = (int)_params[2];
            var height = (int)_params[3];
            var color  = (Color)_params[4];

            rect.Accept(new ReplaceShape(x, y));
            rect.Width  = width;
            rect.Height = height;
            rect.Color  = color;
        }
Beispiel #5
0
        public void OpenRectangleEditMenu(Rectangle r)
        {
            var RectangleEditor = new RectangleEditor(this, r);

            RectangleEditor.Show();
        }
Beispiel #6
0
 public void UpdateRectangle(Rectangle r, int x, int y, int width, int height, Color color)
 {
     r.Accept(new UpdateShape(x, y, width, height, color));
     CreateMemento();
 }