Beispiel #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm();

            asf.ShowDialog(this);

            if (asf.DialogResult == DialogResult.OK)
            {
                listBox1.Items.Clear();
                double textBoxValue = asf.getTextBoxInput();
                int    shapeChoice  = asf.getSelectedType();
                if (shapeChoice == 1)
                {
                    Circle circle = new Circle(textBoxValue);
                    DataModel.getAllElementsList().Add(circle);
                }
                else if (shapeChoice == 2)
                {
                    Square square = new Square(textBoxValue);
                    DataModel.getAllElementsList().Add(square);
                }
                else
                {
                    Triangle triangle = new Triangle(textBoxValue);
                    DataModel.getAllElementsList().Add(triangle);
                }

                asf.Dispose();
                this.label2.Text = $"Total area={DataModel.getTotalArea()}, Total perimeter={DataModel.getTotalPerimeter()}";
                foreach (Shape shape in DataModel.getAllElementsList())
                {
                    listBox1.Items.Add(shape);
                }
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm();

            asf.ShowDialog(this);

            if (asf.DialogResult == DialogResult.OK)
            {
                //to do
                asf.Dispose();
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm();

            asf.ShowDialog(this);

            if (asf.DialogResult == DialogResult.OK)
            {
                var shape = MakeShape(asf.getSelectedType(), asf.getTextBoxInput());
                DataModel.AddElementToList(shape);
                listBox1.Items.Add(shape);
                label2.Text = String.Format("Total area={0}, Total perimeter={1}", DataModel.getTotalArea().ToString(), DataModel.getTotalPerimeter().ToString());
                asf.Dispose();
            }
        }
Beispiel #4
0
        private void insertTriangle_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm(3);

            asf.ShowDialog(this);
            if (asf.DialogResult == DialogResult.OK)
            {
                if (asf.getSelectedType() == 3)
                {
                    Triangle triangle = new Triangle(asf.getTextBoxInput());
                    DataModel.getAllElementsList().Add(triangle);
                    TreeNode tn = new TreeNode();
                    tn.Text = triangle.ToString();
                    tn.Tag  = triangle;
                    treeView1.Nodes[0].Nodes[2].Nodes.Add(tn);
                }
                label1.Text = "Total area=" + DataModel.getTotalArea() + ", Total perimeter=" + DataModel.getTotalPerimeter();
                asf.Dispose();
            }
        }
Beispiel #5
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm();

            asf.ShowDialog(this);

            if (asf.DialogResult == DialogResult.OK)
            {
                Shape shape = CreateShapeFactory(asf);

                DataModel.getAllElementsList().Add(shape);

                listBox1.Items.Add(shape);

                label2.Text = string.Format("Total area={0}, Total perimeter={1}",
                                            DataModel.getTotalArea(), DataModel.getTotalPerimeter());

                asf.Dispose();
            }
        }
Beispiel #6
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm();

            asf.ShowDialog(this);

            if (asf.DialogResult == DialogResult.OK)
            {
                int    shapeType = asf.getSelectedType();
                double value     = asf.getTextBoxInput();

                switch (shapeType)
                {
                case 1:
                    Circle newCircle = new Circle(value);
                    DataModel.getAllElementsList().Add(newCircle);
                    this.listBox1.Items.Add(newCircle.ToString());
                    break;

                case 2:
                    Square newSquare = new Square(value);
                    DataModel.getAllElementsList().Add(newSquare);
                    this.listBox1.Items.Add(newSquare.ToString());
                    break;

                case 3:
                    Triangle newTriangle = new Triangle(value);
                    DataModel.getAllElementsList().Add(newTriangle);
                    this.listBox1.Items.Add(newTriangle.ToString());
                    break;

                default:
                    break;
                }

                updateTotalLabel();

                asf.Dispose();
            }
        }
Beispiel #7
0
        private void insertSquare_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm(2);

            asf.ShowDialog(this);

            if (asf.DialogResult == DialogResult.OK)
            {
                if (asf.getSelectedType() == 2)
                {
                    Square square = new Square(asf.getTextBoxInput());
                    DataModel.getAllElementsList().Add(square);
                    TreeNode tn = new TreeNode();
                    tn.Text = square.ToString();
                    tn.Tag  = square;
                    // Nodes[0] - Shape
                    // Nodes[0].Nodes[1] - Square
                    treeView1.Nodes[0].Nodes[1].Nodes.Add(tn);
                }

                label1.Text = "Total area=" + DataModel.getTotalArea() + ", Total perimeter=" + DataModel.getTotalPerimeter();
                asf.Dispose();
            }
        }
Beispiel #8
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            AddShapeForm asf = new AddShapeForm();

            asf.ShowDialog(this);

            if (asf.DialogResult == DialogResult.OK)
            {
                switch (asf.getSelectedType())
                {
                case 1:
                    Circle circle = new Circle(asf.getTextBoxInput());
                    DataModel.getAllElementsList().Add(circle);
                    listBox1.Items.Add(circle);
                    break;

                case 2:
                    Square square = new Square(asf.getTextBoxInput());
                    DataModel.getAllElementsList().Add(square);
                    listBox1.Items.Add(square);
                    break;

                case 3:
                    Triangle triangle = new Triangle(asf.getTextBoxInput());
                    DataModel.getAllElementsList().Add(triangle);
                    listBox1.Items.Add(triangle);
                    break;

                default:
                    break;
                }

                label2.Text = "Total area=" + DataModel.getTotalArea().ToString() + " Total perimeter=" + DataModel.getTotalPerimeter().ToString();
                asf.Dispose();
            }
        }