Esempio n. 1
0
        public void ReopenItemsSavedInUserConfig()
        {
            string tmp = UserConfig.Get <string> ("OpenedItems");

            if (string.IsNullOrEmpty(tmp))
            {
                return;
            }
            string          sel     = UserConfig.Get <string> ("SelectedProjItems");
            ProjectFileNode selItem = null;

            foreach (string f in tmp.Split(';'))
            {
                string []       s  = f.Split('|');
                ProjectFileNode pi = Projects.FirstOrDefault(p => p.DisplayName == s [0])?.Flatten.OfType <ProjectFileNode>().FirstOrDefault(pfn => pfn.RelativePath == s[1]);
                if (pi == null)
                {
                    continue;
                }
                pi.Open();
                if (pi.SaveID == sel)
                {
                    selItem = pi;
                }
            }
            if (selItem == null)
            {
                return;
            }
            selItem.IsSelected = true;
        }
Esempio n. 2
0
        //    if (ParentProject != null)
        //        ParentProject.Compile ();

        //    CSharpCodeProvider cp = new CSharpCodeProvider ();
        //    CompilerParameters parameters = new CompilerParameters ();

        //    foreach (ProjectReference pr in flattenNodes.OfType<ProjectReference> ()) {
        //        Project p = solution.Projects.FirstOrDefault (pp => pp.ProjectGuid == pr.ProjectGUID);
        //        if (p == null)
        //            throw new Exception ("referenced project not found");
        //        parameters.ReferencedAssemblies.Add (p.Compile ());
        //    }

        //    string outputDir = getDirectoryWithTokens (this.OutputPath);
        //    string objDir = getDirectoryWithTokens (this.IntermediateOutputPath);

        //    Directory.CreateDirectory (outputDir);
        //    Directory.CreateDirectory (objDir);

        //    parameters.OutputAssembly = System.IO.Path.Combine (outputDir, this.AssemblyName);

        //    // True - exe file generation, false - dll file generation
        //    if (this.OutputType == "Library") {
        //        parameters.GenerateExecutable = false;
        //        parameters.CompilerOptions += " /target:library";
        //        parameters.OutputAssembly += ".dll";
        //    } else {
        //        parameters.GenerateExecutable = true;
        //        parameters.CompilerOptions += " /target:exe";
        //        parameters.OutputAssembly += ".exe";
        //        parameters.MainClass = this.StartupObject;
        //    }

        //    parameters.GenerateInMemory = false;
        //    parameters.IncludeDebugInformation = this.DebugSymbols;
        //    parameters.TreatWarningsAsErrors = this.TreatWarningsAsErrors;
        //    parameters.WarningLevel = this.WarningLevel;
        //    parameters.CompilerOptions += " /noconfig";
        //    if (this.AllowUnsafeBlocks)
        //        parameters.CompilerOptions += " /unsafe";
        //    parameters.CompilerOptions += " /delaysign+";
        //    parameters.CompilerOptions += " /debug:full /debug+";
        //    parameters.CompilerOptions += " /optimize-";
        //    parameters.CompilerOptions += " /define:\"DEBUG;TRACE\"";
        //    parameters.CompilerOptions += " /nostdlib";



        //    foreach (ProjectItem pi in flattenNodes.Where (p => p.Type == ItemType.Reference)) {

        //        if (string.IsNullOrEmpty (pi.HintPath)) {
        //            parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/" + pi.Path + ".dll";
        //            continue;
        //        }
        //        parameters.ReferencedAssemblies.Add (pi.Path);
        //        string fullHintPath = System.IO.Path.GetFullPath (System.IO.Path.Combine (RootDir, pi.HintPath.Replace ('\\', '/')));
        //        if (File.Exists (fullHintPath)) {
        //            string outPath = System.IO.Path.Combine (outputDir, System.IO.Path.GetFileName (fullHintPath));
        //            if (!File.Exists (outPath))
        //                File.Copy (fullHintPath, outPath);
        //        }
        //    }
        //    parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/System.Core.dll";
        //    parameters.CompilerOptions += " /reference:/usr/lib/mono/4.5/mscorlib.dll";
        //    //parameters.ReferencedAssemblies.Add ("System.Core");
        //    //parameters.ReferencedAssemblies.Add ("mscorlib.dll");


        //    IEnumerable<ProjectFile> pfs = flattenNodes.OfType<ProjectFile> ();

        //    foreach (ProjectFile pi in pfs.Where (p => p.Type == ItemType.EmbeddedResource)) {

        //        string absPath = pi.AbsolutePath;
        //        string logicName = pi.LogicalName;
        //        if (string.IsNullOrEmpty (logicName))
        //            parameters.CompilerOptions += string.Format (" /resource:{0},{1}", absPath, this.Name + "." + pi.Path.Replace ('/', '.'));
        //        else
        //            parameters.CompilerOptions += string.Format (" /resource:{0},{1}", absPath, logicName);
        //    }
        //    foreach (ProjectFile pi in pfs.Where (p => p.Type == ItemType.None)) {
        //        if (pi.CopyToOutputDirectory == CopyToOutputState.Never)
        //            continue;
        //        string source = pi.AbsolutePath;
        //        string target = System.IO.Path.Combine (outputDir, pi.Path);
        //        Directory.CreateDirectory (System.IO.Path.GetDirectoryName (target));

        //        if (File.Exists (target)) {
        //            if (pi.CopyToOutputDirectory == CopyToOutputState.PreserveNewest) {
        //                if (DateTime.Compare (
        //                        System.IO.File.GetLastWriteTime (source),
        //                        System.IO.File.GetLastWriteTime (target)) < 0)
        //                    continue;
        //            }
        //            File.Delete (target);
        //        }
        //        System.Diagnostics.Debug.WriteLine ("copy " + source + " to " + target);
        //        File.Copy (source, target);
        //    }
        //    string[] files = pfs.Where (p => p.Type == ItemType.Compile).Select (p => p.AbsolutePath).ToArray ();

        //    System.Diagnostics.Debug.WriteLine ("---- start compilation of :" + parameters.OutputAssembly);
        //    System.Diagnostics.Debug.WriteLine (parameters.CompilerOptions);

        //    CompilationResults = cp.CompileAssemblyFromFile (parameters, files);

        //    solution.UpdateErrorList ();

        //    return parameters.OutputAssembly;
        //}

        public bool TryGetProjectFileFromPath(string path, out ProjectFileNode pi)
        {
            if (path.StartsWith("#", StringComparison.Ordinal))
            {
                pi = Flatten.OfType <ProjectFileNode> ().FirstOrDefault
                         (f => f.Type == ItemType.EmbeddedResource && f.LogicalName == path.Substring(1));
            }
            else
            {
                pi = Flatten.OfType <ProjectFileNode> ().FirstOrDefault(pp => pp.FullPath == path);
            }

            if (pi != null)
            {
                return(true);
            }

            foreach (ProjectItemNode pr in Flatten.OfType <ProjectItemNode> ().Where(pn => pn.Type == ItemType.ProjectReference))
            {
                ProjectView p = solution.Projects.FirstOrDefault(pp => pp.FullPath == pr.FullPath);
                if (p == null)
                {
                    continue;
                }
                if (p.TryGetProjectFileFromPath(path, out pi))
                {
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 3
0
 public bool GetProjectFileFromPath(string path, out ProjectFileNode pi)
 {
     pi = null;
     return(false);           /* StartupProject == null ? false :
                               * StartupProject.TryGetProjectFileFromPath (path, out pi);*/
 }
Esempio n. 4
0
        void populateTreeNodes()
        {
            ProjectNode root = new ProjectNode(this, ItemType.VirtualGroup, RootNamespace);
            ProjectNode refs = new ProjectNode(this, ItemType.ReferenceGroup, "References");

            root.AddChild(refs);

            /*Console.ForegroundColor = ConsoleColor.Green;
             * Console.WriteLine ($"Evaluated Globals properties for {DisplayName}");
             * foreach (ProjectProperty item in project.AllEvaluatedProperties.OrderBy(p=>p.Name)) {
             *      Console.ForegroundColor = ConsoleColor.White;
             *      Console.Write ($"\t{item.Name,-40} = ");
             *      Console.ForegroundColor = ConsoleColor.Gray;
             *      Console.WriteLine ($"{item.EvaluatedValue}");
             * }*/


            foreach (ProjectItem pn in project.AllEvaluatedItems)
            {
                switch (pn.ItemType)
                {
                case "ProjectReferenceTargets":
                    Commands.Add(new Crow.Command(new Action(() => Compile(pn.EvaluatedInclude)))
                    {
                        Caption = pn.EvaluatedInclude,
                    });
                    break;

                case "Reference":
                case "PackageReference":
                case "ProjectReference":
                    refs.AddChild(new ProjectItemNode(this, pn));
                    break;

                case "Compile":
                case "None":
                case "EmbeddedResource":
                    ProjectNode curNode = root;
                    try {
                        string file     = pn.EvaluatedInclude.Replace('\\', '/');
                        string treePath = file;
                        if (pn.HasMetadata("Link"))
                        {
                            treePath = project.ExpandString(pn.GetMetadataValue("Link"));
                        }
                        string [] folds = treePath.Split('/');
                        for (int i = 0; i < folds.Length - 1; i++)
                        {
                            ProjectNode nextNode = curNode.Childs.OfType <ProjectNode>().FirstOrDefault(n => n.DisplayName == folds [i] && n.Type == ItemType.VirtualGroup);
                            if (nextNode == null)
                            {
                                nextNode = new ProjectNode(this, ItemType.VirtualGroup, folds [i]);
                                curNode.AddChild(nextNode);
                            }
                            curNode = nextNode;
                        }
                        ProjectItemNode pi = new ProjectItemNode(this, pn);

                        switch (Path.GetExtension(file))
                        {
                        case ".cs":
                            pi = new CSProjectItem(pi);
                            break;

                        case ".crow":
                        case ".template":
                        case ".goml":
                        case ".itemp":
                        case ".imtl":
                            pi = new ImlProjectItem(pi);
                            break;

                        case ".style":
                            pi = new StyleProjectItem(pi);
                            break;

                        default:
                            pi = new ProjectFileNode(pi);
                            break;
                        }
                        curNode.AddChild(pi);
                    } catch (Exception ex) {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(ex);
                        Console.ResetColor();
                    }

                    break;
                }
            }
            root.SortChilds();
            foreach (var item in root.Childs)
            {
                Childs.Add(item);
                item.Parent = this;
            }


            IsLoaded = true;
        }