Exemplo n.º 1
0
        //Saves updated properties depending on shape type and closes form.
        private void SaveChangesButton_Click(object sender, EventArgs e)
        {
            if (this.Shape.GetType().Name == "Circle")
            {
                ICircle circle = (ICircle)this.Shape;

                circle.ChangeSize(new PointF((float)this.CenterXNumber.Value, (float)this.CenterYNumber.Value),
                                  (float)this.RadiusNumber.Value);
            }
            else if (this.Shape.GetType().Name == "Rectangle")
            {
                IRectangle rectangle = (IRectangle)this.Shape;

                rectangle.ChangeSize(new PointF((float)this.PointXNumber.Value, (float)this.PointYNumber.Value),
                                     (float)this.WidthNumber.Value, (float)this.HeightNumber.Value);
            }
            else if (this.Shape.GetType().Name == "Triangle")
            {
                ITriangle triangle = (ITriangle)this.Shape;

                triangle.ChangeSize(
                    new PointF((float)this.PointAXCoordinateNumber.Value, (float)this.PointAYCoordinateNumber.Value),
                    new PointF((float)this.PointBXCoordinateNumber.Value, (float)this.PointBYCoordinateNumber.Value),
                    new PointF((float)this.PointCXCoordinateNumber.Value, (float)this.PointCYCoordinateNumber.Value));
            }

            this.Shape.ChangeColor(this.newColor);

            this.Close();
        }