public NavigationBarSelectedTypeAndMember(
     NavigationBarItem typeItem,
     bool showTypeItemGrayed,
     NavigationBarItem memberItem,
     bool showMemberItemGrayed)
     : this(typeItem, memberItem)
 {
     ShowTypeItemGrayed = showTypeItemGrayed;
     ShowMemberItemGrayed = showMemberItemGrayed;
 }
Exemplo n.º 2
0
 public void PushItem(IContentContainer container)
 {
     var item = new NavigationBarItem();
     var view = container.Manager.View as WindowsUIView;
     if (view == null)
     {
         return;
     }
     item.Text = String.IsNullOrEmpty(container.Subtitle) ? container.Caption + " >" : container.Subtitle + " >";
     item.Tag = container;
     officeNavigationBar1.Items.Insert(0,item);
 }
        public async Task <bool> TryNavigateToItemAsync(
            Document document, NavigationBarItem item, ITextView view, ITextSnapshot textSnapshot, CancellationToken cancellationToken)
        {
            if (item.NavigationTrackingSpan != null)
            {
                var span = item.NavigationTrackingSpan.GetSpan(textSnapshot);
                await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

                var workspace         = document.Project.Solution.Workspace;
                var navigationService = VSTypeScriptDocumentNavigationServiceWrapper.Create(workspace);
                navigationService.TryNavigateToPosition(workspace, document.Id, span.Start, virtualSpace: 0, options: null, cancellationToken: cancellationToken);
            }

            return(true);
        }
