Пример #1
0
        void INavigationBarPresenter.PresentItems(
            IList <NavigationBarProjectItem> projects,
            NavigationBarProjectItem selectedProject,
            IList <NavigationBarItem> types,
            NavigationBarItem selectedType,
            NavigationBarItem selectedMember)
        {
            _projectItems     = projects;
            _currentTypeItems = types;

            // It's possible we're presenting items before the dropdown bar has been initialized.
            if (_dropdownBar == null)
            {
                return;
            }

            var projectIndex = selectedProject != null?_projectItems.IndexOf(selectedProject) : -1;

            var typeIndex = selectedType != null?_currentTypeItems.IndexOf(selectedType) : -1;

            var memberIndex = selectedType != null && selectedMember != null?selectedType.ChildItems.IndexOf(selectedMember) : -1;

            _dropdownBar.RefreshCombo((int)NavigationBarDropdownKind.Project, projectIndex);
            _dropdownBar.RefreshCombo((int)NavigationBarDropdownKind.Type, typeIndex);
            _dropdownBar.RefreshCombo((int)NavigationBarDropdownKind.Member, memberIndex);
        }
        private void GetProjectItems(out IList <NavigationBarProjectItem> projectItems, out NavigationBarProjectItem selectedProjectItem)
        {
            var documents = _subjectBuffer.CurrentSnapshot.GetRelatedDocumentsWithChanges();

            if (!documents.Any())
            {
                projectItems        = SpecializedCollections.EmptyList <NavigationBarProjectItem>();
                selectedProjectItem = null;
                return;
            }

            projectItems = documents.Select(d =>
                                            new NavigationBarProjectItem(
                                                d.Project.Name,
                                                d.Project.GetGlyph(),
                                                workspace: d.Project.Solution.Workspace,
                                                documentId: d.Id,
                                                language: d.Project.Language)).OrderBy(projectItem => projectItem.Text).ToList();

            projectItems.Do(i => i.InitializeTrackingSpans(_subjectBuffer.CurrentSnapshot));

            var document = _subjectBuffer.AsTextContainer().GetOpenDocumentInCurrentContext();

            selectedProjectItem = document != null
                ? projectItems.FirstOrDefault(p => p.Text == document.Project.Name) ?? projectItems.First()
                : projectItems.First();
        }
Пример #3
0
        private void GetProjectItems(out IList<NavigationBarProjectItem> projectItems, out NavigationBarProjectItem selectedProjectItem)
        {
            var documents = _subjectBuffer.CurrentSnapshot.GetRelatedDocumentsWithChanges();
            if (!documents.Any())
            {
                projectItems = SpecializedCollections.EmptyList<NavigationBarProjectItem>();
                selectedProjectItem = null;
                return;
            }

            projectItems = documents.Select(d =>
                new NavigationBarProjectItem(
                    d.Project.Name,
                    d.Project.GetGlyph(),
                    workspace: d.Project.Solution.Workspace,
                    documentId: d.Id,
                    language: d.Project.Language)).OrderBy(projectItem => projectItem.Text).ToList();

            projectItems.Do(i => i.InitializeTrackingSpans(_subjectBuffer.CurrentSnapshot));

            var document = _subjectBuffer.AsTextContainer().GetOpenDocumentInCurrentContext();
            selectedProjectItem = document != null
                ? projectItems.FirstOrDefault(p => p.Text == document.Project.Name) ?? projectItems.First()
                : projectItems.First();
        }