Esempio n. 1
0
        public void Execute(IDataContext context, DelegateExecute nextExecute)
        {
            ISolution   solution = context.GetData(ProjectModelDataConstants.SOLUTION);
            IShellLocks locks    = context.GetComponent <IShellLocks>();
            PopupWindowContextSource popupWindowContextSource = context.GetData(UIDataConstants.PopupWindowContextSource);

            Debug.Assert(popupWindowContextSource != null, "popupWindowContextSource != null");
            Debug.Assert(solution != null, "solution != null");

            void Atomic(LifetimeDefinition lifetimeDefinition, Lifetime lifetime)
            {
                var controller = new GotoGeneratorController(
                    lifetime,
                    solution,
                    locks,
                    context,
                    Shell.Instance.GetComponent <IMainWindowPopupWindowContext>(),
                    false /* enableMulticore */
                    );

                GotoByNameMenu menu = new GotoByNameMenu(
                    context.GetComponent <GotoByNameMenuComponent>(),
                    lifetimeDefinition,
                    controller.Model,
                    context.GetComponent <UIApplication>().MainWindow.TryGetActiveWindow(),
                    solution.GetComponent <GotoByNameModelManager>().GetSearchTextData(context, controller),
                    popupWindowContextSource.Create(lifetime)
                    );

                MakeBusyIconVisibleOnEmptyFilter(menu, controller.Model, lifetime);
            }

            Lifetimes.Define(solution.GetLifetime(), null /* id */, Atomic);
        }
Esempio n. 2
0
        public void ShowMenu(
            [NotNull] IProjectModelElement projectElement, [CanBeNull] ITextControl textControl,
            [CanBeNull] GotoByNameDataConstants.SearchTextData initialText)
        {
            var solution   = projectElement.GetSolution();
            var definition = Lifetimes.Define(solution.GetLifetime());

            var controller = new GotoWordController(
                definition.Lifetime, myShellLocks, projectElement, textControl);

            if (textControl != null)
            {
                // use selected text if there is no initial
                // todo: how to make this work with recent list?
                var selection = textControl.Selection.Ranges.Value;
                if (selection != null && selection.Count == 1)
                {
                    var docRange = selection[0].ToDocRangeNormalized();
                    if (docRange.Length > 0)
                    {
                        var selectedText = textControl.Document.GetText(docRange);
                        initialText = new GotoByNameDataConstants.SearchTextData(
                            selectedText, TextRange.FromLength(selectedText.Length));
                    }
                }
            }

            var menu = new GotoByNameMenu(
                myMenuComponent, definition, controller.Model,
                myUiApplication.MainWindow, initialText);

            var menuDoc = menu.MenuView.Value.Document.NotNull("menuDoc != null");

            menuDoc.SelectedItem.FlowInto(
                definition.Lifetime, controller.SelectedItem,
                FConverter: item => (item != null) ? item.Key : null);
        }
Esempio n. 3
0
        private static void MakeBusyIconVisibleOnEmptyFilter(GotoByNameMenu menu, GotoByNameModel model, Lifetime lifetime)
        {
            EditboxGlyph     glyph  = null;
            EditboxCueBanner banner = null;
            JetPopupMenuView view   = menu.MenuView.GetValue();

            foreach (Control control in view.Title.QuickSearchEditbox.Controls)
            {
                glyph  = glyph ?? control as EditboxGlyph;
                banner = banner ?? control as EditboxCueBanner;
                if (glyph != null && banner != null)
                {
                    break;
                }
            }

            IProperty <bool> property = model.IsReady.CreateNot(lifetime);
            IProperty <bool> target   = new Property <bool>(lifetime, "isShowGlyphDeferred");
            PropertyBindingDeferred <bool> propertyBindingDeferred =
                new PropertyBindingDeferred <bool>(lifetime, property, target, TimeSpan.FromSeconds(0.3));

            target.Change.Advise_HasNew(lifetime, args => glyph.Visible = args.New);
            property.WhenTrueOnce(lifetime, () => banner.Visible        = false);
        }