Example #1
0
 public static void SaveOptions(string ProjectPath)
 {
     try
     {
         UserProjectSettings setts = MakeOptions();
         string file_name          = Path.ChangeExtension(ProjectPath, opt_ext);
         System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
         bf.Serialize(new FileStream(file_name, FileMode.Create), setts);
     }
     catch (Exception e)
     {
     }
 }
Example #2
0
        public static UserProjectSettings LoadOptions(string ProjectPath)
        {
            UserProjectSettings setts = null;

            try
            {
                string file_name = Path.ChangeExtension(ProjectPath, opt_ext);
                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                return(bf.Deserialize(new FileStream(file_name, FileMode.Open)) as UserProjectSettings);
            }
            catch (Exception e)
            {
            }
            return(setts);
        }
Example #3
0
        public static UserProjectSettings MakeOptions()
        {
            UserProjectSettings   options                = new UserProjectSettings();
            List <OpenedFileInfo> openedDocuments        = new List <OpenedFileInfo>();
            List <OpenedFileInfo> openedProjectDocuments = new List <OpenedFileInfo>();

            foreach (CodeFileDocumentControl cfdc in VisualPABCSingleton.MainForm.OpenDocuments.Values)
            {
                OpenedFileInfo fi = new OpenedFileInfo();
                if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(cfdc.FileName))
                {
                    fi.FileName  = PascalABCCompiler.Tools.RelativePathTo(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path), cfdc.FileName);
                    fi.InProject = true;
                }
                else
                {
                    fi.FileName = cfdc.FileName;
                }
                openedDocuments.Add(fi);
                fi.CaretLine   = cfdc.TextEditor.CaretLine;
                fi.CaretColumn = cfdc.TextEditor.CaretColumn;
            }
            if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName))
            {
                options.CurrentDocument            = PascalABCCompiler.Tools.RelativePathTo(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path), VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName);
                options.CurrentDocumentIsInProject = true;
            }
            else
            {
                options.CurrentDocument = WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.FileName;
            }
            options.OpenDocuments = openedDocuments.ToArray();
            string[]             exprs   = VisualPABCSingleton.MainForm.DebugWatchListWindow.GetExpressions();
            List <WatchExprInfo> watches = new List <WatchExprInfo>();

            foreach (string s in exprs)
            {
                watches.Add(new WatchExprInfo(s));
            }
            options.WatchExprs = watches.ToArray();
            return(options);
        }
		public static UserProjectSettings MakeOptions()
		{
			UserProjectSettings options = new UserProjectSettings();
			List<OpenedFileInfo> openedDocuments = new List<OpenedFileInfo>();
            List<OpenedFileInfo> openedProjectDocuments = new List<OpenedFileInfo>();
            foreach (CodeFileDocumentControl cfdc in VisualPABCSingleton.MainForm.OpenDocuments.Values)
			{
				OpenedFileInfo fi = new OpenedFileInfo();
                if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(cfdc.FileName))
                {
                    fi.FileName = PascalABCCompiler.Tools.RelativePathTo(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path),cfdc.FileName);
                    fi.InProject = true;
                }
                else
                {
                    fi.FileName = cfdc.FileName;
                }
                openedDocuments.Add(fi);
                fi.CaretLine = cfdc.TextEditor.CaretLine;
                fi.CaretColumn = cfdc.TextEditor.CaretColumn;
			}
            if (ProjectFactory.Instance.CurrentProject.ContainsSourceFile(VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName))
            {
                options.CurrentDocument = PascalABCCompiler.Tools.RelativePathTo(Path.GetDirectoryName(ProjectFactory.Instance.CurrentProject.Path), VisualPABCSingleton.MainForm.CurrentCodeFileDocument.FileName);
                options.CurrentDocumentIsInProject = true;
            }
            else
                options.CurrentDocument = WorkbenchServiceFactory.DocumentService.CurrentCodeFileDocument.FileName;
			options.OpenDocuments = openedDocuments.ToArray();
			string[] exprs = VisualPABCSingleton.MainForm.DebugWatchListWindow.GetExpressions();
			List<WatchExprInfo> watches = new List<WatchExprInfo>();
			foreach (string s in exprs)
			{
				watches.Add(new WatchExprInfo(s));
			}
			options.WatchExprs = watches.ToArray();
			return options;
		}
Example #5
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);
     }
 }