Example #1
0
        private void canvasPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_dragging)
            {
                // Saev starting point, convert to rect
                _startingX = e.X;
                _startingY = e.Y;
                Rectangle rectangle = new Rectangle(e.X, e.Y, 0, 0);

                // create current shape
                switch (shapeComboBox.Text)
                {
                    case "Ellipse":
                        _draggingCurrentShape = new Ellipse(rectangle, _shapeColor, filledCheckBox.Checked);
                        break;
                    case "Rectangle":
                        _draggingCurrentShape = new Rctngle(rectangle, _shapeColor, filledCheckBox.Checked);
                        break;
                    case "Line":
                        _draggingCurrentShape = new Lne(e.X, e.Y, rectangle, _shapeColor);
                        break;
                }

                //indicate we're drawing rubber-banding
                _dragging = true;
            }
        }
Example #2
0
        // add dis shape
        public int Add(Shape shape)
        {
            // Create or resize our shape didly apes
            if (_shapes == null) { _shapes = new Shape[1]; }
            else { Array.Resize(ref _shapes, _shapes.Length + 1); }

            _shapes[_shapes.Length - 1] = shape;
            return _shapes.Length;
        }