internal Platform() { _renderer = 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(_renderer.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(_renderer.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); }); }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { _modalTracker.Dispose(); _modalTracker = null; _platformRenderer = null; } _disposed = true; } }
public PlatformNavigation(PlatformRenderer mainRenderer) { _platformRenderer = mainRenderer; _modalTracker = new ModalPageTracker(_platformRenderer); _animateModals = true; }