protected void LoadApplication(Application application) { if (application == null) throw new ArgumentNullException("application"); Application.Current = application; Platform = CreatePlatform(); Platform.SetPage(Application.Current.MainPage); application.PropertyChanged += OnApplicationPropertyChanged; Application.Current.SendStart(); }
void InternalSetPage(Page page) { if (!Forms.IsInitialized) throw new InvalidOperationException("Call Forms.Init (Activity, Bundle) before this"); if (_canvas != null) { _canvas.SetPage(page); return; } var busyCount = 0; MessagingCenter.Subscribe(this, Page.BusySetSignalName, (Page sender, bool enabled) => { busyCount = Math.Max(0, enabled ? busyCount + 1 : busyCount - 1); if (!Forms.SupportsProgress) return; SetProgressBarIndeterminate(true); UpdateProgressBarVisibility(busyCount > 0); }); UpdateProgressBarVisibility(busyCount > 0); MessagingCenter.Subscribe(this, Page.AlertSignalName, (Page sender, AlertArguments arguments) => { AlertDialog alert = new AlertDialog.Builder(this).Create(); alert.SetTitle(arguments.Title); alert.SetMessage(arguments.Message); if (arguments.Accept != null) alert.SetButton((int)DialogButtonType.Positive, arguments.Accept, (o, args) => arguments.SetResult(true)); alert.SetButton((int)DialogButtonType.Negative, arguments.Cancel, (o, args) => arguments.SetResult(false)); alert.CancelEvent += (o, args) => { arguments.SetResult(false); }; alert.Show(); }); MessagingCenter.Subscribe(this, Page.ActionSheetSignalName, (Page sender, ActionSheetArguments arguments) => { var builder = new AlertDialog.Builder(this); builder.SetTitle(arguments.Title); string[] items = arguments.Buttons.ToArray(); builder.SetItems(items, (sender2, args) => { arguments.Result.TrySetResult(items[args.Which]); }); if (arguments.Cancel != null) builder.SetPositiveButton(arguments.Cancel, delegate { arguments.Result.TrySetResult(arguments.Cancel); }); if (arguments.Destruction != null) builder.SetNegativeButton(arguments.Destruction, delegate { arguments.Result.TrySetResult(arguments.Destruction); }); AlertDialog dialog = builder.Create(); builder.Dispose(); //to match current functionality of renderer we set cancelable on outside //and return null dialog.SetCanceledOnTouchOutside(true); dialog.CancelEvent += (sender3, e) => { arguments.SetResult(null); }; dialog.Show(); }); _canvas = new Platform(this); if (_application != null) _application.Platform = _canvas; _canvas.SetPage(page); _layout.AddView(_canvas.GetViewGroup()); }