Example #1
0
    protected void OnOpenAction1Activated(object sender, EventArgs e)
    {
        Gtk.FileChooserDialog fc=
        new Gtk.FileChooserDialog("Выберете файл",
                                    this,
                                    FileChooserAction.Open,
                                    "Отмена",ResponseType.Cancel,
                                    "Открыть",ResponseType.Accept);

        if (fc.Run() == (int)ResponseType.Accept)
        {
            string[] found_ans;
            string[] bricks_ans;
            string[] fixes;
            string[] found;
            string[] bricks;
            Storage.ReadAnswers (fc.Filename, out fixes, out found, out bricks, out found_ans, out bricks_ans);
            try{
                float t;
                int t1;
                float.TryParse(fixes[0], out t);
                force_spin.Value = t;
                int.TryParse (fixes [1], out t1);
                objMaterial.Active = t1;
                int.TryParse (fixes [2], out t1);
                planeToFix.Active = t1;
                int.TryParse (fixes [3], out t1);
                objLenght.Value = t1;
                int.TryParse (fixes [4],out t1);
                fixPointsN.Value = t1;
                int.TryParse (fixes [5], out t1);
                wallMaterial.Active = t1;
                int.TryParse (fixes [6], out t1);
                wallLenght.Value = t1;

                int.TryParse (found [0], out t1);
                build_lenght.Value = t1;
                int.TryParse (found [1], out t1);
                build_hight.Value = t1;
                float.TryParse (found [2], out t);
                found_flat.Value = t;
                float.TryParse (found [3], out t);
                addit_P.Value = t;
                float.TryParse (found [4], out t);
                hight.Value = t;
                float.TryParse (found [5], out t);
                deep.Value = t;
                int.TryParse (found [6], out t1);
                beton.Active = t1;

                int.TryParse (bricks [0], out t1);
                build_lenght1.Value = t1;
                int.TryParse (bricks [1], out t1);
                build_weight1.Value = t1;
                int.TryParse (bricks [2], out t1);
                build_hight.Value = t1;
                int.TryParse (bricks [3], out t1);
                materialOfBuild.Active = t1;
                int.TryParse (bricks [4], out t1);
                conWeight.Value = t1;
                int.TryParse (bricks [5], out t1);
                holesS.Value = t1;
                int.TryParse (bricks [6], out t1);
                roofType.Active = t1;
                int.TryParse (bricks [7], out t1);
                roofHight.Value = t1;
                int.TryParse (bricks [8], out t1);
                minh.Value = t1;

                float.TryParse (found_ans [0], out t);
                beton_vol.Value = t;
                float.TryParse (found_ans [1], out t);
                sand.Value = t;
                float.TryParse (found_ans [2], out t);
                concentre.Value = t;
                float.TryParse (found_ans [3], out t);
                gravel.Value = t;
                float.TryParse (found_ans [4], out t);
                arm.Value = t;
                float.TryParse (found_ans [5], out t);
                tube.Value = t;

                float.TryParse (bricks_ans [0], out t);
                bricksN.Value = t;
                float.TryParse (bricks_ans [1], out t);
                glueN.Value = t;

                GtkLabel4.Text = Storage.passed.Count.ToString ();
                btnForward.Sensitive = true;
                nameOfCurrentFix.Text += Storage.passed [0].NameToString ();
                imgFixPreview.Pixbuf = new Gdk.Pixbuf (Storage.GetStreamFromResource (Storage.passed [0].img_name));
                spinD.Value = Storage.passed [0].d;
                spinLenght.Value = Storage.passed [0].lenght;
                spinAvForce.Value = Storage.passed [0].max_avulsion_force;
                spinMaxCutForce.Value = Storage.passed [0].max_cut_force;
                spinMaxA.Value = Storage.passed [0].max_a;
                spinMaxS.Value = Storage.passed [0].max_s;
                spinFixPoints.Value = fixPointsN.Value;
            }
            catch{
                Warn wrn = new Warn();
                wrn.SetLabel("Ошибка в структуре файла!");
                wrn.Modal = true;
                wrn.Show();
            }
        }
        //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
        fc.Destroy();
    }
