void RunnerManager_RunnerManagerUnhanledRuntimeException(string id, string ExceptionType, string ExceptionMessage, string StackTraceData, List <RunManager.StackTraceItem> StackTrace) { string localiseMsg = RuntimeExceptionsStringResources.Get(ExceptionMessage); WorkbenchServiceFactory.OperationsService.AddTextToOutputWindowSync(id, string.Format(Form1StringResources.Get("OW_RUNTIME_EXCEPTION{0}_MESSAGE{1}"), ExceptionType, localiseMsg) + Environment.NewLine); if (StackTraceData != null) { WorkbenchServiceFactory.OperationsService.AddTextToOutputWindowSync(id, string.Format(Form1StringResources.Get("OW_RUNTIME_EXCEPTION_STACKTRACE{0}"), StackTraceData) + Environment.NewLine); } RunManager.StackTraceItem ToSend = null; foreach (RunManager.StackTraceItem StackTraceItem in StackTrace) { if (StackTraceItem.SourceFileName != null) { if (ToSend == null && File.Exists(StackTraceItem.SourceFileName)) { ToSend = StackTraceItem; } if (Workbench.UserOptions.SkipStakTraceItemIfSourceFileInSystemDirectory && (Path.GetDirectoryName(StackTraceItem.SourceFileName) == WorkbenchServiceFactory.BuildService.CompilerOptions.SearchDirectory || Path.GetDirectoryName(StackTraceItem.SourceFileName) == WorkbenchServiceFactory.BuildService.CompilerOptions.SearchDirectory + "Source")) { continue; } if (!(bool)Workbench.VisualEnvironmentCompiler.SourceFilesProvider(StackTraceItem.SourceFileName, PascalABCCompiler.SourceFileOperation.Exists)) { string fn = Path.Combine(WorkbenchStorage.LibSourceDirectory, Path.GetFileName(StackTraceItem.SourceFileName)); if (File.Exists(fn)) { StackTraceItem.SourceFileName = fn; } else { continue; } } ToSend = StackTraceItem; break; } } if (ToSend != null) { List <PascalABCCompiler.Errors.Error> list = new List <PascalABCCompiler.Errors.Error>(); list.Add(new RuntimeException( string.Format( Form1StringResources.Get("ERRORLIST_RUNTIME_EXCEPTION_MESSAGE{0}"), localiseMsg.Replace(Environment.NewLine, " ")), ToSend.SourceFileName, 0, ToSend.LineNumber) ); Workbench.ErrorsListWindow.ShowErrorsSync(list, true); if (RunnerManager.Count > 0) { RunnerManager.KillAll(); } } }
private void LabelEditFinished(object sender, NodeLabelEditEventArgs e) { this.tvProjectExplorer.LabelEdit = false; PascalABCCompiler.IFileInfo fi = items[e.Node] as PascalABCCompiler.IFileInfo; if (e.Label == null) { return; } if (!PascalABCCompiler.Tools.CheckFileNameValid(e.Label)) { e.CancelEdit = true; MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_NAME"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.Compare(Path.GetExtension(e.Label), ".pas", true) != 0) { e.CancelEdit = true; MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_EXTENSION"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (File.Exists(Path.Combine(Path.GetDirectoryName(fi.Name), e.Label))) { e.CancelEdit = true; MessageBox.Show(string.Format(Form1StringResources.Get("FILE_ALREADY_EXISTS{0}"), e.Label), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string oldFileName = fi.Path; ProjectFactory.Instance.RenameFile(fi, e.Label); if (oldFileName == ProjectFactory.Instance.CurrentProject.MainFile) { ProjectFactory.Instance.CurrentProject.MainFile = System.IO.Path.Combine(ProjectFactory.Instance.CurrentProject.ProjectDirectory, e.Label); } WorkbenchServiceFactory.FileService.RenameFile(oldFileName, fi.Path); CodeCompletionActionsManager.RenameUnit(fi.Path, Path.GetFileNameWithoutExtension(e.Label)); string oldFileNameWithoutExt = Path.Combine(Path.GetDirectoryName(oldFileName), Path.GetFileNameWithoutExtension(oldFileName)); string newFilePath = Path.Combine(Path.GetDirectoryName(oldFileName), e.Label); if (File.Exists(oldFileNameWithoutExt + ".fmabc")) { string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc"); File.Copy(fmabcFullName, Path.Combine(Path.GetDirectoryName(oldFileName), Path.GetFileNameWithoutExtension(e.Label) + ".fmabc"), true); File.Delete(fmabcFullName); } ProjectFactory.Instance.SaveProject(); WorkbenchServiceFactory.FileService.SaveAll(false); WorkbenchServiceFactory.FileService.CloseFile(newFilePath); WorkbenchServiceFactory.FileService.OpenFile(newFilePath, Path.GetFileName(newFilePath)); WorkbenchServiceFactory.DesignerService.SetActiveDesignerDirty(); WorkbenchServiceFactory.DesignerService.GenerateAllDesignersCode(); /*if (File.Exists(oldFileNameWithoutExt + ".resources")) * { * string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc"); * File.Copy(fmabcFullName, Path.Combine(Path.GetDirectoryName(e.Label), Path.GetFileNameWithoutExtension(e.Label) + ".fmabc"), true); * File.Delete(fmabcFullName); * }*/ }
void NewProjectFormFormClosing(object sender, FormClosingEventArgs e) { if (this.DialogResult == DialogResult.Cancel) { return; } try { if (this.lvTemplates.SelectedItems.Count == 0) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("PROJECT_TEMPLATE_NOT_SELECTED"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(tbProjectDir.Text)) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("PROJECT_DIRECTORY_EMPTY"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(tbProjectName.Text)) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("PROJECT_NAME_EMPTY"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Directory.Exists(tbProjectDir.Text)) { e.Cancel = true; MessageBox.Show(string.Format(Form1StringResources.Get("DIRECTORY_ALREADY_EXISTS{0}"), tbProjectDir.Text), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FileInfo fi = new FileInfo(Path.Combine(tbProjectDir.Text, tbProjectName.Text)); } catch (PathTooLongException ex) { e.Cancel = true; MessageBox.Show(string.Format(Form1StringResources.Get("TOO_LONG_FILE_NAME{0}"), Path.Combine(tbProjectDir.Text, tbProjectName.Text)), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (ArgumentException ex) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("ERROR_IN_PATH"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } catch (Exception ex) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("ERROR_IN_PROJECT_CREATION"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void saveFileDialog1_FileOk(object sender, CancelEventArgs e) { //ReplaceLastFile(CurrentSourceFileName, saveFileDialog1.FileName); string fn = Tools.FileNameToLower(saveFileDialog1.FileName); if (OpenDocuments.ContainsKey(fn) && OpenDocuments[fn] != CurrentCodeFileDocument) { MessageBox.Show(Form1StringResources.Get("ERROR_FILE_EXISTS_IN_CODEPAGES"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SaveFileAs(CurrentCodeFileDocument, saveFileDialog1.FileName); AddLastFile(saveFileDialog1.FileName); } }
bool QuestionAndSaveFile(CodeFileDocumentControl tp) { CurrentCodeFileDocument = tp; DialogResult result = MessageBox.Show(string.Format(Form1StringResources.Get("SAVE_CHANGES_IN_FILE{0}"), Path.GetFileName(tp.FileName)), PascalABCCompiler.StringResources.Get("!CONFIRM"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { SaveSelFile(CurrentCodeFileDocument); } else if (result == DialogResult.Cancel) { return(false); } return(true); }
int QuestionAndSaveProject() { DialogResult result = MessageBox.Show(string.Format(Form1StringResources.Get("SAVE_CHANGES_IN_PROJECT{0}"), ProjectFactory.Instance.CurrentProject.Name), PascalABCCompiler.StringResources.Get("!CONFIRM"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { ProjectFactory.Instance.SaveProject(); UpdateSaveButtonsEnabled(); return(0); } else if (result == DialogResult.Cancel) { return(2); } return(1); }
internal void SaveFileAs(CodeFileDocumentControl TbPage, string FileName) { try { if (TbPage.DesignerAndCodeTabs != null) { TbPage.GenerateDesignerCode(null); } CodeFileDocumentControl dt = TbPage; WatcherService.DisableWatcher(FileName); //dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding; if (!dt.TextEditor.CanSaveWithCurrentEncoding()) { dt.TextEditor.Encoding = Encoding.UTF8; dt.TextEditor.SaveFile(FileName); dt.TextEditor.Encoding = VisualEnvironmentCompiler.DefaultFileEncoding; } else { dt.TextEditor.SaveFile(FileName); } WatcherService.EnableWatcher(FileName); OpenDocuments.Remove(Tools.FileNameToLower(dt.FileName)); OpenDocuments.Add(Tools.FileNameToLower(FileName), TbPage); WorkbenchServiceFactory.CodeCompletionParserController.RenameFile(dt.FileName, FileName); TbPage.SaveFormFile(FileName); dt.DocumentChanged = false; dt.FileName = FileName; dt.DocumentSavedToDisk = true; dt.SetHighlightingStrategyForFile(FileName); SetTabPageText(TbPage); if (!WorkbenchServiceFactory.RunService.HasRunArgument(FileName.ToLower())) { WorkbenchServiceFactory.RunService.AddRunArgument(FileName.ToLower(), ""); } if (TbPage == CurrentCodeFileDocument) { UpdateSaveButtonsEnabled(); } } catch (Exception ex) { MessageBox.Show(String.Format(Form1StringResources.Get("SAVE_FILE_ERROR_TEXT{0}"), FileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void LoadProject(string projectName, PascalABCCompiler.IProjectInfo project) { TreeNode proj_tn = this.tvProjectExplorer.Nodes.Add(Form1StringResources.Get("MR_PROJECT") + " " + projectName); ProjectNode = proj_tn; project_item_nodes.Add(proj_tn); proj_tn.ImageIndex = ProjectImageIndex; proj_tn.SelectedImageIndex = ProjectImageIndex; TreeNode ref_tn = proj_tn.Nodes.Add(Form1StringResources.Get("PRJ_PROJECT_REFERENCES")); ReferencesNode = ref_tn; reference_nodes.Add(ref_tn); ref_tn.ImageIndex = ClosedReferencesImageIndex; foreach (PascalABCCompiler.IFileInfo fi in project.SourceFiles) { TreeNode tn = proj_tn.Nodes.Add(fi.Name); tn.ImageIndex = SourceFileImageIndex; tn.SelectedImageIndex = SourceFileImageIndex; items[tn] = fi; if (VisualPABCSingleton.MainForm.IsForm(fi.Path)) { tn.ImageIndex = FormImageIndex; tn.SelectedImageIndex = FormImageIndex; NodeInfo ni = new NodeInfo(); ni.IsForm = true; tn.Tag = ni; } source_item_nodes.Add(tn); } foreach (PascalABCCompiler.IReferenceInfo ri in project.References) { TreeNode tn = ref_tn.Nodes.Add(ri.AssemblyName); tn.ImageIndex = ReferenceImageIndex; tn.SelectedImageIndex = ReferenceImageIndex; items[tn] = ri; reference_item_nodes.Add(tn); } proj_tn.Expand(); }
//exclude from project private void pRJEXCLUDEToolStripMenuItem_Click(object sender, EventArgs e) { object o = items[this.tvProjectExplorer.SelectedNode]; if (o != null) { if (o is PascalABCCompiler.IFileInfo) { PascalABCCompiler.IFileInfo fi = o as PascalABCCompiler.IFileInfo; if (ProjectFactory.Instance.CurrentProject.MainFile != fi.Path) { ProjectTask.ExcludeFile(fi); this.tvProjectExplorer.Nodes.Remove(this.tvProjectExplorer.SelectedNode); ProjectFactory.Instance.SaveProject(); } else { MessageBox.Show(Form1StringResources.Get("CANNOT_EXCLUDE_MAIN_FILE"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
void MainForm_Activated(object sender, EventArgs e) { try { if (wasChangedExternally) { wasChangedExternally = false; string mes = null; if (!File.Exists(fileName)) { mes = Form1StringResources.Get("FILE_NOT_EXIST_MESSAGE"); if (MessageBox.Show(fileName + "\n\n" + mes, Form1StringResources.Get("CHANGED_FILE"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { WorkbenchServiceFactory.FileService.SetFileAsChanged(fileName); } else { WorkbenchServiceFactory.FileService.CloseFile(fileName); } return; } mes = Form1StringResources.Get("FILE_CHANGED_MESSAGE"); if (MessageBox.Show(fileName + "\n\n" + mes, Form1StringResources.Get("CHANGED_FILE"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { WorkbenchServiceFactory.FileService.ReloadFile(fileName); } else { WorkbenchServiceFactory.FileService.SetFileAsChanged(fileName); } } } catch (Exception ex) { } }
public bool Run(ICodeFileDocument tabPage, bool forDebugging, bool startWithGoto, bool needFirstBreakpoint) { lock (o) { bool attachdbg = forDebugging || startWithGoto || needFirstBreakpoint; //|| WorkbenchServiceFactory.DebuggerManager.HasBreakpoints(); bool fictive_attach = false; BuildService.CompilerOptions.UseDllForSystemUnits = false; BuildService.CompilerOptions.OutputFileType = PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton; if (ProjectFactory.Instance.ProjectLoaded) { tabPage = DocumentService.GetTabPageForMainFile(); } if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart) { fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints(); } WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage); Workbench.ErrorsListWindow.ClearErrorList(); DesignerService.GenerateAllDesignersCode(); string runtimeModule; string ModeName; bool RunWithPause = false; if (Workbench.UserOptions.RedirectConsoleIO || forDebugging) { runtimeModule = RedirectIOModeModuleName; ModeName = RedirectIOModeName; if (Workbench.UserOptions.UseDllForSystemUnits && !Workbench.UserOptions.PABCDllChecked) { if (typeof(System.Runtime.CompilerServices.ExtensionAttribute).Assembly != typeof(int).Assembly || PascalABCCompiler.Compiler.get_assembly_path("PABCRtl.dll", false) == null) { Workbench.UserOptions.UseDllForSystemUnits = false; } Workbench.UserOptions.PABCDllChecked = true; } // SSM 09.02.20 - UseDllForSystemUnits включать когда флаг установлен - безо всяких доп. условий if (/*Workbench.UserOptions.DeleteEXEAfterExecute &&*/ Workbench.UserOptions.UseDllForSystemUnits && !startWithGoto && !needFirstBreakpoint) { BuildService.CompilerOptions.UseDllForSystemUnits = true; } } else { runtimeModule = RunModeModuleName; ModeName = RunModeName; RunWithPause = Workbench.UserOptions.PauseInRunModeIfConsole; } bool debug = BuildService.CompilerOptions.Debug; if (forDebugging) { BuildService.CompilerOptions.Debug = true; BuildService.CompilerOptions.ForDebugging = true; Workbench.UserOptions.RedirectConsoleIO = true; } string OutputFileName = null; if (!forDebugging) { if (!ProjectFactory.Instance.ProjectLoaded) { OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO); } else { OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO); } } else { if (!ProjectFactory.Instance.ProjectLoaded) { OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, true); } else { OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, true); } } if (RunWithPause) { RunWithPause = RunWithPause && Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType == PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton; } if (OutputFileName != null) { switch (Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType) { case PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary: if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run) { if (!RunActiveTabPage) { RunActiveTabPage = true; return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint)); } } MessageBox.Show(Form1StringResources.Get("RUN_DLL_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning); RunActiveTabPage = false; break; case PascalABCCompiler.CompilerOptions.OutputType.PascalCompiledUnit: if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run) { if (!RunActiveTabPage) { RunActiveTabPage = true; return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint)); } } RunActiveTabPage = false; MessageBox.Show(Form1StringResources.Get("RUN_PCU_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton: case PascalABCCompiler.CompilerOptions.OutputType.WindowsApplication: if (forDebugging) { BuildService.CompilerOptions.Debug = debug; BuildService.CompilerOptions.ForDebugging = false; if (startWithGoto) { DebuggerManager.ShowDebugTabs = true; DebuggerManager.UpdateBreakpoints(); DebuggerManager.CurrentBreakpoint = DebuggerManager.AddBreakPoint(DocumentService.CurrentCodeFileDocument.FileName, DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1, false); DebuggerManager.AddGoToBreakPoint(DebuggerManager.CurrentBreakpoint); } else if (needFirstBreakpoint) { DebuggerManager.ShowDebugTabs = true; DebuggerManager.UpdateBreakpoints(); if (Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset != 0) { DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset); DebuggerManager.AddGoToBreakPoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset); } else { DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset); } } else { DebuggerManager.UpdateBreakpoints(); DebuggerManager.ShowDebugTabs = false; } } RunActiveTabPage = false; try { RunTabsAdd(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, tabPage); RunnerManager.Run(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, Workbench.UserOptions.RedirectConsoleIO, ModeName, RunWithPause, // Path.GetDirectoryName(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName), // SSM 21.05.19 - исправил. Теперь текущим является каталог, в котором расположен исходник. // Если компилировать программы на сетевом диске, а exe создавать локально, то работает шустро Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.SourceFileDirectory, RunArgumentsTable[tabPage.FileName.ToLower()], attachdbg, fictive_attach); } catch (System.Exception e) { // SSM 22/04/19 - исправляю вылет оболочки при отсутствии exe файла // this.RunnerManager_Exited(OutputFileName); // - это всё равно не срабатывает. Кнопки оказываются в заблокированном состоянии WorkbenchServiceFactory.OperationsService.AddTextToOutputWindowSync(OutputFileName, "Произошла непредвиденная ошибка. Вероятно, на диске отсутствует .exe-файл. Повторите запуск"); //throw; } if (!ProjectFactory.Instance.ProjectLoaded) { DocumentService.ActiveCodeFileDocument = tabPage; } if (forDebugging) { DebuggerOperationsService.AddDebugPage(tabPage); } WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow = Workbench.UserOptions.RedirectConsoleIO; //if (UserOptions1.ConsoleOutput) //AddTextToOutputWindow("Ïðîãðàììà çàïóùåíà"); return(true); } } RunActiveTabPage = false; return(false); } }
public void OpenProject(string projectFileName) { if (!File.Exists(projectFileName)) { MessageBox.Show(string.Format(PascalABCCompiler.StringResources.Get("!PROJECT_NOT_FOUND{0}"), projectFileName), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (ProjectFactory.Instance.ProjectLoaded) { CloseProject(); } try { PascalABCCompiler.IProjectInfo proj = ProjectFactory.Instance.OpenProject(projectFileName); ProjectExplorerWindow.LoadProject(Path.GetFileNameWithoutExtension(projectFileName), ProjectFactory.Instance.CurrentProject); ICSharpCode.FormsDesigner.ToolboxProvider.ReloadSideTabs(false); CloseFilesAndSaveState(); ClearAndSaveWatch(); this.miProjectExplorer.Visible = true; ShowContent(ProjectExplorerWindow, false); UserProjectSettings setts = ProjectUserOptionsManager.LoadOptions(projectFileName); foreach (IReferenceInfo ri in ProjectFactory.Instance.CurrentProject.References) { var path = Compiler.get_assembly_path(Path.Combine(ProjectFactory.Instance.ProjectDirectory, ri.FullAssemblyName), false); if (path == null) { path = Compiler.get_assembly_path(ri.FullAssemblyName, false); } ICSharpCode.FormsDesigner.ToolboxProvider.AddComponentsFromAssembly(PascalABCCompiler.NetHelper.NetHelper.LoadAssembly(path)); } if (setts != null) { foreach (OpenedFileInfo fi in setts.OpenDocuments) { if (fi.InProject) { string f = Path.Combine(proj.ProjectDirectory, fi.FileName); if (File.Exists(f)) { WorkbenchServiceFactory.FileService.OpenFile(f, null); } } else if (File.Exists(fi.FileName)) { WorkbenchServiceFactory.FileService.OpenFile(fi.FileName, null); } if (fi.CaretLine > 0) { CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line = fi.CaretLine; } if (fi.CaretColumn > 0) { CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Column = fi.CaretColumn; } } if (!string.IsNullOrEmpty(setts.CurrentDocument)) { if (!setts.CurrentDocumentIsInProject) { if (File.Exists(setts.CurrentDocument)) { WorkbenchServiceFactory.FileService.OpenFile(setts.CurrentDocument, null); } } else { string f = Path.Combine(proj.ProjectDirectory, setts.CurrentDocument); if (File.Exists(f)) { WorkbenchServiceFactory.FileService.OpenFile(f, null); } } } else { WorkbenchServiceFactory.FileService.OpenFile(proj.MainFile, null); } foreach (WatchExprInfo wi in setts.WatchExprs) { AddVariable(wi.Expression, false); } } else { WorkbenchServiceFactory.FileService.OpenFile(proj.MainFile, null); } ActiveCodeFileDocument = CurrentCodeFileDocument; AddLastProject(projectFileName); if (CodeCompletion.CodeCompletionController.comp != null) { CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = proj; } this.mRPROJECTToolStripMenuItem.Visible = true; this.miCloseProject.Visible = true; } catch (PascalABCCompiler.TooOldProjectFileVersion) { MessageBox.Show(Form1StringResources.Get("TOO_OLD_PROJECT_FILE_VERSION"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(Form1StringResources.Get("ERROR_OPEN_PROJECT"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ChangeContinueDebugNameOnStart() { this.StartDebugButton.ToolTipText = Form1StringResources.Get("M_DEBUGSTART"); this.mDEBUGSTARTToolStripMenuItem.Text = Form1StringResources.Get("M_DEBUGSTART"); }
private void ProjectProperties_FormClosing(object sender, FormClosingEventArgs e) { if (this.DialogResult == DialogResult.Cancel) { return; } if (string.IsNullOrEmpty(this.tbMajor.Text)) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("MAJOR_VERSION_MUST_BE_SET"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { int ver = Convert.ToInt32(this.tbMajor.Text); if (ver < 0) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("MAJOR_VERSION_LESS_ZERO"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("MAJOR_VERSION_MUST_BE_INT"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(this.tbMinor.Text)) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("MINOR_VERSION_MUST_BE_SET"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { int ver = Convert.ToInt32(this.tbMajor.Text); if (ver < 0) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("MINOR_VERSION_LESS_ZERO"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("MINOR_VERSION_MUST_BE_INT"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(this.tbBuild.Text)) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("BUILD_VERSION_MUST_BE_SET"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { int ver = Convert.ToInt32(this.tbBuild.Text); if (ver < 0) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("BUILD_VERSION_LESS_ZERO"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("BUILD_VERSION_MUST_BE_INT"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(this.tbRevision.Text)) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("REVISION_VERSION_MUST_BE_SET"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { int ver = Convert.ToInt32(this.tbRevision.Text); if (ver < 0) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("REVISION_VERSION_LESS_ZERO"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("REVISION_VERSION_MUST_BE_INT"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!string.IsNullOrEmpty(tbAppIcon.Text)) { if (!File.Exists(tbAppIcon.Text) && !File.Exists(Path.Combine(proj.ProjectDirectory, tbAppIcon.Text))) { e.Cancel = true; MessageBox.Show(Form1StringResources.Get("ICON_FILE_NOT_FOUND"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
public override string ToString() { return(string.Format(Form1StringResources.Get("EXCEPTION_IN_START_EXE{0}"), fileName)); }
public bool Run(ICodeFileDocument tabPage, bool forDebugging, bool startWithGoto, bool needFirstBreakpoint) { bool attachdbg = forDebugging || startWithGoto || needFirstBreakpoint; //|| WorkbenchServiceFactory.DebuggerManager.HasBreakpoints(); bool fictive_attach = false; BuildService.CompilerOptions.UseDllForSystemUnits = false; BuildService.CompilerOptions.OutputFileType = PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton; if (ProjectFactory.Instance.ProjectLoaded) { tabPage = DocumentService.GetTabPageForMainFile(); } if (attachdbg && !Workbench.UserOptions.AlwaysAttachDebuggerAtStart) { fictive_attach = !startWithGoto && !needFirstBreakpoint && !DebuggerManager.HasBreakpoints(); } WorkbenchServiceFactory.OperationsService.ClearOutputTextBoxForTabPage(tabPage); Workbench.ErrorsListWindow.ClearErrorList(); DesignerService.GenerateAllDesignersCode(); string runtimeModule; string ModeName; bool RunWithPause = false; if (Workbench.UserOptions.RedirectConsoleIO || forDebugging) { runtimeModule = RedirectIOModeModuleName; ModeName = RedirectIOModeName; if (Workbench.UserOptions.UseDllForSystemUnits && !Workbench.UserOptions.PABCDllChecked) { if (typeof(System.Runtime.CompilerServices.ExtensionAttribute).Assembly != typeof(int).Assembly || PascalABCCompiler.Compiler.get_assembly_path("PABCRtl.dll", false) == null) { Workbench.UserOptions.UseDllForSystemUnits = false; } Workbench.UserOptions.PABCDllChecked = true; } if (Workbench.UserOptions.DeleteEXEAfterExecute && Workbench.UserOptions.UseDllForSystemUnits && !startWithGoto && !needFirstBreakpoint) { BuildService.CompilerOptions.UseDllForSystemUnits = true; } } else { runtimeModule = RunModeModuleName; ModeName = RunModeName; RunWithPause = Workbench.UserOptions.PauseInRunModeIfConsole; } bool debug = BuildService.CompilerOptions.Debug; if (forDebugging) { BuildService.CompilerOptions.Debug = true; BuildService.CompilerOptions.ForDebugging = true; Workbench.UserOptions.RedirectConsoleIO = true; } string OutputFileName = null; if (!forDebugging) { if (!ProjectFactory.Instance.ProjectLoaded) { OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO); } else { OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, Workbench.UserOptions.RedirectConsoleIO); } } else { if (!ProjectFactory.Instance.ProjectLoaded) { OutputFileName = BuildService.Compile(tabPage.FileName, false, runtimeModule, true, true); } else { OutputFileName = BuildService.Compile(ProjectFactory.Instance.CurrentProject, false, runtimeModule, true, true); } } if (RunWithPause) { RunWithPause = RunWithPause && Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType == PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton; } if (OutputFileName != null) { switch (Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileType) { case PascalABCCompiler.CompilerOptions.OutputType.ClassLibrary: if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run) { if (!RunActiveTabPage) { RunActiveTabPage = true; return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint)); } } MessageBox.Show(Form1StringResources.Get("RUN_DLL_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning); RunActiveTabPage = false; break; case PascalABCCompiler.CompilerOptions.OutputType.PascalCompiledUnit: if (DocumentService.ActiveCodeFileDocument != null && DocumentService.ActiveCodeFileDocument != DocumentService.CurrentCodeFileDocument && !DocumentService.ActiveCodeFileDocument.Run) { if (!RunActiveTabPage) { RunActiveTabPage = true; return(Run(DocumentService.ActiveCodeFileDocument, forDebugging, startWithGoto, needFirstBreakpoint)); } } RunActiveTabPage = false; MessageBox.Show(Form1StringResources.Get("RUN_PCU_WARNING_TEXT"), PascalABCCompiler.StringResources.Get("!WARNING"), MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case PascalABCCompiler.CompilerOptions.OutputType.ConsoleApplicaton: case PascalABCCompiler.CompilerOptions.OutputType.WindowsApplication: if (forDebugging) { BuildService.CompilerOptions.Debug = debug; BuildService.CompilerOptions.ForDebugging = false; if (startWithGoto) { DebuggerManager.ShowDebugTabs = true; DebuggerManager.CurrentBreakpoint = DebuggerManager.AddBreakPoint(DocumentService.CurrentCodeFileDocument.FileName, DocumentService.CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.Caret.Line + 1, false); DebuggerManager.AddGoToBreakPoint(DebuggerManager.CurrentBreakpoint); } else if (needFirstBreakpoint) { DebuggerManager.ShowDebugTabs = true; if (Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset != 0) { DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.VarBeginOffset); DebuggerManager.AddGoToBreakPoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset); } else { DebuggerManager.SetFirstBreakpoint(tabPage.FileName, Workbench.VisualEnvironmentCompiler.Compiler.BeginOffset); } } else { DebuggerManager.ShowDebugTabs = false; } } RunActiveTabPage = false; try { RunTabsAdd(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, tabPage); RunnerManager.Run(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName, Workbench.UserOptions.RedirectConsoleIO, ModeName, RunWithPause, Path.GetDirectoryName(Workbench.VisualEnvironmentCompiler.Compiler.CompilerOptions.OutputFileName), RunArgumentsTable[tabPage.FileName.ToLower()], attachdbg, fictive_attach); } catch (System.Exception e) { throw; } if (!ProjectFactory.Instance.ProjectLoaded) { DocumentService.ActiveCodeFileDocument = tabPage; } if (forDebugging) { DebuggerOperationsService.AddDebugPage(tabPage); } WorkbenchStorage.SetCurrentTabPageIfWriteToOutputWindow = Workbench.UserOptions.RedirectConsoleIO; //if (UserOptions1.ConsoleOutput) //AddTextToOutputWindow("Ïðîãðàììà çàïóùåíà"); return(true); } } RunActiveTabPage = false; return(false); }