예제 #1
0
 public override void Confirm(ConfirmConfig config)
 {
     var dialog = new MessageDialog(config.Message, config.Title);
     dialog.Commands.Add(new UICommand(config.OkText, x => config.OnConfirm(true)));
     dialog.Commands.Add(new UICommand(config.CancelText, x => config.OnConfirm(false)));
     dialog.ShowAsync();
 }
예제 #2
0
 public virtual Task<bool> ConfirmAsync(ConfirmConfig config)
 {
     var tcs = new TaskCompletionSource<bool>();
     config.OnConfirm = x => tcs.TrySetResult(x);
     this.Confirm(config);
     return tcs.Task;
 }
예제 #3
0
 public override IDisposable Confirm(ConfirmConfig config)
 {
     var dlg = new TaskDialog
     {
         WindowTitle = config.Title,
         Content = config.Message,
         Buttons =
         {
             new TaskDialogButton(config.CancelText)
             {
                 ButtonType = ButtonType.Cancel
             },
             new TaskDialogButton(config.OkText)
             {
                 ButtonType = ButtonType.Ok
             }
         }
     };
     dlg.ButtonClicked += (sender, args) =>
     {
         var ok = ((TaskDialogButton)args.Item).ButtonType == ButtonType.Ok;
         config.OnAction(ok);
     };
     return new DisposableAction(dlg.Dispose);
 }
예제 #4
0
 public override IDisposable Confirm(ConfirmConfig config)
 {
     var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
     dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Cancel, x => config.OnAction(false)));
     dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnAction(true)));
     return this.Present(dlg);
 }
예제 #5
0
        public override void Confirm(ConfirmConfig config) {
            var dialog = new MessageDialog(config.Message, config.Title);
            dialog.Commands.Add(new UICommand(config.OkText, x => config.OnConfirm(true)));
            dialog.DefaultCommandIndex = 0;

            dialog.Commands.Add(new UICommand(config.CancelText, x => config.OnConfirm(false)));
            dialog.CancelCommandIndex = 1;
            this.Dispatch(() => dialog.ShowAsync());
        }
예제 #6
0
 public override IDisposable Confirm(ConfirmConfig config)
 {
     return(this.Present(() =>
     {
         var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
         dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Cancel, x => config.OnAction?.Invoke(false)));
         dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnAction?.Invoke(true)));
         return dlg;
     }));
 }
예제 #7
0
 public override void Confirm(ConfirmConfig config) {
     var confirm = new CustomMessageBox {
         Caption = config.Title,
         Message = config.Message,
         LeftButtonContent = config.OkText,
         RightButtonContent = config.CancelText
     };
     confirm.Dismissed += (sender, args) => config.OnConfirm(args.Result == CustomMessageBoxResult.LeftButton);
     this.Dispatch(confirm.Show);
 }
예제 #8
0
        public override async void Confirm(ConfirmConfig config)
        {
            var input = new InputDialog {
                AcceptButton = config.OkText,
                CancelButton = config.CancelText
            };
            var choice = await input.ShowAsync(config.Title, config.Message);

            config.OnConfirm(config.OkText == choice);
        }
예제 #9
0
        public override void Confirm(ConfirmConfig config)
        {
            var dialog = new MessageDialog(config.Message, config.Title);

            dialog.Commands.Add(new UICommand(config.OkText, x => config.OnConfirm(true)));
            dialog.DefaultCommandIndex = 0;

            dialog.Commands.Add(new UICommand(config.CancelText, x => config.OnConfirm(false)));
            dialog.CancelCommandIndex = 1;
            this.Dispatch(() => dialog.ShowAsync());
        }
예제 #10
0
        public override IDisposable Confirm(ConfirmConfig config)
        {
            var activity = this.TopActivityFunc();

            if (activity is AppCompatActivity act)
            {
                return(this.ShowDialog <ConfirmAppCompatDialogFragment, ConfirmConfig>(act, config));
            }

            return(this.Show(activity, () => new ConfirmBuilder().Build(activity, config)));
        }
        public async Task<bool> ConfirmLogoutAsync()
        {
            var config = new ConfirmConfig()
            {
                Message = "Are you sure you want to logout?",
                OkText = "Yes",
                CancelText = "No"
            };

            return await UserDialogs.Instance.ConfirmAsync(config);
        }
예제 #12
0
        public override void Confirm(ConfirmConfig config)
        {
            var confirm = new CustomMessageBox {
                Caption            = config.Title,
                Message            = config.Message,
                LeftButtonContent  = config.OkText,
                RightButtonContent = config.CancelText
            };

            confirm.Dismissed += (sender, args) => config.OnConfirm(args.Result == CustomMessageBoxResult.LeftButton);
            this.Dispatch(confirm.Show);
        }
예제 #13
0
 public override void Confirm(ConfirmConfig config) {
     Utils.RequestMainThread(() =>
         new AlertDialog
             .Builder(this.GetTopActivity())
             .SetCancelable(false)
             .SetMessage(config.Message)
             .SetTitle(config.Title)
             .SetPositiveButton(config.OkText, (s, a) => config.OnConfirm(true))
             .SetNegativeButton(config.CancelText, (s, a) => config.OnConfirm(false))
             .ShowExt()
     );
 }
