コード例 #1
0
        public void NewProject()
        {
            NewProjectForm npf = new NewProjectForm();

            Form1StringResources.SetTextForAllControls(npf);

            if (npf.ShowDialog() == DialogResult.OK)
            {
                if (ProjectFactory.Instance.ProjectLoaded)
                {
                    if (!CloseProject())
                    {
                        return;
                    }
                }
                PascalABCCompiler.IProjectInfo proj = ProjectFactory.Instance.CreateProject(npf.ProjectName, npf.ProjectFileName, npf.ProjectType);
                ProjectExplorerWindow.LoadProject(npf.ProjectName, ProjectFactory.Instance.CurrentProject);
                ProjectExplorerWindow.Show();
                //ShowContent(ProjectExplorerWindow,true);
                CloseFilesAndSaveState();
                ClearAndSaveWatch();
                SelectContent(ProjectExplorerWindow, false);
                WorkbenchServiceFactory.FileService.OpenFile(proj.MainFile, null);
                ActiveCodeFileDocument = CurrentCodeFileDocument;
                AddLastProject(npf.ProjectFileName);
                if (CodeCompletion.CodeCompletionController.comp != null)
                {
                    CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = proj;
                }
                this.mRPROJECTToolStripMenuItem.Visible = true;
                this.miCloseProject.Visible             = true;
                if (proj.ProjectType == PascalABCCompiler.ProjectType.WindowsApp)
                {
                    //string s = ProjectFactory.Instance.GetFullUnitFileName();
                    //OpenFile(null,s);
                    //CurrentCodeFileDocument.AddDesigner(null);
                    ProjectTask.NewForm(ProjectExplorerWindow, false);//roman//
                    GenerateMainProgramForDesigner(proj.MainFile);
                    //OpenFile(s,null);
                    //SaveFileAs(CurrentCodeFileDocument,s);
                    //CurrentCodeFileDocument.DesignerAndCodeTabs.SelectedTab = CurrentCodeFileDocument.DesignerPage;
                    //ProjectTask.AddFile(ProjectExplorerWindow,Path.GetFileName(s));
                    SaveAll(false);
                }
            }
        }
コード例 #2
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);
     }
 }