private void kryptonButtonInput_Click(object sender, EventArgs e) { if (DialogResult.No == KryptonMessageBox.Show( "���������Ḳ��Ŀ¼���Ѵ��ڵ��ļ���Ҫ��ʼ��һ���ɱ¾��", "Ŷ���㿪�ң�", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) return; int count = 0; try { foreach (var file in Directory.GetFiles(kryptonTextBox2.Text, "*.sav")) { count++; var textData = new TextData(); var stfp = new SavedTranslationFormatProvider(file); textData.LoadTranslation(Path.Combine(kryptonTextBox1.Text, Path.GetFileName(stfp.ScriptPath)), stfp.Lines); textData.BuildScript(Path.Combine(kryptonTextBox3.Text, Path.GetFileName(stfp.ScriptPath))); } } catch (Exception ea) { KryptonMessageBox.Show(ea.Message); } KryptonMessageBox.Show(string.Format("�ѵ��� {0} ���ļ���", count)); }
internal void LoadTranslation(string filename, SavedTranslationFormatProvider.LineInfo[] lines) { if (IsOpened) { if (Path.GetFileName(_filename) != Path.GetFileName(filename)) OpenScript(filename); } else { OpenScript(filename); } _stackRedo.Clear(); int ii = 0; foreach (var line in lines) { if (line.Index == -1) //old ver { try { _dtTexts.Rows[ii++]["New_Text"] = line.Text; } catch (Exception e) { if (isFirstTime) { KryptonMessageBox.Show(string.Format("在 {0} 导入第 {1} 行时发生错误:{2}", Path.GetFileName(filename), ii, e.Message)); isFirstTime = true; } } } else //new ver { if (_dtTexts.Rows.Find(line.Index) == null) continue; _dtTexts.Rows.Find(line.Index)["New_Text"] = line.Text; } } }
private void kryptonCommandOpen_Execute(object sender, EventArgs e) { var ofd = new OpenFileDialog { Filter = "*.txt;*.sav;*.autosave|*.txt;*.sav;*.autosave", FileName = Path.GetFileName(_textData.Filename), InitialDirectory = Utilities.GetAbsolutePath(Properties.Settings.Default.SavedPath), }; if (ofd.ShowDialog() == DialogResult.Cancel) return; try { var stfp = new SavedTranslationFormatProvider(ofd.FileName); var file = CheckFileExists(stfp.ScriptPath); if (String.IsNullOrEmpty(file)) { KryptonMessageBox.Show("���ҵ���Ӧ�Ľű��ļ���"); return; } _totalTime = stfp.TotalTime; _textData.LoadTranslation(file, stfp.Lines); _isModified = false; //goto last modified-line dataGridViewText.FirstSelectedRowIndex = stfp.LastLine; dataGridViewText.MakeSelectedLineToCenterScreen(); _currentTime = TimeSpan.Zero; textBoxNewText.Focus(); } catch (Exception ex) { KryptonMessageBox.Show(ex.Message); } }