private void saveToTxt() // saves data to txt { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile(); StreamWriter sw = new StreamWriter(fs); for (int i = 1; i <= cables.Count; i++) { sw.WriteLine("Cable nr: " + cables[i].nrCable); sw.WriteLine("Nazwa systemu: " + cables[i].systemName); sw.WriteLine("Siła sprężająca [kN]: " + cables[i].prestressForce); sw.WriteLine("Współczynnik tarcia: " + cables[i].friction); sw.WriteLine("Ilość kabli: " + cables[i].quantityCable); sw.WriteLine("Zakotwienie czynne kabla: Poczatek=" + cables[i].cableBeginActive.ToString()); sw.WriteLine("Zakotwienie czynne kabla: Koniec=" + cables[i].cableEndActive.ToString() + "\n"); sw.WriteLine("Rzędne kabla nr " + i + "[m]"); sw.WriteLine("Nr" + "\t" + "X" + "\t" + "Y"); for (int j = 0; j < cables[i].cableOrdinates.Count(); j++) { sw.WriteLine((j + 1) + "\t" + cables[i].cableOrdinates[j].X + "\t" + cables[i].cableOrdinates[j].Y); } sw.WriteLine("\n"); // -----------------------------Forces in one cable-------------------------------------// sw.WriteLine("Sily od kabla nr " + i + " [kN]"); sw.WriteLine("Nr" + "\t" + "X" + "\t" + "Y"); for (int j = 0; j < cables[i].Forces().Count(); j++) { sw.WriteLine((j + 1) + "\t" + cables[i].Forces()[j].X.ToString("N2") + "\t" + cables[i].Forces()[j].Y.ToString("N2")); } sw.WriteLine("\n"); // -----------------------------Sum Forces -------------------------------------// } sw.WriteLine("Sily calkowite"); sw.WriteLine("Nr" + "\t" + "X" + "\t" + "Y"); for (int i = 0; i < SumForcesManager.SumForces(cables).Count(); i++) { sw.WriteLine((i + 1) + "\t" + SumForcesManager.SumForces(cables)[i].X.ToString("N2") + "\t" + SumForcesManager.SumForces(cables)[i].Y.ToString("N2")); } sw.WriteLine("\n"); sw.Close(); } }
private void ForcesSum_Click(object sender, EventArgs e) // shows a new window with sum forces { SumForces openForm = new SumForces(SumForcesManager.SumForces(cables)); openForm.Show(); }