コード例 #1
0
ファイル: Form1.cs プロジェクト: aykutmunuk/c-
 private void place_click(object sender, EventArgs e)
 {
     if (areaEntity != null)
     {
         areaEntity.DrawArea(this.grpArea);
         RobotEntity.Clear();
         int robotXCoor = int.Parse(txtRobotXCoor.Text);
         int robotYCoor = areaEntity.ySize - int.Parse(txtRobotYCoor.Text);
         if (robotXCoor < 0 || robotYCoor < 0)
         {
             MessageBox.Show("Alan ölçüleri 0 dan büyük bir değer olmalıdır.");
             return;
         }
         else if (robotXCoor > areaEntity.xSize || robotYCoor > areaEntity.ySize)
         {
             MessageBox.Show("Robot koordinatı alan içerisinde olmalıdır.");
             return;
         }
         else
         {
             Directions direction = (Directions)Enum.Parse(typeof(Directions), cbxDirection.SelectedItem.ToString());
             robotEntity = RobotEntity.CreateInstance(robotXCoor, robotYCoor, direction);
         }
     }
     else
     {
         MessageBox.Show("Alanı oluşturun.");
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: aykutmunuk/c-
        private void btnArea_Click(object sender, EventArgs e)
        {
            int xSize = int.Parse(txtX.Text);
            int ySize = int.Parse(txtY.Text);

            if (xSize <= 0 || ySize <= 0)
            {
                MessageBox.Show("Alan ölçüleri 0 dan büyük bir değer olmalıdır.");
                return;
            }
            areaEntity  = null;
            robotEntity = null;
            areaEntity  = AreaEntity.CreateInstance(xSize, ySize);
            areaEntity.DrawArea(this.grpArea);
        }