Exemple #1
0
		private void button3_Click(object sender, EventArgs e)
		{
			ColorDialog dialog = new ColorDialog();
			if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
			{
				ColorDialog dialogDop = new ColorDialog();
				if (dialogDop.ShowDialog() == System.Windows.Forms.DialogResult.OK)
				{
					var plane = new Bombardir(100, 4, 1000, dialog.Color, true, true, true, dialogDop.Color);
					int place = parking.PutPlaneInParking(plane);
					Draw();
					MessageBox.Show("Вашеместо: " + place);
				}
			}
		}
 public bool LoadData(string filename)
 {
     if (!File.Exists(filename))
     {
         return(false);
     }
     using (FileStream fs = new FileStream(filename, FileMode.Open))
     {
         string s = "";
         using (BufferedStream bs = new BufferedStream(fs))
         {
             byte[]       b    = new byte[fs.Length];
             UTF8Encoding temp = new UTF8Encoding(true);
             while (bs.Read(b, 0, b.Length) > 0)
             {
                 s += temp.GetString(b);
             }
         }
         s = s.Replace("\r", "");
         var strs = s.Split('\n');
         if (strs[0].Contains("CountLeveles"))
         {                //считываем кол-во уровней
             int count = Convert.ToInt32(strs[0].Split(':')[1]);
             if (parkingStages != null)
             {
                 parkingStages.Clear();
             }
             parkingStages = new List <ClassArray <ITechnique> >(count);
         }
         else
         {                 /// если нет такой записи, то это не те данные
             return(false);
         }
         int counter = -1;
         for (int i = 1; i < strs.Length; ++i)
         {                //идем по считанным записям
             if (strs[i] == "Level")
             {            //Начинаем новый уровень
                 counter++;
                 parkingStages.Add(new ClassArray <ITechnique>(countPlaces, null));
             }
             else if (strs[i].Split(':')[0] == "Plane")
             {
                 ITechnique plane  = new Plane(strs[i].Split(':')[1]);
                 int        number = parkingStages[counter] + plane;
                 if (number == -1)
                 {
                     return(false);
                 }
             }
             else if (strs[i].Split(':')[0] == "Bombardir")
             {
                 ITechnique plane  = new Bombardir(strs[i].Split(':')[1]);
                 int        number = parkingStages[counter] + plane;
                 if (number == -1)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }