private void event_CompilationCompleted(object sender, CompilationEventArgs e) { if (Workspace.Compilation.Result.Successful == true) { Status.Set(StatusType.Finish, StatusReset.FiveSeconds, Localization.Status_Compiled); } else { foreach (CompilationError error in Workspace.Compilation.Result.Errors) { this.SetText(error.ToString(), true); } Status.Set(StatusType.Error, StatusReset.FiveSeconds, Localization.Status_CompiledError); // Add empty line because we have errors and we want a empty line to show the output. this.SetText(Environment.NewLine, true); } this.SetText(Workspace.Compilation.Result.Output, true); }
private void event_CompilationStarted(object sender, CompilationEventArgs e) { this.ClearText(); }
public CompilationStatus Start(string fileName) { // Get instance of the editor by file name. Editor editor = Workspace.GetEditorByKey(fileName); if (Starting != null) { CompilationEventArgs e = new CompilationEventArgs(this.FileName); Starting(this, e); if(e.Handled == true) { return CompilationStatus.Routed; } } this.FileName = fileName; if (editor == null) { return CompilationStatus.EditorNull; } else if (this.backgroundWorker.IsBusy == true) { return CompilationStatus.Compiling; } else if (Path.GetExtension(FileName) != ".pwn") { return CompilationStatus.InvalidFile; } else if (string.IsNullOrEmpty(editor.TextEditor.Text) == true || string.IsNullOrWhiteSpace(editor.TextEditor.Text) == true) { Status.Set(StatusType.Error, StatusReset.FiveSeconds, Localization.Status_EmptyText); return CompilationStatus.EmptyText; } // Disable 'Save*' menu items. this.mainForm.saveToolStripMenuItem.Enabled = false; this.mainForm.savesAsToolStripMenuItem.Enabled = false; this.mainForm.saveAllToolStripMenuItem.Enabled = false; // Saving all files opened. Status.Set(StatusType.Warning, StatusReset.None, Localization.Status_SavingFiles); foreach (Editor currentEditor in Workspace.GetEditors().Values) { if (currentEditor.IsModified == true) { currentEditor.Save(); } } Status.Set(StatusType.Warning, StatusReset.None, Localization.Status_Compiling); this.backgroundWorker.RunWorkerAsync(); if (Started != null) { Started(this, new CompilationEventArgs(editor, fileName)); } return CompilationStatus.Started; }
public CompilationStatus Cancel() { if (this.backgroundWorker.IsBusy == false) { return CompilationStatus.NotRunning; } if (Canceling != null) { CompilationEventArgs e = new CompilationEventArgs(this.FileName); Canceling(this, e); if (e.Handled == true) { return CompilationStatus.Routed; } } this.backgroundWorker.CancelAsync(); return CompilationStatus.Canceled; }