Beispiel #1
0
        private void OnCustomExpression(object sender, EventArgs e)
        {
            var customExpressionView = new CustomExpressionView(this.hostResources, viewModel)
            {
                Appearance = EffectiveAppearance
            };

            var customExpressionPopOver = new AutoClosePopOver {
                ContentViewController = new NSViewController(null, null)
                {
                    View = customExpressionView
                },
            };

            customExpressionPopOver.SetAppearance(this.hostResources.GetVibrantAppearance(EffectiveAppearance));

            customExpressionPopOver.Show(customExpressionView.Frame, (NSView)this, NSRectEdge.MinYEdge);
        }
        private void OnResourceRequested(object sender, EventArgs e)
        {
            var requestResourceView = new RequestResourceView(this.hostResources, this.viewModel)
            {
                Appearance = EffectiveAppearance
            };

            var resourceSelectorPopOver = new AutoClosePopOver(this.hostResources, EffectiveAppearance)
            {
                ContentViewController = new NSViewController(null, null)
                {
                    View = requestResourceView
                },
            };

            requestResourceView.PopOver = resourceSelectorPopOver;

            resourceSelectorPopOver.Show(requestResourceView.Frame, (NSView)this, NSRectEdge.MinYEdge);
        }
Beispiel #3
0
        public static Task <ITypeInfo> RequestAt(this TypeRequestedEventArgs self, IHostResourceProvider hostResources, NSView source, AsyncValue <IReadOnlyDictionary <IAssemblyInfo, ILookup <string, ITypeInfo> > > assignableTypes)
        {
            var tcs = new TaskCompletionSource <ITypeInfo> ();

            var vm       = new TypeSelectorViewModel(assignableTypes);
            var selector = new TypeSelectorControl {
                ViewModel  = vm,
                Appearance = source.EffectiveAppearance
            };

            vm.PropertyChanged += (vms, ve) => {
                if (ve.PropertyName == nameof(TypeSelectorViewModel.SelectedType))
                {
                    tcs.TrySetResult(vm.SelectedType);
                }
            };

            var popover = new AutoClosePopOver(hostResources, hostResources.GetVibrantAppearance(source.EffectiveAppearance))
            {
                Delegate = new PopoverDelegate <ITypeInfo> (tcs),
                ContentViewController = new NSViewController {
                    View = selector,
                    PreferredContentSize = new CoreGraphics.CGSize(360, 335)
                },
            };

            tcs.Task.ContinueWith(t => {
                // Focus back to the button that popped us up
                source.Superview?.Window?.MakeFirstResponder(source);

                popover.PerformClose(popover);
                popover.Dispose();
            }, TaskScheduler.FromCurrentSynchronizationContext());

            popover.Show(source.Frame, source.Superview, NSRectEdge.MinYEdge);
            return(tcs.Task);
        }