예제 #14
0
 public override void Confirm(ConfirmConfig config)
 {
     Utils.RequestMainThread(() =>
                             new AlertDialog
                             .Builder(this.getTopActivity())
                             .SetMessage(config.Message)
                             .SetTitle(config.Title)
                             .SetPositiveButton(config.OkText, (o, e) => config.OnConfirm(true))
                             .SetNegativeButton(config.CancelText, (o, e) => config.OnConfirm(false))
                             .Show()
                             );
 }
        public override IDisposable Confirm(ConfirmConfig config)
        {
            var confirm = new CustomMessageBox
            {
                Caption            = config.Title,
                Message            = config.Message,
                LeftButtonContent  = config.OkText,
                RightButtonContent = config.CancelText
            };

            confirm.Dismissed += (sender, args) => config.OnConfirm(args.Result == CustomMessageBoxResult.LeftButton);
            return(this.DispatchWithDispose(confirm.Show, confirm.Dismiss));
        }
예제 #16
0
        public override IDisposable Confirm(ConfirmConfig config) => this.Present(() =>
        {
            var alert = new NSAlert
            {
                AlertStyle      = NSAlertStyle.Informational,
                MessageText     = config.Title ?? string.Empty,
                InformativeText = config.Message
            };
            alert.AddButton(config.OkText);
            alert.AddButton(config.CancelText);

            alert.BeginSheetForResponse(this.windowFunc(), result => config.OnAction?.Invoke(result == 1000));
            return(alert);
        });
        public override IDisposable Confirm(ConfirmConfig config)
        {
            XButton positive = new XButton()
            {
                Text = config.OkText
            };
            XButton negative = new XButton()
            {
                Text = config.CancelText
            };
            XLable content = new XLable()
            {
                Text = config.Message
            };
            var layout = new StackLayout
            {
                Children =
                {
                    content,
                },
                Padding = 30
            };
            var dialog = new Dialog()
            {
                Title = config.Title,
                //Subtitle = config.Message,
                Content          = layout,
                HorizontalOption = LayoutOptions.Center,
                VerticalOption   = LayoutOptions.Center,
                Negative         = negative,
                Positive         = positive
            };

            dialog.OutsideClicked += (s, e) =>
            {
                dialog.Hide();
            };
            positive.Clicked += (s, e) =>
            {
                dialog.Hide();
                config.OnAction?.Invoke(true);
            };
            negative.Clicked += (s, e) =>
            {
                dialog.Hide();
                config.OnAction?.Invoke(false);
            };
            return(Show(dialog));
        }
예제 #18
0
        public override IDisposable Confirm(ConfirmConfig config)
        {
            var alert = new NSAlert
            {
                MessageText = config.Message
            };

            alert.AddButton(config.OkText);
            alert.AddButton(config.CancelText);
            var actionIndex = alert.RunModal();

            config.OnAction?.Invoke(actionIndex == 0);

            return(alert);
        }
        public virtual Task <bool> ConfirmAsync(ConfirmConfig config, CancellationToken?cancelToken = null)
        {
            var tcs = new TaskCompletionSource <bool>();

            config.OnConfirm = x => tcs.TrySetResult(x);

            var disp = this.Confirm(config);

            cancelToken?.Register(() =>
            {
                disp.Dispose();
                tcs.TrySetCanceled();
            });
            return(tcs.Task);
        }
예제 #20
0
        public override IDisposable Confirm(ConfirmConfig config)
        {
            var dialog = new MessageDialog(config.Message, config.Title ?? String.Empty);
            dialog.Commands.Add(new UICommand(config.OkText, x => config.OnAction?.Invoke(true)));
            dialog.DefaultCommandIndex = 0;

            dialog.Commands.Add(new UICommand(config.CancelText, x => config.OnAction?.Invoke(false)));
            dialog.CancelCommandIndex = 1;

            IAsyncOperation<IUICommand> dialogTask = null;
            return this.DispatchAndDispose(
                () => dialogTask = dialog.ShowAsync(),
                () => dialogTask?.Cancel()
            );
        }
예제 #21
0
 public override void Confirm(ConfirmConfig config) {
     if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) {
         var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
         dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnConfirm(true)));
         dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => config.OnConfirm(false)));
         this.Present(dlg);
     }
     else {
         var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText);
         dlg.Clicked += (s, e) => {
             var ok = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex);
             config.OnConfirm(ok);
         };
         this.Present(dlg);
     }
 }
        public override IDisposable Confirm(ConfirmConfig config)
        {
            var activity = this.TopActivityFunc();

            if (activity is AppCompatActivity)
            {
                return(this.ShowDialog <ConfirmAppCompatDialogFragment, ConfirmConfig>((AppCompatActivity)activity, config));
            }

            if (activity is FragmentActivity)
            {
                return(this.ShowDialog <ConfirmDialogFragment, ConfirmConfig>((FragmentActivity)activity, config));
            }

            return(this.Show(activity, ConfirmBuilder.Build(activity, config)));
        }