Exemplo n.º 4
0
 static VSSymbolInformation Create(NavigationBarItem item, TextSpan span, string containerName, Document document, SourceText text)
 {
     return(new VSSymbolInformation
     {
         Name = item.Text,
         Location = new LSP.Location
         {
             Uri = document.GetURI(),
             Range = ProtocolConversions.TextSpanToRange(span, text),
         },
         Kind = ProtocolConversions.GlyphToSymbolKind(item.Glyph),
         ContainerName = containerName,
         Icon = new ImageElement(item.Glyph.GetImageId()),
     });
 }
        public async Task <bool> TryNavigateToItemAsync(
            Document document, NavigationBarItem item, ITextView view, ITextVersion textVersion, CancellationToken cancellationToken)
        {
            // Spans.First() is safe here as we filtered out any items with no spans above in ConvertItems.
            var navigationSpan = item.GetCurrentItemSpan(textVersion, item.Spans.First());
            await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            var workspace         = document.Project.Solution.Workspace;
            var navigationService = VSTypeScriptDocumentNavigationServiceWrapper.Create(workspace);

            navigationService.TryNavigateToPosition(
                workspace, document.Id, navigationSpan.Start,
                virtualSpace: 0, options: null, cancellationToken: cancellationToken);

            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get a symbol information from a specified nav bar item.
        /// </summary>
        private static SymbolInformation GetSymbolInformation(NavigationBarItem item, Compilation compilation, SyntaxTree tree, Document document,
                                                              SourceText text, CancellationToken cancellationToken, string containerName = null)
        {
            if (item.Spans.Count == 0)
            {
                return(null);
            }

            var location = GetLocation(item, compilation, tree, cancellationToken);

            if (location == null)
            {
                return(Create(item, item.Spans.First(), containerName, document, text));
            }

            return(Create(item, location.SourceSpan, containerName, document, text));
Exemplo n.º 7
0
        public FrmMain(bool admin, string type)
        {
            InitializeComponent();
            //InitView<Acceuil>();
            _admin = admin;
            _type  = type;
            ribbonControl.Toolbar.ItemLinks.Add(rgbiSkins);
            if (!_admin)
            {
                return;
            }
            var navigationItem = new NavigationBarItem {
                Text = "Gestion d'Utilisateur"
            };

            officeNavigationBar1.Items.Add(navigationItem);
        }
Exemplo n.º 8
0
        private void PushSelectedItemsToPresenter(NavigationBarSelectedTypeAndMember selectedItems)
        {
            AssertIsForeground();

            var oldLeft  = selectedItems.TypeItem;
            var oldRight = selectedItems.MemberItem;

            NavigationBarItem newLeft  = null;
            NavigationBarItem newRight = null;
            var listOfLeft             = new List <NavigationBarItem>();
            var listOfRight            = new List <NavigationBarItem>();

            if (oldRight != null)
            {
                newRight = new NavigationBarPresentedItem(oldRight.Text, oldRight.Glyph, oldRight.Spans, oldRight.ChildItems, oldRight.Bolded, oldRight.Grayed || selectedItems.ShowMemberItemGrayed)
                {
                    TrackingSpans = oldRight.TrackingSpans
                };
                listOfRight.Add(newRight);
            }

            if (oldLeft != null)
            {
                newLeft = new NavigationBarPresentedItem(oldLeft.Text, oldLeft.Glyph, oldLeft.Spans, listOfRight, oldLeft.Bolded, oldLeft.Grayed || selectedItems.ShowTypeItemGrayed)
                {
                    TrackingSpans = oldLeft.TrackingSpans
                };
                listOfLeft.Add(newLeft);
            }

            IList <NavigationBarProjectItem> projectItems;
            NavigationBarProjectItem         selectedProjectItem;

            GetProjectItems(out projectItems, out selectedProjectItem);

            _presenter.PresentItems(
                projectItems,
                selectedProjectItem,
                listOfLeft,
                newLeft,
                newRight);
            _versionStampOfFullListPushedToPresenter = null;
        }
        void INavigationBarPresenter.PresentItems(
            IList <NavigationBarItem> types,
            NavigationBarItem selectedType,
            NavigationBarItem selectedMember)
        {
            _currentTypeItems = types;

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

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

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

            _dropdownBar.RefreshCombo((int)NavigationBarDropdownKind.Type, typeIndex);
            _dropdownBar.RefreshCombo((int)NavigationBarDropdownKind.Member, memberIndex);
        }
Exemplo n.º 10
0
        public void NavigateToItem(Document document, NavigationBarItem item, ITextView view, CancellationToken cancellationToken)
        {
            // The logic here was ported from FSharp's implementation. The main reason was to avoid shimming INotificationService.
            if (item.Spans.Count > 0)
            {
                var span              = item.Spans.First();
                var workspace         = document.Project.Solution.Workspace;
                var navigationService = workspace.Services.GetService <IFSharpDocumentNavigationService>();

                if (navigationService.CanNavigateToPosition(workspace, document.Id, span.Start))
                {
                    navigationService.TryNavigateToPosition(workspace, document.Id, span.Start);
                }
                else
                {
                    var notificationService = workspace.Services.GetService <INotificationService>();
                    notificationService.SendNotification(EditorFeaturesResources.The_definition_of_the_object_is_hidden, severity: NotificationSeverity.Error);
                }
            }
        }
Exemplo n.º 11
0
        DefaultClass AddClass(NavigationBarItem item, IDocument document)
        {
            var defaultClass = new DefaultClass(this, item.text);

            defaultClass.BodyRegion = item.ToRegionStartingFromOpeningCurlyBrace(document);
            defaultClass.Region     = defaultClass.BodyRegion;

            IClass parentClass = FindParentClass(defaultClass);

            if (parentClass != null)
            {
                defaultClass.FullyQualifiedName = parentClass.FullyQualifiedName + "." + defaultClass.FullyQualifiedName;
                parentClass.InnerClasses.Add(defaultClass);
            }
            else
            {
                Classes.Add(defaultClass);
            }
            AddMethods(defaultClass, item.childItems, document);
            return(defaultClass);
        }
Exemplo n.º 12
0
 internal virtual Task <(DocumentId documentId, int position, int virtualSpace)> GetNavigationLocationAsync(
     Document document,
     NavigationBarItem item,
     RoslynNavigationBarItem.SymbolItem symbolItem,
     ITextSnapshot textSnapshot,
     CancellationToken cancellationToken)
 {
     // If the item points to a location in this document, then just determine the current location
     // of that item and go directly to it.
     if (item.NavigationTrackingSpan != null)
     {
         return(Task.FromResult((document.Id, item.NavigationTrackingSpan.GetSpan(textSnapshot).Start.Position, 0)));
     }
     else
     {
         // Otherwise, the item pointed to a location in another document.  Just return the position we
         // computed and stored for it.
         Contract.ThrowIfNull(symbolItem.Location.OtherDocumentInfo);
         var(documentId, navigationSpan) = symbolItem.Location.OtherDocumentInfo.Value;
         return(Task.FromResult((documentId, navigationSpan.Start, 0)));
     }
 }
Exemplo n.º 13
0
        private void ActionNavItem(object sender, DevExpress.XtraBars.Navigation.NavigationBarItemEventArgs e)
        {
            NavigationBarItem input = e.Item;

            if (transitionManager1.IsTransition && transitionManager2.IsTransition && transitionManager3.IsTransition)
            {
                transitionManager1.EndTransition();
                transitionManager2.EndTransition();
                transitionManager3.EndTransition();
            }

            transitionManager1.StartTransition(lb_permission);
            transitionManager2.StartTransition(lb_join);
            transitionManager3.StartTransition(tb_email);
            try
            {
                switch (input.Text)
                {
                case "Employee":
                    lb_permission.Text = "Manager";
                    lb_join.Text       = "";
                    lb_join.Enabled    = false; tb_email.Text = "ID";
                    break;

                case "Customer":
                    lb_permission.Text = "Customer";
                    lb_join.Text       = "Join us >";
                    lb_join.Enabled    = true;
                    tb_email.Text      = "email";
                    break;
                }
            }
            finally
            {
                transitionManager1.EndTransition();
                transitionManager2.EndTransition();
                transitionManager3.EndTransition();
            }
        }
Exemplo n.º 14
0
        public async Task NavigateToItemAsync(Document document, NavigationBarItem item, ITextView view, CancellationToken cancellationToken)
        {
            // The logic here was ported from FSharp's implementation. The main reason was to avoid shimming INotificationService.
            if (!item.Spans.IsEmpty)
            {
                var span              = item.Spans.First();
                var workspace         = document.Project.Solution.Workspace;
                var navigationService = workspace.Services.GetRequiredService <IFSharpDocumentNavigationService>();

                await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

                if (navigationService.CanNavigateToPosition(workspace, document.Id, span.Start, virtualSpace: 0, cancellationToken))
                {
                    navigationService.TryNavigateToPosition(workspace, document.Id, span.Start, virtualSpace: 0, options: null, cancellationToken);
                }
                else
                {
                    var notificationService = workspace.Services.GetRequiredService <INotificationService>();
                    notificationService.SendNotification(EditorFeaturesResources.The_definition_of_the_object_is_hidden, severity: NotificationSeverity.Error);
                }
            }
        }
        public async Task <bool> TryNavigateToItemAsync(
            Document document, NavigationBarItem item, ITextView view, ITextVersion textVersion, CancellationToken cancellationToken)
        {
            // The logic here was ported from FSharp's implementation. The main reason was to avoid shimming INotificationService.
            // Spans.First() is safe here as we filtered down to only items that have spans in ConvertItems.
            var span              = item.GetCurrentItemSpan(textVersion, item.Spans.First());
            var workspace         = document.Project.Solution.Workspace;
            var navigationService = workspace.Services.GetRequiredService <IFSharpDocumentNavigationService>();

            await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            if (navigationService.CanNavigateToPosition(workspace, document.Id, span.Start, virtualSpace: 0, cancellationToken))
            {
                navigationService.TryNavigateToPosition(workspace, document.Id, span.Start, virtualSpace: 0, cancellationToken);
            }
            else
            {
                var notificationService = workspace.Services.GetRequiredService <INotificationService>();
                notificationService.SendNotification(EditorFeaturesResources.The_definition_of_the_object_is_hidden, severity: NotificationSeverity.Error);
            }

            return(true);
        }
 internal virtual Task <(DocumentId documentId, int position, int virtualSpace)> GetNavigationLocationAsync(
     Document document,
     NavigationBarItem item,
     SymbolItem symbolItem,
     ITextVersion textVersion,
     CancellationToken cancellationToken)
 {
     if (symbolItem.Location.InDocumentInfo != null)
     {
         // If the item points to a location in this document, then just determine the where that span currently
         // is (in case recent edits have moved it) and navigate there.
         var navigationSpan = item.GetCurrentItemSpan(textVersion, symbolItem.Location.InDocumentInfo.Value.navigationSpan);
         return(Task.FromResult((document.Id, navigationSpan.Start, 0)));
     }
     else
     {
         // Otherwise, the item pointed to a location in another document.  Just return the position we
         // computed and stored for it.
         Contract.ThrowIfNull(symbolItem.Location.OtherDocumentInfo);
         var(documentId, span) = symbolItem.Location.OtherDocumentInfo.Value;
         return(Task.FromResult((documentId, span.Start, 0)));
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Process the selection of an item synchronously inside a wait context.
        /// </summary>
        /// <param name="item">The selected item.</param>
        /// <param name="cancellationToken">A cancellation token from the wait context.</param>
        private void ProcessItemSelectionSynchronously(NavigationBarItem item, CancellationToken cancellationToken)
        {
            AssertIsForeground();

            var presentedItem = item as NavigationBarPresentedItem;

            if (presentedItem != null)
            {
                // Presented items are not navigable, but they may be selected due to a race
                // documented in Bug #1174848. Protect all INavigationBarItemService implementers
                // from this by ignoring these selections here.
                return;
            }

            var projectItem = item as NavigationBarProjectItem;

            if (projectItem != null)
            {
                projectItem.SwitchToContext();

                // TODO: navigate to document / focus text view
            }
            else
            {
                var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
                if (document != null)
                {
                    var languageService = document.Project.LanguageServices.GetService <INavigationBarItemService>();

                    NavigateToItem(item, document, _subjectBuffer.CurrentSnapshot, languageService, cancellationToken);
                }
            }

            // Now that the edit has been done, refresh to make sure everything is up-to-date. At
            // this point, we now use CancellationToken.None to ensure we're properly refreshed.
            UpdateDropDownsSynchronously(CancellationToken.None);
        }
        TypeScriptUnresolvedTypeDefinition AddClass(NavigationBarItem item, IDocument document)
        {
            var defaultClass = new TypeScriptUnresolvedTypeDefinition(item.text)
            {
                UnresolvedFile = this
            };

            defaultClass.BodyRegion = item.ToRegionStartingFromOpeningCurlyBrace(document);
            defaultClass.Region     = defaultClass.BodyRegion;

            TypeScriptUnresolvedTypeDefinition parentClass = FindParentClass(defaultClass);

            if (parentClass != null)
            {
                defaultClass.Namespace = parentClass.FullName;
                parentClass.NestedTypes.Add(defaultClass);
            }
            else
            {
                typeDefinitions.Add(defaultClass);
            }
            AddMethods(defaultClass, item.childItems, document);
            return(defaultClass);
        }
 public abstract void NavigateToItem(Document document, NavigationBarItem item, ITextView textView, CancellationToken cancellationToken);
        private void PushSelectedItemsToPresenter(NavigationBarSelectedTypeAndMember selectedItems)
        {
            AssertIsForeground();

            var oldLeft = selectedItems.TypeItem;
            var oldRight = selectedItems.MemberItem;

            NavigationBarItem newLeft = null;
            NavigationBarItem newRight = null;
            var listOfLeft = new List<NavigationBarItem>();
            var listOfRight = new List<NavigationBarItem>();

            if (oldRight != null)
            {
                newRight = new NavigationBarItem(oldRight.Text, oldRight.Glyph, oldRight.Spans, oldRight.ChildItems, 0, oldRight.Bolded, oldRight.Grayed || selectedItems.ShowMemberItemGrayed);
                newRight.TrackingSpans = oldRight.TrackingSpans;
                listOfRight.Add(newRight);
            }

            if (oldLeft != null)
            {
                newLeft = new NavigationBarItem(oldLeft.Text, oldLeft.Glyph, oldLeft.Spans, listOfRight, 0, oldLeft.Bolded, oldLeft.Grayed || selectedItems.ShowTypeItemGrayed);
                newLeft.TrackingSpans = oldLeft.TrackingSpans;
                listOfLeft.Add(newLeft);
            }

            IList<NavigationBarProjectItem> projectItems;
            NavigationBarProjectItem selectedProjectItem;
            GetProjectItems(out projectItems, out selectedProjectItem);

            _presenter.PresentItems(
                projectItems,
                selectedProjectItem,
                listOfLeft,
                newLeft,
                newRight);
            _versionStampOfFullListPushedToPresenter = null;
        }
 public override void NavigateToItem(Document document, NavigationBarItem item, ITextView textView, CancellationToken cancellationToken)
 {
     NavigateToSymbolItem(document, (NavigationBarSymbolItem)item, cancellationToken);
 }
Exemplo n.º 22
0
 public virtual bool ShowItemGrayedIfNear(NavigationBarItem item)
 {
     return(true);
 }
Exemplo n.º 23
0
        void AddInterface(NavigationBarItem item, IDocument document)
        {
            DefaultClass c = AddClass(item, document);

            c.ClassType = ClassType.Interface;
        }
 public Task <bool> TryNavigateToItemAsync(Document document, NavigationBarItem item, ITextView textView, ITextVersion textVersion, CancellationToken cancellationToken)
 => TryNavigateToItemAsync(document, (WrappedNavigationBarItem)item, textView, textVersion, cancellationToken);
 public bool ShowItemGrayedIfNear(NavigationBarItem item)
 {
     // We only show items in gray when near that actually exist (i.e. are not meant for codegen).
     // This will be all C# items, and only VB non-codegen items.
     return(((WrappedNavigationBarItem)item).UnderlyingItem is SymbolItem);
 }
Exemplo n.º 26
0
 private void NavigateToItem(NavigationBarItem item, Document document, ITextSnapshot snapshot, INavigationBarItemService languageService, CancellationToken cancellationToken)
 {
     item.Spans = item.TrackingSpans.Select(ts => ts.GetSpan(snapshot).Span.ToTextSpan()).ToList();
     languageService.NavigateToItem(document, item, _presenter.TryGetCurrentView(), cancellationToken);
 }
Exemplo n.º 27
0
 public NavigationBarSelectedTypeAndMember(NavigationBarItem typeItem, NavigationBarItem memberItem)
 {
     TypeItem = typeItem;
     MemberItem = memberItem;
 }
        /// <summary>
        /// Process the selection of an item synchronously inside a wait context.
        /// </summary>
        /// <param name="item">The selected item.</param>
        /// <param name="cancellationToken">A cancellation token from the wait context.</param>
        private void ProcessItemSelectionSynchronously(NavigationBarItem item, CancellationToken cancellationToken)
        {
            AssertIsForeground();

            var projectItem = item as NavigationBarProjectItem;
            if (projectItem != null)
            {
                projectItem.SwitchToContext();

                // TODO: navigate to document / focus text view
            }
            else
            {
                var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
                if (document != null)
                {
                    var languageService = document.Project.LanguageServices.GetService<INavigationBarItemService>();

                    NavigateToItem(item, document, _subjectBuffer.CurrentSnapshot, languageService, cancellationToken);
                }
            }

            // Now that the edit has been done, refresh to make sure everything is up-to-date. At
            // this point, we now use CancellationToken.None to ensure we're properly refreshed.
            UpdateDropDownsSynchronously(CancellationToken.None);
        }
Exemplo n.º 29
0
 public NavigationBarSelectedTypeAndMember(NavigationBarItem typeItem, NavigationBarItem memberItem)
 {
     TypeItem   = typeItem;
     MemberItem = memberItem;
 }
 public virtual bool ShowItemGrayedIfNear(NavigationBarItem item)
 {
     return true;
 }
 public virtual bool ShowItemGrayedIfNear(NavigationBarItem item)
 => true;
Exemplo n.º 32
0
        /// <summary>
        /// Process the selection of an item synchronously inside a wait context.
        /// </summary>
        /// <param name="item">The selected item.</param>
        /// <param name="cancellationToken">A cancellation token from the wait context.</param>
        private void ProcessItemSelectionSynchronously(NavigationBarItem item, CancellationToken cancellationToken)
        {
            AssertIsForeground();

            var presentedItem = item as NavigationBarPresentedItem;
            if (presentedItem != null)
            {
                // Presented items are not navigable, but they may be selected due to a race
                // documented in Bug #1174848. Protect all INavigationBarItemService implementers
                // from this by ignoring these selections here.
                return;
            }

            var projectItem = item as NavigationBarProjectItem;
            if (projectItem != null)
            {
                projectItem.SwitchToContext();

                // TODO: navigate to document / focus text view
            }
            else
            {
                var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
                if (document != null)
                {
                    var languageService = document.Project.LanguageServices.GetService<INavigationBarItemService>();

                    NavigateToItem(item, document, _subjectBuffer.CurrentSnapshot, languageService, cancellationToken);
                }
            }

            // Now that the edit has been done, refresh to make sure everything is up-to-date. At
            // this point, we now use CancellationToken.None to ensure we're properly refreshed.
            UpdateDropDownsSynchronously(CancellationToken.None);
        }
Exemplo n.º 33
0
 private void NavigateToItem(NavigationBarItem item, Document document, ITextSnapshot snapshot, INavigationBarItemService languageService, CancellationToken cancellationToken)
 {
     item.Spans = item.TrackingSpans.Select(ts => ts.GetSpan(snapshot).Span.ToTextSpan()).ToList();
     languageService.NavigateToItem(document, item, _presenter.TryGetCurrentView(), cancellationToken);
 }
Exemplo n.º 34
0
 protected override void BindAllFoldersItem(NavigationBarItem allFoldersItem)
 {
     allFoldersItem.BindCommand(() => CollectionViewModel.ShowAllFolders(), CollectionViewModel);
 }
Exemplo n.º 35
0
 public abstract void NavigateToItem(Document document, NavigationBarItem item, ITextView textView, CancellationToken cancellationToken);
 public Task NavigateToItemAsync(Document document, NavigationBarItem item, ITextView textView, CancellationToken cancellationToken)
 => NavigateToItemAsync(document, (WrappedNavigationBarItem)item, textView, cancellationToken);
Exemplo n.º 37
0
 public void NavigateToItem(Document document, NavigationBarItem item, ITextView view, CancellationToken cancellationToken)
 => throw new NotSupportedException($"Caller should call {nameof(NavigateToItemAsync)} instead");
Exemplo n.º 38
0
 static bool IsGlobalModule(NavigationBarItem item)
 {
     return(item.text == "<global>");
 }
Exemplo n.º 39
0
 public bool ShowItemGrayedIfNear(NavigationBarItem item)
 {
     return(false);
 }
 public override void NavigateToItem(Document document, NavigationBarItem item, ITextView textView, CancellationToken cancellationToken)
 {
     NavigateToSymbolItem(document, (NavigationBarSymbolItem)item, cancellationToken);
 }