Exemple #1
0
        public List <SymbolsViewerSymbol> Rename(string expr, string name, string fileName, int line, int column, ref string new_val)
        {
            if (rf == null)
            {
                rf = new RenameForm();
                Form1StringResources.SetTextForAllControls(rf);
            }
            rf.EditValue = name.Trim(' ');
            DialogResult dr = rf.ShowDialog();

            if (dr == DialogResult.OK)
            {
                new_val = rf.EditValue;
                List <SymbolsViewerSymbol> refers = FindReferences(expr, fileName, line, column, true);
                if (refers == null)
                {
                    return(null);
                }
                return(refers);
            }
            return(null);
        }
        public static void NewForm(ProjectExplorerForm ProjectExplorerWindow, bool prompt)         //roman//
        {
            NewFileForm frm = new NewFileForm();

            frm.SetWinFormsFilter();
            Form1StringResources.SetTextForAllControls(frm);
            frm.FileName = ProjectFactory.Instance.GetUnitFileName();
            if (prompt && frm.ShowDialog() != DialogResult.OK) //roman//
            {
                return;
            }
            PascalABCCompiler.IFileInfo fi = ProjectFactory.Instance.AddSourceFile(frm.FileName);
            string       full_file_name    = Path.Combine(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path), frm.FileName);
            StreamWriter sw = File.CreateText(full_file_name);

            sw.Close();

            WorkbenchServiceFactory.FileService.OpenFile(full_file_name, null);
            VisualPABCSingleton.MainForm.CurrentCodeFileDocument.AddDesigner(null);
            ProjectExplorerWindow.AddSourceFile(fi, true);
            VisualPABCSingleton.MainForm.SaveFileAs(VisualPABCSingleton.MainForm.CurrentCodeFileDocument, full_file_name);
        }
Exemple #3
0
        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)
            {
            }
        }
Exemple #4
0
        public static void NewFile(ProjectExplorerForm ProjectExplorerWindow)
        {
            NewFileForm frm = new NewFileForm();

            Form1StringResources.SetTextForAllControls(frm);
            frm.FileName = ProjectFactory.Instance.GetUnitFileName();
            frm.SetUnitFilter();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                PascalABCCompiler.IFileInfo fi = ProjectFactory.Instance.AddSourceFile(frm.FileName);
                ProjectExplorerWindow.AddSourceFile(fi, false);
                string       full_file_name = Path.Combine(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path), frm.FileName);
                StreamWriter sw             = File.CreateText(full_file_name);
                sw.WriteLine("unit " + Path.GetFileNameWithoutExtension(frm.FileName) + ";");
                sw.WriteLine();
                sw.WriteLine("interface");
                sw.WriteLine();
                sw.WriteLine("implementation");
                sw.WriteLine();
                sw.WriteLine("end.");
                sw.Close();
                WorkbenchServiceFactory.FileService.OpenFile(full_file_name, null);
            }
        }
 private void AddDesignerSidebars()
 {
     if (ToolBoxWindow == null)
     {
         ToolBoxWindow = new ToolBoxForm();
         SharpDevelopSideBar sideBar = FormsDesignerViewContent.FormsDesignerToolBox;
         sideBar.Dock   = DockStyle.Fill;
         sideBar.Parent = ToolBoxWindow;
         AddWindowToDockPanel(ToolBoxWindow, MainDockPanel, OutputWindow.Dock, DockState.DockLeft, OutputWindow.IsFloat, null, -1);
         ToolBoxWindow.Visible = false;
         ToolBoxWindow.Hide();
     }
     if (PropertiesWindow == null)
     {
         PropertiesWindow = new PropertiesForm();
         Form1StringResources.SetTextForAllControls(PropertiesWindow);
         Panel properties = FormsDesignerViewContent.PropertyPad.PropertyPadPanel;
         properties.Dock   = DockStyle.Fill;
         properties.Parent = PropertiesWindow;
         AddWindowToDockPanel(PropertiesWindow, MainDockPanel, DockStyle.Fill, DockState.DockRight, OutputWindow.IsFloat, ProjectPane, int.MaxValue);
         PropertiesWindow.Visible = false;
         PropertiesWindow.Hide();
     }
 }
Exemple #6
0
        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);
            }
        }
Exemple #7
0
 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 OutputWindowForm(Form1 MainForm)
     : base(MainForm)
 {
     InitializeComponent();
     Form1StringResources.SetTextForAllControls(this.contextMenuStrip1);
 }
 public void ChangeContinueDebugNameOnStart()
 {
     this.StartDebugButton.ToolTipText      = Form1StringResources.Get("M_DEBUGSTART");
     this.mDEBUGSTARTToolStripMenuItem.Text = Form1StringResources.Get("M_DEBUGSTART");
 }
Exemple #10
0
        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;
                }
            }
        }
Exemple #11
0
 public override string ToString()
 {
     return(string.Format(Form1StringResources.Get("EXCEPTION_IN_START_EXE{0}"), fileName));
 }
Exemple #12
0
        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);
        }