Example #2
0
 protected void OnButton65Clicked(object sender, EventArgs e)
 {
     Calculator.initConcrete ();//init prportions
     float volume = Calculator.foundamentVolume ((float)(hight.Value + deep.Value), (float)build_lenght.Value, (float)found_flat.Value, (float)addit_P.Value, (float)build_weight.Value);//total volume
     beton_vol.Value = volume;
     Calculator.Concrete mark = new Calculator.Concrete ();
     if (Calculator.Concrete.TryParse (beton.ActiveText, out mark)) {
         float[] mats = new float[3];
         mats = Calculator.concreteMaterials (volume, mark);//weight of components
         concentre.Value = mats[0]/1000;
         gravel.Value = mats[1]/1000;
         sand.Value = mats[2]/1000;
     }
     else
     {
         Warn wrn = new Warn();
         wrn.SetLabel("Проверьте, выбрали ли вы марку бетона! Если ошибка сохранится, свяжитесь с разработчиком!");
         wrn.Modal = true;
         wrn.Show();
     }
     arm.Value = Calculator.armsTotalLenght((float)(build_lenght.Value+addit_P.Value+build_weight.Value), (float)(hight.Value + deep.Value), (float)found_flat.Value);//just lenght of "arms"
     tube.Value = Calculator.formwork((float)(hight.Value + deep.Value), (float)(build_lenght.Value), (float)(build_weight.Value), (float)found_flat.Value, (float)addit_P.Value);
 }
Example #3
0
		public static void ReadAnswers (string filname, out string[] fix_inp, out string[] found_inp, out string[] bricks_inp, out string[] found, out string[] brick)
		{
			fix_inp = new string[1];
			found_inp = new string[1];
			bricks_inp = new string[1];
			found = new string[1];
			brick = new string[1];
			try{
				StreamReader reader = new StreamReader(filname);
				string s;
				List<string> data = new List<string>(100);
				bool inputs = true, fixing = false, foundament = false, bricks = false;
				while((s = reader.ReadLine()) != null)
				{
					if(s[0] != '#')
					{
						if(inputs)
						{
							string[] s1 = s.Split('\\');
							if(s1.Length == 3)
							{
								fix_inp = s1[0].Split(' ');
								found_inp = s1[1].Split(' ');
								bricks_inp = s1[2].Split(' ');
							}
							else
								throw new Exception("Inputs range error");
							//inputs = false;
							//fixing = true;
						}
						if(fixing)
						{
							if(passed.Count == passed.Capacity)
								passed.Capacity *= 2;
							passed.Add(Mount.FromString(s));
						}
						if(foundament)
						{
							found = s.Split(' ');
						}
						if(bricks)
						{
							brick = s.Split(' ');
						}
					}
					else
					{
						if(s.IndexOf("Inputs range")>-1)
						{
							inputs = true;
							fixing = false;
							foundament = false;
							bricks = false;
						}
						if(s.IndexOf("Fixing set")>-1)
						{
							fixing = true;
							inputs = false;
							foundament = false;
							bricks = false;
						}
						if(s.IndexOf("Foundament set")>-1)
						{
							foundament = true;
							inputs = false;
							fixing = false;
							bricks = false;
						}
						if(s.IndexOf("Bricks vol set")>-1)
						{
							bricks = true;
							inputs = false;
							fixing = false;
							foundament = false;
						}
					}
				}
			}
			catch(Exception e){
				Warn wrn = new Warn ();
				wrn.SetLabel (e.Message);
				wrn.Modal = true;
				wrn.Show ();
			}
			/*catch{
				Warn wrn = new Warn ();
				wrn.SetLabel ("Ошибка импорта результатов!");
				wrn.Modal = true;
				wrn.Show ();
			}*/
		}
