public bool CloseProject() { if (SaveAllInProject() == 2) { return(false); } BottomTabsVisible = true; ProjectUserOptionsManager.SaveOptions(ProjectFactory.Instance.CurrentProject.Path); CloseProjectFiles(); ProjectFactory.Instance.CloseProject(); ProjectExplorerWindow.Clear(); HideContent(ProjectExplorerWindow); HideContent(PropertiesWindow); if (ToolBoxWindow != null) { HideContent(ToolBoxWindow); } this.miProjectExplorer.Visible = false; CodeFileDocumentControl tmp = CurrentCodeFileDocument; //CloseAllButThis(CurrentCodeFileDocument); RestoreFiles(); RestoreWatch(); //CloseFile(tmp, false); WorkbenchServiceFactory.BuildService.CompilerOptions.ProjectCompiled = false; mrDesigner.Visible = false; miCloseProject.Visible = false; this.mRPROJECTToolStripMenuItem.Visible = false; CodeCompletion.CodeCompletionController.comp.CompilerOptions.CurrentProject = null; return(true); }
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); } }