예제 #1
0
        public void Reset()
        {
            store.Clear();

            bool isPcl = configureProject.IsPortableLibrary;

            foreach (SystemAssembly systemAssembly in targetContext.GetAssemblies(targetVersion))
            {
                if (systemAssembly.Package.IsFrameworkPackage && (isPcl || systemAssembly.Name == "mscorlib"))
                {
                    continue;
                }

                bool   selected = IsSelected(ReferenceType.Package, systemAssembly.FullName, systemAssembly.Package.Name);
                int    matchRank = 0;
                string name, version;

                if (stringMatcher != null)
                {
                    string txt = systemAssembly.Name + " " + systemAssembly.Version;
                    if (!stringMatcher.CalcMatchRank(txt, out matchRank))
                    {
                        continue;
                    }
                    int[] match = stringMatcher.GetMatch(txt);
                    name    = GetMatchMarkup(treeView, systemAssembly.Name, match, 0);
                    version = GetMatchMarkup(treeView, systemAssembly.Version, match, systemAssembly.Name.Length + 1);
                }
                else
                {
                    name    = GLib.Markup.EscapeText(systemAssembly.Name);
                    version = GLib.Markup.EscapeText(systemAssembly.Version);
                }
                string pkg = systemAssembly.Package.GetDisplayName();
                if (systemAssembly.Package.IsInternalPackage)
                {
                    pkg += " " + GettextCatalog.GetString("(Provided by {0})", BrandingService.ApplicationName);
                }

                store.AppendValues(name,
                                   version,
                                   systemAssembly,
                                   selected,
                                   systemAssembly.FullName,
                                   pkg,
                                   MonoDevelop.Ide.Gui.Stock.Package,
                                   matchRank,
                                   ReferenceType.Package);
            }

            if (showAll)
            {
                Solution openSolution = configureProject.ParentSolution;
                if (openSolution == null)
                {
                    return;
                }

                Dictionary <DotNetProject, bool> references = new Dictionary <DotNetProject, bool> ();

                foreach (Project projectEntry in openSolution.GetAllItems <Project>())
                {
                    if (projectEntry == configureProject)
                    {
                        continue;
                    }

                    bool   selected  = IsSelected(ReferenceType.Project, projectEntry.Name, "");
                    int    matchRank = 0;
                    string name;

                    if (stringMatcher != null)
                    {
                        if (!stringMatcher.CalcMatchRank(projectEntry.Name, out matchRank))
                        {
                            continue;
                        }
                        int[] match = stringMatcher.GetMatch(projectEntry.Name);
                        name = GetMatchMarkup(treeView, projectEntry.Name, match, 0);
                    }
                    else
                    {
                        name = GLib.Markup.EscapeText(projectEntry.Name);
                    }

                    DotNetProject netProject = projectEntry as DotNetProject;
                    if (netProject != null)
                    {
                        if (ProjectReferencePanel.ProjectReferencesProject(references, null, netProject, configureProject.Name))
                        {
                            continue;
                        }

                        string reason;
                        if (!configureProject.CanReferenceProject(netProject, out reason))
                        {
                            continue;
                        }
                    }
                    store.AppendValues(name, "", null, selected, projectEntry.FileName.ToString(), "", projectEntry.StockIcon, matchRank, ReferenceType.Project);
                }

                foreach (FilePath file in selectDialog.GetRecentFileReferences())
                {
                    bool   selected  = IsSelected(ReferenceType.Assembly, file, "");
                    int    matchRank = 0;
                    string fname     = file.FileName;
                    string name;

                    string version = string.Empty;
                    try {
                        string sname = SystemAssemblyService.GetAssemblyName(file);
                        var    aname = SystemAssemblyService.ParseAssemblyName(sname);
                        version = aname.Version.ToString();
                    } catch {
                        continue;
                    }

                    if (stringMatcher != null)
                    {
                        if (!stringMatcher.CalcMatchRank(fname, out matchRank))
                        {
                            continue;
                        }
                        int[] match = stringMatcher.GetMatch(fname);
                        name = GetMatchMarkup(treeView, fname, match, 0);
                    }
                    else
                    {
                        name = GLib.Markup.EscapeText(fname);
                    }
                    store.AppendValues(name, version, null, selected, (string)file, GLib.Markup.EscapeText(file), MonoDevelop.Ide.Gui.Stock.OpenFolder, matchRank, ReferenceType.Assembly);
                }
            }
        }
예제 #2
0
        void PopulateListView()
        {
            store.Clear();

            Solution openSolution = configureProject.ParentSolution;

            if (openSolution == null)
            {
                return;
            }

            Dictionary <DotNetProject, bool> references = new Dictionary <DotNetProject, bool> ();

            foreach (Project projectEntry in openSolution.GetAllItems <Project>())
            {
                if (projectEntry == configureProject)
                {
                    continue;
                }

                if (projectEntry is UnknownProject)
                {
                    continue;
                }

                string txt;
                int    matchRank = 0;

                if (stringMatcher != null)
                {
                    if (!stringMatcher.CalcMatchRank(projectEntry.Name, out matchRank))
                    {
                        continue;
                    }
                    int[] match = stringMatcher.GetMatch(projectEntry.Name);
                    txt = PackageReferencePanel.GetMatchMarkup(treeView, projectEntry.Name, match, 0);
                }
                else
                {
                    txt = GLib.Markup.EscapeText(projectEntry.Name);
                }

                bool          selected       = selection.Contains(projectEntry.Name);
                bool          allowSelecting = true;
                DotNetProject netProject     = projectEntry as DotNetProject;
                if (netProject != null)
                {
                    string reason;

                    if (ProjectReferencesProject(references, null, netProject, configureProject.Name))
                    {
                        txt           += " " + GLib.Markup.EscapeText(GettextCatalog.GetString("(Cyclic dependencies not allowed)"));
                        allowSelecting = false;
                    }
                    else if (!configureProject.CanReferenceProject(netProject, out reason))
                    {
                        txt           += " " + GLib.Markup.EscapeText("(" + reason + ")");
                        allowSelecting = false;
                    }
                }

                var icon = ImageService.GetIcon(projectEntry.StockIcon, IconSize.Menu);
                if (!allowSelecting)
                {
                    // Don't show unselectable projects if there is a filter
                    if (stringMatcher != null)
                    {
                        continue;
                    }
                    icon = icon.WithAlpha(0.5);
                }
                Gtk.TreeIter it = store.AppendValues(txt, projectEntry.BaseDirectory.ToString(), projectEntry, selected, icon, allowSelecting);
                if (!allowSelecting)
                {
                    store.SetValue(it, ColColor, "dimgrey");
                }
            }
        }