Example #4
0
 protected void OnButton3Clicked(object sender, EventArgs e)
 {
     bool params_OK = true;
     float pressure = (float)force_spin.Value*9.8f;//P=mg, http://ru.wikipedia.org/wiki/%D0%92%D0%B5%D1%81
     Materials material = Materials.None;
     switch (objMaterial.ActiveText) {
     case "Гипсокартон":
         material = Materials.GKL;
         break;
     case "Дерево":
         material = Materials.Tree;
         break;
     case "Металл":
         material = Materials.Metal;
         break;
     default:
         params_OK &= false;
         break;
     }
     int fix_point = objMaterial.Active - 2;
     float lenght = (float)objLenght.Value;
     int fix_pointsN = (int)fixPointsN.Value;
     pressure /= fix_pointsN;
     Materials wall_material = Materials.None;
     switch (wallMaterial.ActiveText) {
     case "Гипсокартон":
         wall_material = Materials.GKL;
         break;
     case "Дерево":
         wall_material = Materials.Tree;
         break;
     case "Кирпич":
         wall_material = Materials.Brick;
         break;
     case "Бетон":
         wall_material = Materials.Concrete;
         break;
     case "Пеноблок":
         wall_material = Materials.FoamBlock;
         break;
     default:
         params_OK &= false;
         break;
     }
     float wall_lenght = (float)wallLenght.Value;
     if ((pressure > 0) && (fix_point > -2 && fix_point < 2) && (lenght > 0) && (fix_pointsN > -1) && (wall_lenght > -1) && params_OK) {
         params_OK |= true;
         //подбираем
         Storage.passed.Clear();
         Calculator.GenerateByMaterialList (material, wall_material);
         Calculator.GenerateByLenght (wall_lenght, lenght);
         Calculator.GenerateByForce (fix_point, pressure, lenght, wall_material);
         if (Storage.passed.Count < 1) {
             //Error! Can't fix it by any material:(
             Warn wrn = new Warn ();
             wrn.SetLabel ("Мы не нашли подходящего крепежа в нашей базе!");
             wrn.Modal = true;
             wrn.Show ();
         } else {
             GtkLabel4.Text = Storage.passed.Count.ToString ();
             btnForward.Sensitive = true;
             nameOfCurrentFix.Text += Storage.passed [0].NameToString ();
             imgFixPreview.Pixbuf = new Gdk.Pixbuf (Storage.GetStreamFromResource (Storage.passed [0].img_name));
             spinD.Value = Storage.passed [0].d;
             spinLenght.Value = Storage.passed [0].lenght;
             spinAvForce.Value = Storage.passed [0].max_avulsion_force;
             spinMaxCutForce.Value = Storage.passed [0].max_cut_force;
             spinMaxA.Value = Storage.passed [0].max_a;
             spinMaxS.Value = Storage.passed [0].max_s;
             spinFixPoints.Value = fixPointsN.Value;
         }
     } else {
         Warn wrn = new Warn();
         wrn.SetLabel("Что-то не так с параметрами крепежа! Проверьте данные, которые ввели. Если это не помогло, свяжитесь с разработчиком!");
         wrn.Modal = true;
         wrn.Show();
         params_OK &= false;
     }
 }
Example #5
0
		public static void WriteAnswers(string filename, string inputDataState, string foundamentSet, string bricksSet)
		{
			try
			{
				StreamWriter writer = new StreamWriter (filename);
				writer.WriteLine ("# Here # - is comment.");
				writer.WriteLine ("# Inputs range: objMaterial planeToFix objLenght fixPointsN wallMaterial wallLenght build_lenght " +
					"build_hight found_flat addit_P hight deep beton build_lenght1 build_weight1 build_hight materialOfBuild conWeight holesS roofType roofHight minh");
				writer.WriteLine (inputDataState);
				writer.WriteLine ("# Fixing set");
				foreach (Mount mnt in passed)
					writer.WriteLine (mnt.ToString ());
				writer.WriteLine ("# Foundament set");
				writer.WriteLine (foundamentSet);
				writer.WriteLine ("# Bricks vol set");
				writer.WriteLine (bricksSet);
				writer.Close ();
			}
			catch(System.IO.FileNotFoundException){
				Warn wrn = new Warn ();
				wrn.SetLabel ("Нет такого файла!");
				wrn.Modal = true;
				wrn.Show ();
			}
			catch(System.IO.IOException){
				Warn wrn = new Warn ();
				wrn.SetLabel ("Ошибка ввода-вывода!");
				wrn.Modal = true;
				wrn.Show ();
			}
		}