private bool CheckRunConfig() { if (!File.Exists(textBox_ProgramPath.Text)) { MessageBox.Show(I18N.GetValue("Program not found!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!Directory.Exists(textBox_InputPath.Text)) { MessageBox.Show(I18N.GetValue("Input folder not found!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!Directory.Exists(textBox_OutputPath.Text)) { MessageBox.Show(I18N.GetValue("Output folder not found!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (textBox_InputPath.Text == textBox_OutputPath.Text) { MessageBox.Show(I18N.GetValue("Input equals Output!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!int.TryParse(textBox_TimeLimit.Text, out int timeLimit)) { MessageBox.Show(I18N.GetValue("Invalid time limit!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } return(true); }
private void checkUpdateToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show(I18N.GetValue("Latest version"), "Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { System.Diagnostics.Process.Start("https://github.com/Azure99/CodeDonut/releases"); } }
private void ReplaceAll() { if (String.IsNullOrEmpty(textBox_FindWhat.Text)) { MessageBox.Show(I18N.GetValue("You must input something that you want to find!")); return; } _fctb.Text = _fctb.Text.Replace(textBox_FindWhat.Text, textBox_ReplaceWith.Text); }
private void button_FAQ_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); sb.AppendLine(I18N.GetValue("MultipleCasesTest is a function for ACMer and OIer.")); sb.AppendLine(I18N.GetValue("You can use it to test your program like Online Judge or produce test data. And it can show judge details for you.")); sb.AppendLine(""); sb.AppendLine("Tips:"); sb.AppendLine(I18N.GetValue("1.Test data should be saved in folder.")); sb.AppendLine(I18N.GetValue("2.CodeDonut will write the runtime output to out file if output file not in folder.")); MessageBox.Show(sb.ToString(), "FAQ", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private bool Exit()//退出 { if (fastColoredTextBox_Main.Text != FileHelper.ReadAllText(currentFilePath)) { if (MessageBox.Show(I18N.GetValue("Do you want to exit?"), "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (MessageBox.Show(I18N.GetValue("Do you want to save changes?"), "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (!FileHelper.WriteAllText(currentFilePath, fastColoredTextBox_Main.Text)) { MessageBox.Show(I18N.GetValue("Can't write source file."), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } } else { return(false); } } FileHelper.WriteAllText("LastOpen.dat", currentFilePath); Config.MainFormHeight = this.Height.ToString(); Config.MainFormWidth = this.Width.ToString(); Config.MainFormMax = this.WindowState == FormWindowState.Maximized ? "1" : "0"; Config.SaveConfig(); //Environment.Exit(0); if (_findForm != null && !_findForm.IsDisposed) { _findForm.Close(); } if (_findForm != null && !_findForm.IsDisposed) { _findForm.Close(); } if (FormCompileErrorInfo != null && !FormCompileErrorInfo.IsDisposed) { FormCompileErrorInfo.Close(); } return(true); }
private void Count() { if (String.IsNullOrEmpty(textBox_FindWhat.Text)) { MessageBox.Show(I18N.GetValue("You must input something that you want to find!")); return; } int cnt = 0; int p = _fctb.Text.IndexOf(textBox_FindWhat.Text); while (p != -1) { cnt++; p = _fctb.Text.IndexOf(textBox_FindWhat.Text, p + textBox_FindWhat.Text.Length); } MessageBox.Show(cnt.ToString(), "Count", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void Replace() { if (_fctb.SelectionLength == 0) { MessageBox.Show(I18N.GetValue("You must select something before replace!")); return; } int selStart = _fctb.SelectionStart; string newText = _fctb.Text.Substring(0, _fctb.SelectionStart) + textBox_ReplaceWith.Text + _fctb.Text.Substring(_fctb.SelectionStart + _fctb.SelectionLength, (_fctb.TextLength - _fctb.SelectionStart - _fctb.SelectionLength)); _fctb.Text = newText; _fctb.SelectionStart = selStart; _fctb.DoSelectionVisible(); }
public static bool CompileFile(string sourceFile) //编译源文件 { MainForm.FormCompileErrorInfo.Visible = false; //隐藏编译信息窗口 ICompiler compiler = CreateCompiler(sourceFile); CompileResult compileResult = compiler.Compile(sourceFile); if (compileResult.ResultCode == CompileResultCode.Successful) { MessageBox.Show(I18N.GetValue("Compile successful"), "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (compileResult.ResultCode == CompileResultCode.UnknownError) { MessageBox.Show(I18N.GetValue(compileResult.Message), I18N.GetValue("Compile Failed"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { MainForm.FormCompileErrorInfo.ClearErrorInfo(); foreach (CompileErrorInfo info in compileResult.CompileErrorInfos) { MainForm.FormCompileErrorInfo.AddErrorInfo(info); } MainForm.FormCompileErrorInfo.Text = I18N.GetValue("Compile Information ") + compileResult.ErrorCount.ToString() + I18N.GetValue("-Error ") + compileResult.WarningCount.ToString() + I18N.GetValue("-Warning ") + compileResult.NoteCount.ToString() + I18N.GetValue("-note"); MainForm.FormCompileErrorInfo.AdjustFormPosition(); MainForm.FormCompileErrorInfo.Visible = true; MainForm.FormCompileErrorInfo.Focus(); } return(compileResult.ResultCode == CompileResultCode.Successful); }
private void button_Run_Click(object sender, EventArgs e) { string path = textBox_Path.Text; if (!File.Exists(path)) { MessageBox.Show(I18N.GetValue("File not found!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (int.TryParse(textBox_TimeLimit.Text, out int timelimit) == false) { MessageBox.Show(I18N.GetValue("Time limit must be a integer!"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } _judger = new Judger.Judger(path, timelimit); ChangeCtrlsStatus(true); backgroundWorker_Main.RunWorkerAsync(); }
private void Find(FindType type) { if (String.IsNullOrEmpty(textBox_FindWhat.Text)) { MessageBox.Show(I18N.GetValue(I18N.GetValue("You must input something that you want to find!"))); return; } int startP, p; if (type == FindType.Last) { startP = _fctb.SelectionStart - 1; if (startP < 0)//防止起始位置小于0 { startP = 0; } p = _fctb.Text.LastIndexOf(textBox_FindWhat.Text, startP); } else { startP = _fctb.SelectionStart + _fctb.SelectionLength; p = _fctb.Text.IndexOf(textBox_FindWhat.Text, startP); } if (p == -1) { MessageBox.Show(I18N.GetValue("Can't find"), "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { _fctb.SelectionStart = p; _fctb.SelectionLength = textBox_FindWhat.Text.Length; _fctb.DoSelectionVisible(); //调整滚动条位置 _fctb.Focus(); //切换焦点 } }
private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show(I18N.GetValue("By Azure99 QQ:961523404")); }