Exemple #13
0
        public DebugWatchListWindowForm(Form1 MainForm)
            : base(MainForm)
        {
            InitializeComponent();
//            this.WColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
//            this.WColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
//            this.WColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
//            this.WColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
//            this.WColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            watchWindow = this;
            Form1StringResources.SetTextForAllControls(this.cntxtWatch);
            this.WColumn4      = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.WColumn1      = new AdvancedDataGridView.TreeGridColumn();
            this.WColumn2      = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.WColumn3      = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.WColumn5      = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.WColumn6Empty = new System.Windows.Forms.DataGridViewTextBoxColumn();

            this.watchList.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
            this.watchList.AutoSizeRowsMode            = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
            this.watchList.BackgroundColor             = System.Drawing.Color.White;
            this.watchList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
            this.watchList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
                this.WColumn1,
                this.WColumn3,
                this.WColumn2,
                this.WColumn6Empty
            });
            this.watchList.Dock               = System.Windows.Forms.DockStyle.Fill;
            this.watchList.GridColor          = System.Drawing.SystemColors.Control;
            this.watchList.Location           = new System.Drawing.Point(1, 1);
            this.watchList.MultiSelect        = true;
            this.watchList.Font               = new Font("Tahoma", 8);
            this.watchList.BorderStyle        = BorderStyle.None;
            this.watchList.ReadOnly           = false;
            this.watchList.RowHeadersVisible  = false;
            this.watchList.RowTemplate.Height = 24;
            this.watchList.SelectionMode      = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            this.watchList.Size               = new System.Drawing.Size(782, 121);
            this.watchList.TabIndex           = 0;
            //this.watchList.CellValueChanged += RefreshWatchDel;//delegate(object sender, DataGridViewCellEventArgs e) { RefreshWatch(); };
            this.watchList.CellEndEdit     += delegate(object sender, DataGridViewCellEventArgs e) { RefreshRow(e.RowIndex); };
            this.watchList.CellClick       += CellClickDel;
            this.watchList.CellDoubleClick += CellDblClickDel;
            this.watchList.KeyDown         += KeyDownDel;
            this.watchList.UserDeletingRow += new System.Windows.Forms.DataGridViewRowCancelEventHandler(this.watchList_UserDeletingRow);
            this.watchList._imageList       = CodeCompletionProvider.ImagesProvider.ImageList;
            this.watchList.EditMode         = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
            this.watchList.ShowLines        = true;
            this.watchList.Nodes.Add(new AdvancedDataGridView.TreeGridNode());
            //this.dataGridView1.ClientSizeChanged += new System.EventHandler(this.dataGridView1_ClientSizeChanged);
            //this.dataGridView1.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellDoubleClick);
            //this.dataGridView1.SizeChanged += new System.EventHandler(this.dataGridView1_SizeChanged);
            //this.dataGridView1.Paint += new System.Windows.Forms.PaintEventHandler(this.dataGridView1_Paint);
            //this.dataGridView1.Resize += new System.EventHandler(this.dataGridView1_Resize);


            this.WColumn4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
            this.WColumn4.FillWeight   = 20F;
            this.WColumn4.Frozen       = true;
            this.WColumn4.HeaderText   = "ER_NUM";
            this.WColumn4.Name         = "WColumn4";
            this.WColumn4.ReadOnly     = true;
            this.WColumn4.Resizable    = System.Windows.Forms.DataGridViewTriState.False;
            this.WColumn4.Width        = 25;
            //
            // Column1
            //
            this.WColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
            this.WColumn1.FillWeight   = 20F;
            this.WColumn1.Frozen       = false;
            this.WColumn1.HeaderText   = "WT_EXPR";
            this.WColumn1.Name         = "WColumn1";
            this.WColumn1.ReadOnly     = false;
            this.WColumn1.Width        = 250;
            //
            // Column2
            //
            this.WColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
            this.WColumn2.FillWeight   = 221.0297F;
            this.WColumn2.Frozen       = false;
            this.WColumn2.HeaderText   = "WT_TYPE";
            this.WColumn2.Name         = "WColumn2";
            this.WColumn2.ReadOnly     = true;
            this.WColumn2.Width        = 200;
            //
            // Column3
            //
            this.WColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
            this.WColumn3.FillWeight   = 101.5228F;
            this.WColumn3.Frozen       = false;
            this.WColumn3.HeaderText   = "WT_VALUE";
            this.WColumn3.Name         = "WColumn3";
            this.WColumn3.ReadOnly     = true;

            //
            // Column6Empty
            //
            this.WColumn6Empty.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
            this.WColumn6Empty.FillWeight   = 101.5228F;
            this.WColumn6Empty.Frozen       = false;
            this.WColumn6Empty.HeaderText   = "";
            this.WColumn6Empty.Name         = "Empty";
            this.WColumn6Empty.Resizable    = System.Windows.Forms.DataGridViewTriState.False;
            this.WColumn6Empty.ReadOnly     = true;

            //
            // Column5
            //
            this.WColumn5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
            this.WColumn5.HeaderText   = "ER_PATH";
            this.WColumn5.Name         = "WColumn5";
            this.WColumn5.ReadOnly     = true;
            this.WColumn5.Width        = 200;

            this.watchList.AllowUserToAddRows       = true;
            this.watchList.AllowUserToDeleteRows    = true;
            this.watchList.AllowUserToResizeColumns = true;
            this.watchList.AllowUserToResizeRows    = false;
        }
        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();
                }
            }
        }