Exemple #1
0
        private void btnFigure_Click(object sender, EventArgs e)
        {
            canvas.Enabled = true;

            if (lsbPictures.Items.Count >= imagesCount)
            {
                lsbPictures.Items.RemoveAt(0);
                imageList.RemoveAt(0);
            }

            figureCreator     = creatorList[Convert.ToInt32((sender as Button).Tag.ToString())];
            figure            = figureCreator.CreateFigure();
            figureDrawer      = drawerList[Convert.ToInt32((sender as Button).Tag.ToString())];
            figureInitializer = initializerList[Convert.ToInt32((sender as Button).Tag.ToString())];
        }
Exemple #2
0
        private void PanelPaintArea_MouseClick(object sender, MouseEventArgs e)
        {
            if (_manual)
            {
                var figure = FigureCreator.CreateFigure();

                var figureName = ComboBoxFigures.SelectedItem as string;
                var loc        = e.Location;

                figure.Name = figureName;

                var width  = Convert.ToInt32(TextBoxWidth.Text);
                var height = Convert.ToInt32(TextBoxHeight.Text);

                figure.Point    = loc;
                figure.Size     = new Size(width, height);
                figure.Color    = _color;
                figure.IsFilled = _isFilled;

                Figures.Add(figure);
            }
            else
            {
                if (Points.Count < 3)
                {
                    Points.Add(e.Location);

                    if (Points.Count == 2)
                    {
                        var width  = Points[1].X - Points[0].X;
                        var height = Points[1].Y - Points[0].Y;

                        var figure = FigureCreator.CreateFigure();

                        var figureName = ComboBoxFigures.SelectedItem as string;

                        figure.Name     = figureName;
                        figure.Color    = _color;
                        figure.IsFilled = _isFilled;

                        Point loc = Point.Empty;
                        if (width < 0 && height < 0)
                        {
                            loc = Points[1];
                        }
                        else if (width > 0 && height > 0)
                        {
                            loc = Points[0];
                        }
                        else if (width < 0 && height > 0)
                        {
                            loc = new Point(Points[0].X - Math.Abs(width), Points[0].Y);
                        }
                        else if (width > 0 && height < 0)
                        {
                            loc = new Point(Points[1].X - Math.Abs(width), Points[1].Y);
                        }

                        figure.Point = loc;

                        figure.Size = new Size(Math.Abs(width), Math.Abs(height));
                        Figures.Add(figure);
                        Points.Clear();
                    }
                }
            }


            this.Refresh();
        }