private void kryptonCommandSave_Execute(object sender, EventArgs e) { if (!_textData.IsOpened) { return; } var sfd = new SaveFileDialog { Filter = "*.sav|*.sav", FileName = Path.GetFileName(_textData.Filename) + ".sav", InitialDirectory = Utilities.GetAbsolutePath(Properties.Settings.Default.SavedPath), }; if (sfd.ShowDialog() == DialogResult.Cancel) { return; } SavedTranslationFormatProvider.MakeSavedTranslation( sfd.FileName, _textData.Filename, _textData.Library.GetLibraryInfo(), _totalTime, _textData.Library.GetDefaultEncoding(), dataGridViewText.FirstSelectedRowIndex, _textData.GetLineInfoAll() ); _isModified = false; }
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); } }
private void kryptonButtonOutput_Click(object sender, EventArgs e) { if (DialogResult.No == KryptonMessageBox.Show( "本操作将会覆盖目录下已存在的文件,要开始神一般的杀戮吗?", "哦死你开挂?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)) { return; } int count = 0; try { var textData = new TextData(); foreach (var file in Directory.GetFiles(kryptonTextBox1.Text, "*." + textData.Library.GetSupportExtension())) { count++; textData.OpenScript(file); SavedTranslationFormatProvider.MakeSavedTranslation( Path.Combine(kryptonTextBox2.Text, Path.GetFileName(file) + ".sav"), file, textData.Library.GetLibraryInfo(), TimeSpan.Zero, textData.Library.GetDefaultEncoding(), 0, textData.GetLineInfoAll() ); } } catch (Exception ea) { KryptonMessageBox.Show(ea.Message); } KryptonMessageBox.Show(string.Format("已导入 {0} 个文件。", count)); }
private void CheckAutoSave() { _autoSaveCount++; if (_autoSaveCount >= Properties.Settings.Default.AutoSaveDuration) { SavedTranslationFormatProvider.MakeSavedTranslation( Utilities.GetAbsolutePath( Properties.Settings.Default.AutoSavePath + "\\" + Path.GetFileNameWithoutExtension(_textData.Filename) + ".sav"), _textData.Filename, _textData.Library.GetLibraryInfo(), _totalTime, _textData.Library.GetDefaultEncoding(), dataGridViewText.FirstSelectedRowIndex, _textData.GetLineInfoAll() ); _autoSaveCount = 0; } }
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)); }