Esempio n. 1
0
        private void gridPanel_MouseClick(object sender, MouseEventArgs e)
        {
            MouseEventArgs me = (MouseEventArgs)e;

            System.Drawing.Point coordinates = me.Location;

            if (option != 0)
            {
                if (pointArray.Count < 1)
                {
                    pointArray.Add(coordinates);
                }
                else
                {
                    pointArray.Add(coordinates);
                    pointArray[0] = grid.FixPoint(pointArray[0]);
                    switch (option)
                    {
                    case 1:
                        try
                        {
                            grid.AddWall(graphic, new Wall(new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y)
                                                           , new Domain.Entities.Point(grid.FixPoint(pointArray[1]).X, grid.FixPoint(pointArray[1]).Y)));
                            UpdateLines();
                        }
                        catch (ExceptionController Exception)
                        {
                            string message = Exception.Message;
                            MessageBox.Show(message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    case 2:
                        try
                        {
                            grid.AddDoor(graphic, new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y)
                                         , new Domain.Entities.Point(pointArray[1].X, pointArray[1].Y)
                                         , grid.WallSense(new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y)));
                            UpdateLines();
                        }
                        catch (ExceptionController Exception)
                        {
                            string message = Exception.Message;
                            MessageBox.Show(message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    case 3:
                        try
                        {
                            grid.AddWindow(graphic, new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y)
                                           , new Domain.Entities.Point(pointArray[1].X, pointArray[1].Y)
                                           , grid.WallSense(new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y)));
                            UpdateLines();
                        }
                        catch (ExceptionController Exception)
                        {
                            string message = Exception.Message;
                            MessageBox.Show(message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    case 4:
                        try
                        {
                            grid.RemoveWall(grid.ObtainWallInPoint(new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y)));
                            UpdateLines();
                        }
                        catch (ExceptionController Exception)
                        {
                            string message = Exception.Message;
                            MessageBox.Show(message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    case 5:
                        try
                        {
                            grid.RemoveWindow(new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y));
                            UpdateLines();
                        }
                        catch (ExceptionController Exception)
                        {
                            string message = Exception.Message;
                            MessageBox.Show(message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    case 6:
                        try
                        {
                            grid.RemoveDoor(new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y));
                            UpdateLines();
                        }
                        catch (ExceptionController Exception)
                        {
                            string message = Exception.Message;
                            MessageBox.Show(message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    case 8:
                        try
                        {
                            grid.AddDecorativeColumn(graphic, new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y));
                            UpdateLines();
                        }
                        catch (ExceptionController Exception)
                        {
                            string message = Exception.Message;
                            MessageBox.Show(message, "Oops", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    case 9:
                        grid.RemoveDecorativeColumn(new Domain.Entities.Point(pointArray[0].X, pointArray[0].Y));
                        UpdateLines();
                        break;

                    default:
                        break;
                    }
                    pointArray.Clear();
                }
            }
        }