示例#1
0
        internal Platform()
        {
            PlatformRenderer = new PlatformRenderer(this);

            MessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) =>
            {
                var alert  = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Accept, null, arguments.Message);
                var result = alert.RunSheetModal(PlatformRenderer.View.Window);
                if (arguments.Accept == null)
                {
                    arguments.SetResult(result == 1);
                }
                else
                {
                    arguments.SetResult(result == 0);
                }
            });

            MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) =>
            {
                var alert = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Destruction, null, "");
                if (arguments.Buttons != null)
                {
                    int maxScrollHeight = (int)(0.6 * NSScreen.MainScreen.Frame.Height);
                    NSView extraButtons = GetExtraButton(arguments);
                    if (extraButtons.Frame.Height > maxScrollHeight)
                    {
                        NSScrollView scrollView        = new NSScrollView();
                        scrollView.Frame               = new RectangleF(0, 0, extraButtons.Frame.Width, maxScrollHeight);
                        scrollView.DocumentView        = extraButtons;
                        scrollView.HasVerticalScroller = true;
                        alert.AccessoryView            = scrollView;
                    }
                    else
                    {
                        alert.AccessoryView = extraButtons;
                    }
                    alert.Layout();
                }

                var result      = (int)alert.RunSheetModal(PlatformRenderer.View.Window);
                var titleResult = string.Empty;
                if (result == 1)
                {
                    titleResult = arguments.Cancel;
                }
                else if (result == 0)
                {
                    titleResult = arguments.Destruction;
                }
                else if (result > 1 && arguments.Buttons != null && result - 2 <= arguments.Buttons.Count())
                {
                    titleResult = arguments.Buttons.ElementAt(result - 2);
                }

                arguments.SetResult(titleResult);
            });
        }
示例#2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    _modalTracker.Dispose();
                    _modalTracker     = null;
                    _platformRenderer = null;
                }

                _disposed = true;
            }
        }
示例#3
0
        internal Platform()
        {
            PlatformRenderer = new PlatformRenderer(this);

            MessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) =>
            {
                var alert  = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Accept, null, arguments.Message);
                var result = alert.RunSheetModal(PlatformRenderer.View.Window);
                if (arguments.Accept == null)
                {
                    arguments.SetResult(result == 1);
                }
                else
                {
                    arguments.SetResult(result == 0);
                }
            });

            MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) =>
            {
                var alert = NSAlert.WithMessage(arguments.Title, arguments.Cancel, arguments.Destruction, null, "");
                if (arguments.Buttons != null)
                {
                    alert.AccessoryView = GetExtraButton(arguments);
                    alert.Layout();
                }

                var result      = (int)alert.RunSheetModal(PlatformRenderer.View.Window);
                var titleResult = string.Empty;
                if (result == 1)
                {
                    titleResult = arguments.Cancel;
                }
                else if (result == 0)
                {
                    titleResult = arguments.Destruction;
                }
                else if (result > 1 && arguments.Buttons != null && result - 2 <= arguments.Buttons.Count())
                {
                    titleResult = arguments.Buttons.ElementAt(result - 2);
                }

                arguments.SetResult(titleResult);
            });
        }
示例#4
0
 public PlatformNavigation(PlatformRenderer mainRenderer)
 {
     _platformRenderer = mainRenderer;
     _modalTracker     = new ModalPageTracker(_platformRenderer);
     _animateModals    = true;
 }