예제 #23
0
        public override IDisposable Confirm(ConfirmConfig config)
        {
            var dialog = new MessageDialog(config.Message, config.Title ?? String.Empty);

            dialog.Commands.Add(new UICommand(config.OkText, x => config.OnAction?.Invoke(true)));
            dialog.DefaultCommandIndex = 0;

            dialog.Commands.Add(new UICommand(config.CancelText, x => config.OnAction?.Invoke(false)));
            dialog.CancelCommandIndex = 1;

            IAsyncOperation <IUICommand> dialogTask = null;

            return(this.DispatchAndDispose(
                       () => dialogTask = dialog.ShowAsync(),
                       () => dialogTask?.Cancel()
                       ));
        }
예제 #24
0
        public virtual async Task <bool> ConfirmAsync(ConfirmConfig config, CancellationToken?cancelToken = null)
        {
            if (config.OnAction != null)
            {
                throw new ArgumentException(NO_ONACTION);
            }

            var tcs = new TaskCompletionSource <bool>();

            config.OnAction = x => tcs.TrySetResult(x);

            var disp = this.Confirm(config);

            using (cancelToken?.Register(() => Cancel(disp, tcs)))
            {
                return(await tcs.Task);
            }
        }
예제 #25
0
 public override IDisposable Confirm(ConfirmConfig config)
 {
     Dispatch(() =>
     {
         FormsContentDialog dialog = new FormsContentDialog()
         {
             Title   = config.Title,
             Content = config.Message,
             IsPrimaryButtonEnabled   = true,
             PrimaryButtonText        = config.OkText,
             IsSecondaryButtonEnabled = true,
             SecondaryButtonText      = config.CancelText
         };
         dialog.PrimaryButtonClick   += (s, e) => { HideContentDialog(); config.OnAction(true); e.Cancel = true; };
         dialog.SecondaryButtonClick += (s, e) => { HideContentDialog(); config.OnAction(false); e.Cancel = true; };
         ShowContentDialog(dialog);
     });
     return(new DisposableAction(HideContentDialog));
 }
 public override void Confirm(ConfirmConfig config)
 {
     if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
     {
         var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
         dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Cancel, x => config.OnConfirm(false)));
         dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnConfirm(true)));
         this.Present(dlg);
     }
     else
     {
         var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText);
         dlg.Clicked += (s, e) => {
             var ok = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex);
             config.OnConfirm(ok);
         };
         this.Present(dlg);
     }
 }
예제 #27
0
        public virtual Task <bool> ConfirmAsync(ConfirmConfig config, CancellationToken?cancelToken = null)
        {
            if (config.OnAction != null)
            {
                throw new ArgumentException(NO_ONACTION);
            }

            var tcs = new TaskCompletionSource <bool>();

            config.OnAction = x => tcs.TrySetResult(x);

            var disp = this.Confirm(config);

            cancelToken?.Register(() =>
            {
                disp.Dispose();
                tcs.TrySetCanceled();
            });
            return(tcs.Task);
        }
예제 #28
0
        /// <summary> Gets confirm configuration. </summary>
        /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
        /// <param name="config"> The configuration. </param>
        /// <returns> The confirm configuration. </returns>
        private AcrDialogs.ConfirmConfig GetConfirmConfig(UserDialogConfirmConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var result = new AcrDialogs.ConfirmConfig();

            if (config.Title != null)
            {
                result.Title = config.Title;
            }
            if (config.Message != null)
            {
                result.Message = config.Message;
            }
            if (config.AndroidStyleId != null)
            {
                result.AndroidStyleId = config.AndroidStyleId;
            }
            if (config.OnAction != null)
            {
                result.OnAction = config.OnAction;
            }
            if (config.OkText != null)
            {
                result.OkText = config.OkText;
            }
            if (config.CancelText != null)
            {
                result.CancelText = config.CancelText;
            }

            return(result);
        }
예제 #29
0
 public override IDisposable Confirm(ConfirmConfig config)
 {
     var confirm = new CustomMessageBox
     {
         Caption = config.Title,
         Message = config.Message,
         LeftButtonContent = config.OkText,
         RightButtonContent = config.CancelText
     };
     confirm.Dismissed += (sender, args) => config.OnAction(args.Result == CustomMessageBoxResult.LeftButton);
     return this.DispatchWithDispose(confirm.Show, confirm.Dismiss);
 }
예제 #30
0
 public abstract void Confirm(ConfirmConfig config);
예제 #31
0
 public override IDisposable Confirm(ConfirmConfig config)
 {
     throw new NotImplementedException ();
 }
예제 #32
0
 public abstract void Confirm(ConfirmConfig config);
예제 #33
0
 public override IDisposable Confirm(ConfirmConfig config)
 {
     throw new NotImplementedException();
 }
예제 #34
0
 public abstract IDisposable Confirm(ConfirmConfig config);