コード例 #1
0
 // The App class accepts its commands via constructor-injection
 public App(CircleCommand circleCommand, TriangleCommand triangleCommand, SquareCommand squareCommand, NoneCommand noneCommand)
 {
     _circleCommand   = circleCommand;
     _triangleCommand = triangleCommand;
     _squareCommand   = squareCommand;
     _noneCommand     = noneCommand;
 }
コード例 #2
0
        private void Canvas_MouseDown(object sender, MouseEventArgs e)
        {
            // Each mouse down creates a new command class instance

            ICommand command = null;

            if (_activeShape == ShapeEnum.Square)
            {
                command = new SquareCommand(_bitmap, _activeColor, e.X, e.Y);
            }

            else if (_activeShape == ShapeEnum.Rectangle)
            {
                command = new RectangleCommand(_bitmap, _activeColor, e.X, e.Y);
            }

            command.Do();
            _commandStack.Push(command);

            RefreshUI();
        }