private void timer_readCfg_Tick(object sender, EventArgs e) { this.timer_readCfg.Enabled = false; if (File.Exists(str_cfgfile)) { ArrayList al_tmp = new ArrayList(); al_tmp = Form_Main.ReadAllValues("REMOVE_SENTENCES", str_cfgfile); if (al_tmp.Count < 1) { MessageBox.Show("Please add sentences you want to remove.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); Form_RemSen_AddSen frsas = new Form_RemSen_AddSen(); frsas.ShowDialog(); } else { for (int idx = 0; idx < al_tmp.Count; idx++) { String str_tmp = al_tmp[idx].ToString(); str_tmp = str_tmp.Replace("$$Rem$$", ""); al_addSen.Add(str_tmp); } } } else { File.Create(str_cfgfile); MessageBox.Show("Please add sentences you want to remove.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); Form_RemSen_AddSen frsas = new Form_RemSen_AddSen(); frsas.ShowDialog(); } this.btn_addsen.Enabled = true; }
private void timer_remove_Tick(object sender, EventArgs e) { this.timer_remove.Enabled = false; Form_Main.AddTextToListbox(this.lb_info, "Begin to remove sentences."); foreach (FileInfo finfo in l_listfiles) { Form_Main.AddTextToListbox(this.lb_info, "Current file: " + finfo.FullName); String str_read = ""; StreamReader sr = new StreamReader(finfo.FullName); str_read = sr.ReadToEnd(); sr.Close(); for (int idx = 0; idx < al_addSen.Count; idx++) { if (str_read.Contains(al_addSen[idx].ToString())) { Form_Main.AddTextToListbox(this.lb_info, "Remove : \"" + al_addSen[idx].ToString() + "\""); str_read = str_read.Replace(al_addSen[idx].ToString() + "\r\n", ""); } } StreamWriter sw = new StreamWriter(finfo.FullName); sw.Write(str_read); sw.Flush(); sw.Close(); } MessageBox.Show("Done!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Main.AddTextToListbox(this.lb_info, "Done!"); this.grpBox_settings.Enabled = true; this.tb_filepath.Text = ""; }
private void btn_run_Click(object sender, EventArgs e) { this.lb_info.Items.Clear(); var sourceLang = this.comBox_sourceLang.Text; var pathIn = this.tb_path.Text; if (!Directory.Exists(pathIn)) { MessageBox.Show("The Project Location does not exist.\r\n" + pathIn, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); this.tb_path.Text = ""; Form_Main.AddTextToListbox(this.lb_info, "Please enter a valid Project Location."); } else { this.panel_set.Enabled = false; this.btn_run.Enabled = false; int copyCount = 0; var pathOut = Directory.GetParent(pathIn).FullName; if (b_sync) { pathOut = Path.Combine(pathOut, "3_ForTrans_Xliff"); copyCount = copyXliffFiles(pathIn, sourceLang, pathOut); MessageBox.Show("Done!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Main.AddTextToListbox(this.lb_info, copyCount.ToString() + " file(s) copied."); } else if (b_tm) { pathOut = Path.Combine(pathOut, "3_ForTM_Xliff"); copyCount = copyXliffFiles(pathIn, sourceLang, pathOut); MessageBox.Show("Done!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Main.AddTextToListbox(this.lb_info, copyCount.ToString() + " file(s) copied."); } else if (b_xml) { pathOut = Path.Combine(pathOut, "4_TargetTranslated"); copyCount = copyTargetFiles(pathIn, sourceLang, pathOut); MessageBox.Show("Done!", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Main.AddTextToListbox(this.lb_info, copyCount.ToString() + " file(s) copied."); } else { MessageBox.Show("Please select what files need to copy.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); Form_Main.AddTextToListbox(this.lb_info, "Need to select an option."); } this.panel_set.Enabled = true; this.btn_run.Enabled = true; if (copyCount >= 1) { Process.Start("explorer.exe", pathOut); } } }
private void timer_listFile_Tick(object sender, EventArgs e) { this.timer_listFile.Enabled = false; Form_Main.AddTextToListbox(this.lb_info, "Getting files list......"); ClassLib_RML.GetFilesListOfFolder(str_filepath, b_subfolder, l_listfiles); if (l_listfiles.Count > 0) { this.timer_remove.Enabled = true; } else { MessageBox.Show("No file found!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); Form_Main.AddTextToListbox(this.lb_info, "Can not find any file in the path: " + str_filepath); this.grpBox_settings.Enabled = true; this.tb_filepath.Text = ""; } }
public int copyTargetFiles(String pathIn, String sourceLang, String pathOut) { int copyCount = 0; var dirs = Directory.GetDirectories(pathIn, "*-*", SearchOption.TopDirectoryOnly); foreach (var dir in dirs) { DirectoryInfo dirInfo = new DirectoryInfo(dir); var dirName = dirInfo.Name; if (Regex.IsMatch(dirName, @"[a-z]{2}-[A-Z]{2}") && dirName.Length == 5 && dirName != sourceLang) { var files = Directory.GetFiles(dir, "*.*", SearchOption.AllDirectories); if (files.Length >= 1) { var pathOutLang = Path.Combine(pathOut, dirName); foreach (var file in files) { var type = Path.GetExtension(file).ToLower(); if (type != ".sdlxliff") { if (!Directory.Exists(pathOutLang)) { Directory.CreateDirectory(pathOutLang); } var fileOut = Path.Combine(pathOutLang, Path.GetFileName(file)); if (File.Exists(fileOut)) { File.Delete(fileOut); } Form_Main.AddTextToListbox(this.lb_info, "Copy: \"" + file + "\" To \"" + fileOut + "\"."); File.Copy(file, fileOut); copyCount++; } } } } } return(copyCount); }
private void btn_start_Click(object sender, EventArgs e) { str_filepath = this.tb_filepath.Text; l_listfiles.Clear(); this.grpBox_settings.Enabled = false; this.btn_start.Enabled = false; this.lb_info.Items.Clear(); if (al_addSen.Count > 0) { this.timer_listFile.Enabled = true; } else { MessageBox.Show("No sentence to be removed!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); Form_Main.AddTextToListbox(this.lb_info, "Please add sentences you want to remove."); this.grpBox_settings.Enabled = true; this.btn_start.Enabled = true; } }
private void btn_run_Click(object sender, EventArgs e) { this.lb_info.Items.Clear(); Form_Main.AddTextToListbox(this.lb_info, "----------START----------"); var str_pathInp = this.tb_path.Text; if (!Directory.Exists(str_pathInp)) { MessageBox.Show("The path does not exist.\r\n" + str_pathInp, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); this.tb_path.Text = ""; Form_Main.AddTextToListbox(this.lb_info, "Please check the path!"); } else { var filesIn = Directory.GetFiles(str_pathInp, "*.xlf", SearchOption.AllDirectories); if (filesIn.Length < 1) { MessageBox.Show("Did not find the type of files to be processed in the path.\r\n" + str_pathInp, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tb_path.Text = ""; Form_Main.AddTextToListbox(this.lb_info, "Please check files in the path!"); } else { this.grpBox_settings.Enabled = false; this.btn_run.Enabled = false; String pathOut = ""; if (b_preENG) { pathOut = Path.Combine(Directory.GetParent(str_pathInp).FullName, "Source_forPreENG"); foreach (var fileIn in filesIn) { Form_Main.AddTextToListbox(this.lb_info, fileIn); var fileOut = fileIn.Replace(str_pathInp, pathOut); if (File.Exists(fileOut)) { File.Delete(fileOut); } if (!Directory.Exists(Path.GetDirectoryName(fileOut))) { Directory.CreateDirectory(Path.GetDirectoryName(fileOut)); } fileProcessedForPreENG(fileIn, fileOut, b_onlyFilter); } } else { pathOut = Path.Combine(Directory.GetParent(str_pathInp).FullName, "Source_forCheckFiles"); foreach (var fileIn in filesIn) { Form_Main.AddTextToListbox(this.lb_info, fileIn); var fileOut = fileIn.Replace(str_pathInp, pathOut); if (File.Exists(fileOut)) { File.Delete(fileOut); } if (!Directory.Exists(Path.GetDirectoryName(fileOut))) { Directory.CreateDirectory(Path.GetDirectoryName(fileOut)); } fileProcessedForCheckFiles(fileIn, fileOut); } } MessageBox.Show("Done!", "TIP", MessageBoxButtons.OK, MessageBoxIcon.Information); Form_Main.AddTextToListbox(this.lb_info, "----------END----------"); this.grpBox_settings.Enabled = true; this.btn_run.Enabled = true; Process.Start("explorer.exe", pathOut); } } }