public Fv(string fileNameTXT, string fileLogName) { string pdfName = fileNameTXT.Replace(".txt", ".pdf"); conf Config = new conf(); FileStream fs = new FileStream(fileNameTXT, FileMode.Open, FileAccess.ReadWrite); DataTable docNames = new DataTable(); docNames.Columns.Add("WZ", typeof(string)); StreamReader sr = new StreamReader(fs); while (!sr.EndOfStream) { string text1 = sr.ReadLine().Replace(" ", ""); compilerDocName.All allCompiler = new ocr_wz.compilerDocName.All(text1); string text = allCompiler.resultText; if ( text.Contains("F/") || (text.Contains("Nu") && text.Contains("dow") && text.Contains("du")) ) { if (text.Contains("F/")) { compilerDocName.Fv FvName = new ocr_wz.compilerDocName.Fv(text); counter.Fv licznikFv = new ocr_wz.counter.Fv(FvName.resultFV); if (licznikFv.result0 != null) { docNames.Rows.Add(licznikFv.result0); } } else if (text.Contains("Nu") && text.Contains("dow") && text.Contains("du")) { compilerDocName.Wz WzName = new ocr_wz.compilerDocName.Wz(text); counter.Wz licznikWz = new ocr_wz.counter.Wz(WzName.resultWZ); if (licznikWz.result0 != null) { docNames.Rows.Add(licznikWz.result0); } } } } if (docNames.Rows.Count == 0) { string docName = pdfName.Replace(Config.inPath + "\\!ocr\\po_ocr\\", ""); Copy CopyNewName = new Copy(pdfName, "0", docName, fileLogName); CopyNewName.CopyOther(); } else { var UniqueRows = docNames.AsEnumerable().Distinct(DataRowComparer.Default); DataTable uniqDocNames = UniqueRows.CopyToDataTable(); StreamWriter SW; SW = File.AppendText(fileLogName); SW.WriteLine("Tablica dokumentów:"); SW.Close(); int ileFV = 0; int ileWZ = 0; foreach (DataRow row in uniqDocNames.Rows) { StreamWriter SW2; SW2 = File.AppendText(fileLogName); SW2.WriteLine(row.Field <string>(0)); SW2.Close(); string docName = row.Field <string>(0); if (docName.Contains("F_")) { ileFV++; } else if (docName.Contains("WZ_")) { ileWZ++; } } if (ileFV == ileWZ || ileWZ > ileFV) { foreach (DataRow row in uniqDocNames.Rows) { if (row.Field <string>(0).Contains("WZ_")) { yearDocs WZ = new yearDocs(row.Field <string>(0)); WZ.yearWZ(); Copy CopyNewName = new Copy(pdfName, WZ.year, row.Field <string>(0), fileLogName); CopyNewName.CopyWZFV(); } } } else { foreach (DataRow row in uniqDocNames.Rows) { string docName = row.Field <string>(0); if (docName.Contains("F_")) { yearDocs readYear = new yearDocs(docName); readYear.yearFV(); Copy CopyNewName = new Copy(pdfName, readYear.year, docName, fileLogName); CopyNewName.CopyFV(); } } } fs.Close(); } }
private void FormKB_KeyDown(object sender, KeyEventArgs e) { #region PLAYER MOVEMENT if (e.KeyCode == Keys.Right) { if (Player1.Location.X + Player1.Width > this.Width) { PlayerOneMovement = 0; } else { SpeedOfPlayer = 7; PlayerOneMovement = SpeedOfPlayer; } } else if ((e.KeyCode == Keys.Left)) { if (Player1.Location.X < 0) { PlayerOneMovement = 0; } else if (Player1.Location.X > 0) { SpeedOfPlayer = 7; PlayerOneMovement = -SpeedOfPlayer; } } // When the esc key is pressed, prompt user if they want to save the game before exiting else if (e.KeyCode == Keys.Escape) { Pause = true; DialogResult dialogResult = MessageBox.Show("Do you want to save your score before closing the game?", "PongWithMyo", MessageBoxButtons.YesNoCancel); if (dialogResult == DialogResult.Yes) { if ((File.Exists(Path_PlayerOne))) { StreamWriter SW1; StreamWriter SW1_SO; SW1 = File.AppendText(Path_PlayerOne); SW1_SO = File.AppendText(Path_PlayerOne_SCOREONLY); SW1.WriteLine(ScoreOne + " - Player One " + DateTime.Now); SW1_SO.WriteLine(ScoreOne); MessageBox.Show("Player One's Score Saved Successfully"); SW1.Close(); SW1_SO.Close(); } if (!File.Exists(Path_PlayerOne)) { StreamWriter SW1; StreamWriter SW1_SO; SW1 = File.CreateText(Path_PlayerOne); SW1_SO = File.CreateText(Path_PlayerOne_SCOREONLY); SW1.Close(); SW1_SO.Close(); SW1 = File.AppendText(Path_PlayerOne); SW1_SO = File.AppendText(Path_PlayerOne_SCOREONLY); SW1.WriteLine(ScoreOne + " - Player One(KB) " + DateTime.Now); SW1_SO.WriteLine(ScoreOne); MessageBox.Show("Player One's Score Saved Successfully"); SW1.Close(); SW1_SO.Close(); } if (File.Exists(Path_PlayerTwo)) { StreamWriter SW2; StreamWriter SW2_SO; SW2 = File.AppendText(Path_PlayerTwo); SW2_SO = File.AppendText(Path_PlayerTwo_SCOREONLY); SW2.WriteLine(ScoreTwo + " - Player Two(KB) " + DateTime.Now); SW2_SO.WriteLine(ScoreTwo); MessageBox.Show("Player Two's Score Saved Successfully"); SW2.Close(); SW2_SO.Close(); Form1 f1 = new Form1(); f1.Show(); this.Hide(); } if (!File.Exists(Path_PlayerTwo)) { StreamWriter SW2; StreamWriter SW2_SO; SW2 = File.CreateText(Path_PlayerTwo); SW2_SO = File.CreateText(Path_PlayerTwo_SCOREONLY); SW2.Close(); SW2_SO.Close(); SW2 = File.AppendText(Path_PlayerTwo); SW2_SO = File.AppendText(Path_PlayerTwo_SCOREONLY); SW2.WriteLine(ScoreTwo + " - Player Two " + DateTime.Now); SW2_SO.WriteLine(ScoreTwo); MessageBox.Show("Player Two's Score Saved Successfully"); SW2.Close(); SW2_SO.Close(); Form1 f1 = new Form1(); f1.Show(); this.Hide(); } } // YES if (dialogResult == DialogResult.No) { Form1 f1 = new Form1(); f1.Show(); this.Hide(); } else if (dialogResult == DialogResult.Cancel) { // do nothing } } else if ((e.KeyCode == Keys.A)) { if (Player2.Location.X < 0) { PlayerTwoMovement = 0; } else if (Player2.Location.X > 0) { SpeedOfPlayer = 6; PlayerTwoMovement = -SpeedOfPlayer; } } else if ((e.KeyCode == Keys.D)) { if (Player2.Location.X + Player2.Width > this.Width) { PlayerTwoMovement = 0; } else { SpeedOfPlayer = 6; PlayerTwoMovement = SpeedOfPlayer; } } #endregion #region PAUSING GAME else if ((e.KeyCode == Keys.Space)) { if (!Pause) { Pause = true; } else if (Pause) { Pause = false; } } #endregion }
public Raben(string fileNameTXT, string fileLogName) { conf Config = new conf(); FileStream fs = new FileStream(fileNameTXT, FileMode.Open, FileAccess.ReadWrite); DataTable docNames = new DataTable(); docNames.Columns.Add("WZ", typeof(string)); string pdfName = fileNameTXT.Replace(".txt", ".pdf"); StreamReader sr = new StreamReader(fs); DateTime thisTime = DateTime.Now; string year = (thisTime.ToString().Replace(" ", "_").Replace("-", "").Replace(":", "")).Remove(4).Replace("20", ""); string yearBack = Convert.ToString((Convert.ToInt32(year) - 1)); string yearNext = Convert.ToString((Convert.ToInt32(year) + 1)); string pdfPath = fileNameTXT.Replace(".txt", ".pdf"); String[] documents; while (!sr.EndOfStream) { string text1 = sr.ReadLine().Replace(" ", ""); compilerDocName.All allCompiler = new ocr_wz.compilerDocName.All(text1); string text = allCompiler.resultText; if ( text.Contains("WZ/" + yearBack + "/") || text.Contains("WZ/" + year + "/") || text.Contains("WZ/" + yearNext + "/") || text.Contains("WW" + yearBack + "/") || text.Contains("WW" + year + "/") || text.Contains("WW" + yearNext + "/") ) { compilerDocName.Raben RabenName = new ocr_wz.compilerDocName.Raben(text); documents = RabenName.resultRaben.Split(','); documents = RabenName.resultRaben.Split(';'); foreach (string row in documents) { if (row.Contains("WZ/")) { compilerDocName.Wz WzName = new ocr_wz.compilerDocName.Wz(row); counter.Wz licznikWz = new ocr_wz.counter.Wz(WzName.resultWZ); if (licznikWz.result0 != null) { docNames.Rows.Add(licznikWz.result0); } } else if (row.Contains("WW")) { compilerDocName.Ww WwName = new ocr_wz.compilerDocName.Ww(row); counter.Ww licznikWw = new ocr_wz.counter.Ww(WwName.resultWW); if (licznikWw.result0 != null) { docNames.Rows.Add(licznikWw.result0); } } } } } if (docNames.Rows.Count == 0) { string docName = pdfName.Replace(Config.inPath + "\\!ocr\\po_ocr\\", ""); Copy CopyNewName = new Copy(pdfName, "0", docName, fileLogName); CopyNewName.CopyOther(); } else { var UniqueRows = docNames.AsEnumerable().Distinct(DataRowComparer.Default); DataTable uniqDocNames = UniqueRows.CopyToDataTable(); StreamWriter SW1; SW1 = File.AppendText(fileLogName); SW1.WriteLine("Tablica dokumentów:"); SW1.Close(); foreach (DataRow row in uniqDocNames.Rows) { StreamWriter SW2; SW2 = File.AppendText(fileLogName); SW2.WriteLine(row.Field <string>(0)); SW2.Close(); if (row.Field <string>(0).Contains("WZ_")) { yearDocs WZ = new yearDocs(row.Field <string>(0)); WZ.yearWZ(); Copy CopyNewName = new Copy(pdfName, WZ.year, row.Field <string>(0), fileLogName); CopyNewName.CopyWZdeliveryDoc(); } else if (row.Field <string>(0).Contains("WW")) { yearDocs WW = new yearDocs(row.Field <string>(0)); WW.yearWW(); Copy CopyNewName = new Copy(pdfName, WW.year, row.Field <string>(0), fileLogName); CopyNewName.CopyWWdeliveryDoc(); } } } fs.Close(); }