コード例 #1
0
        /// <summary> Gets alert configuration. </summary>
        /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
        /// <param name="config"> The configuration. </param>
        /// <returns> The alert configuration. </returns>
        private AcrDialogs.AlertConfig GetAlertConfig(UserDialogAlertConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var result = new AcrDialogs.AlertConfig();

            if (config.OkText != null)
            {
                result.OkText = config.OkText;
            }
            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;
            }

            return(result);
        }
コード例 #2
0
 public virtual Task AlertAsync(AlertConfig config)
 {
     var tcs = new TaskCompletionSource<object>();
     config.OnOk = () => tcs.TrySetResult(null);
     this.Alert(config);
     return tcs.Task;
 }
コード例 #3
0
        public override void Alert(AlertConfig config)
        {
            var dlg = config.Title == null
                ? new MessageDialog(config.Message)
                : new MessageDialog(config.Message, config.Title);

            dlg.ShowAsync();
        }
コード例 #4
0
 public override IDisposable Alert(AlertConfig config)
 {
     return this.Present(() =>
     {
         var alert = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
         alert.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnAction?.Invoke()));
         return alert;
     });
 }
コード例 #5
0
        public LoginPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            LoginCommand = new DelegateCommand(async() =>
            {
                var repoLogin = new LoginRepository();

                var pdcMessage = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在身分驗證中..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(pdcMessage))
                {
                    APIResult apiResult;
                    if (UsingHttpGet == true)
                    {
                        apiResult = await repoLogin.GetAsync(Account, Password);
                    }
                    else
                    {
                        apiResult = await repoLogin.PostAsync(Account, Password);
                    }

                    apiResult = new APIResult()
                    {
                        Success = true
                    };                                            //跳過驗證debug

                    if (apiResult.Success == false)
                    {
                        var config = new Acr.UserDialogs.AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"進行使用者身分驗證失敗,原因:{Environment.NewLine}{apiResult.Message}",
                            OkText  = "確定",
                        };

                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                    }
                    else
                    {
                        var repoSystemStatus = new SystemStatusRepository();
                        await repoSystemStatus.ReadAsync();
                        repoSystemStatus.Item.LoginMethodAction = UsingHttpGet;
                        repoSystemStatus.Item.AccessToken       = repoLogin.Item.AccessToken;
                        await repoSystemStatus.SaveAsync();
                        await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                    }
                }
            });
#if DEBUG
            Account  = "ycwu";
            Password = "******";
#endif
        }
コード例 #6
0
        public override IDisposable Alert(AlertConfig config)
        {
            var dialog = new MessageDialog(config.Message, config.Title ?? String.Empty);
            dialog.Commands.Add(new UICommand(config.OkText, x => config.OnAction?.Invoke()));
            IAsyncOperation<IUICommand> dialogTask = null;

            return this.DispatchAndDispose(
                () => dialogTask = dialog.ShowAsync(),
                () => dialogTask?.Cancel()
            );
        }
コード例 #7
0
 public override IDisposable Alert(AlertConfig config)
 {
     var alert = new CustomMessageBox
     {
         Caption = config.Title,
         Message = config.Message,
         LeftButtonContent = config.OkText,
         IsRightButtonEnabled = false
     };
     alert.Dismissed += (sender, args) => config.OnAction?.Invoke();
     return this.DispatchWithDispose(alert.Show, alert.Dismiss);
 }
コード例 #8
0
 public override void Alert(AlertConfig config) {
     if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) {
         var alert = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
         alert.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnOk?.Invoke()));
         this.Present(alert);
     }
     else {
         var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, null, config.OkText);
         dlg.Clicked += (s, e) => config.OnOk?.Invoke();
         this.Present(dlg);
     }
 }
コード例 #9
0
        public LoginPageViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            LoginCommand = new DelegateCommand(async() =>
            {
                var fooLoginRepository = new LoginRepository();

                var fooProgressDialogConfig = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在身分驗證中..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
                {
                    APIResult fooResult;
                    if (UsingHttpGet == true)
                    {
                        fooResult = await fooLoginRepository.GetAsync(Account, Password);
                    }
                    else
                    {
                        fooResult = await fooLoginRepository.PostAsync(Account, Password);
                    }
                    if (fooResult.Success == false)
                    {
                        var config = new Acr.UserDialogs.AlertConfig()
                        {
                            Title   = "警告",
                            Message = $"進行使用者身分驗證失敗,原因:{Environment.NewLine}{fooResult.Message}",
                            OkText  = "確定",
                        };

                        await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                    }
                    else
                    {
                        var fooSystemStatusRepository = new SystemStatusRepository();
                        await fooSystemStatusRepository.ReadAsync();
                        fooSystemStatusRepository.Item.LoginMethodAction = UsingHttpGet;
                        fooSystemStatusRepository.Item.AccessToken       = fooLoginRepository.Item.AccessToken;
                        await fooSystemStatusRepository.SaveAsync();
                        await _navigationService.NavigateAsync("xf:///MDPage/NaviPage/AboutPage");
                    }
                }
            });

#if DEBUG
            Account  = "user1";
            Password = "******";
#endif
        }
コード例 #10
0
        public override void Alert(AlertConfig config) {
            this.Dispatch(() => {
                var alert = new CustomMessageBox {
                    Caption = config.Title,
                    Message = config.Message,
                    LeftButtonContent = config.OkText,
                    IsRightButtonEnabled = false
                };
                alert.Dismissed += (sender, args) => config.OnOk?.Invoke();

                alert.Show();
            });
        }
コード例 #11
0
 public override IDisposable Alert(AlertConfig config)
 {
     var dlg = new TaskDialog
     {
         WindowTitle = config.Title,
         Content = config.Message,
         Buttons =
         {
             new TaskDialogButton(config.OkText)
         }
     };
     dlg.ShowDialog();
     return new DisposableAction(dlg.Dispose);
 }
コード例 #12
0
        public override IDisposable Alert(AlertConfig config)
        {
            var dlg = new TaskDialog
            {
                WindowTitle = config.Title,
                Content     = config.Message,
                Buttons     =
                {
                    new TaskDialogButton(config.OkText)
                }
            };

            dlg.ShowDialog();
            return(new DisposableAction(dlg.Dispose));
        }
コード例 #13
0
        public override IDisposable Alert(AlertConfig config)
        {
            var activity = this.TopActivityFunc();

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

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

            return(this.Show(activity, () => new AlertBuilder().Build(activity, config)));
        }
コード例 #14
0
 public override void Alert(AlertConfig config)
 {
     Utils.RequestMainThread(() =>
                             new AlertDialog
                             .Builder(this.getTopActivity())
                             .SetMessage(config.Message)
                             .SetTitle(config.Title)
                             .SetPositiveButton(config.OkText, (o, e) => {
         if (config.OnOk != null)
         {
             config.OnOk();
         }
     })
                             .Show()
                             );
 }
コード例 #15
0
 public override IDisposable Alert(AlertConfig config)
 {
     Dispatch(() =>
     {
         FormsContentDialog dialog = new FormsContentDialog()
         {
             Title   = config.Title,
             Content = config.Message,
             IsPrimaryButtonEnabled = true,
             PrimaryButtonText      = config.OkText
         };
         dialog.PrimaryButtonClick += (s, e) => { HideContentDialog(); e.Cancel = true; };
         ShowContentDialog(dialog);
     });
     return(new DisposableAction(HideContentDialog));
 }
コード例 #16
0
        public virtual Task AlertAsync(AlertConfig config, CancellationToken?cancelToken = null)
        {
            var tcs = new TaskCompletionSource <object>();

            config.OnOk = () => tcs.TrySetResult(null);

            var disp = this.Alert(config);

            cancelToken?.Register(() =>
            {
                disp.Dispose();
                tcs.TrySetCanceled();
            });

            return(tcs.Task);
        }
コード例 #17
0
 public override void Alert(AlertConfig config)
 {
     UIApplication.SharedApplication.InvokeOnMainThread(() => {
         if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
         {
             var alert = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
             alert.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnOk?.Invoke()));
             this.Present(alert);
         }
         else
         {
             var dlg      = new UIAlertView(config.Title ?? String.Empty, config.Message, null, null, config.OkText);
             dlg.Clicked += (s, e) => config.OnOk?.Invoke();
             dlg.Show();
         }
     });
 }
コード例 #18
0
        public override void Alert(AlertConfig config)
        {
            this.Dispatch(() => {
                var alert = new CustomMessageBox {
                    Caption              = config.Title,
                    Message              = config.Message,
                    LeftButtonContent    = config.OkText,
                    IsRightButtonEnabled = false
                };
                if (config.OnOk != null)
                {
                    alert.Dismissed += (sender, args) => config.OnOk();
                }

                alert.Show();
            });
        }
コード例 #19
0
        public override void Alert(AlertConfig config) {
            //var context = this.GetTopActivity();
            //var layout = new LinearLayout(context) {
            //    Orientation = Orientation.Vertical,
            //    OverScrollMode = OverScrollMode.IfContentScrolls
            //};
            //var txt = new TextView(context);

            Utils.RequestMainThread(() =>
                new AlertDialog
                    .Builder(this.GetTopActivity())
                    .SetCancelable(false)
                    .SetMessage(config.Message)
                    .SetTitle(config.Title)
					.SetPositiveButton(config.OkText, (o, e) => config.OnOk?.Invoke())
                    .ShowExt()
            );
        }
コード例 #20
0
        public virtual async Task AlertAsync(AlertConfig config, CancellationToken?cancelToken = null)
        {
            if (config.OnAction != null)
            {
                throw new ArgumentException(NO_ONACTION);
            }

            var tcs = new TaskCompletionSource <object>();

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

            var disp = this.Alert(config);

            using (cancelToken?.Register(() => Cancel(disp, tcs)))
            {
                await tcs.Task;
            }
        }
コード例 #21
0
        public override void Alert(AlertConfig config)
        {
            //var context = this.GetTopActivity();
            //var layout = new LinearLayout(context) {
            //    Orientation = Orientation.Vertical,
            //    OverScrollMode = OverScrollMode.IfContentScrolls
            //};
            //var txt = new TextView(context);

            Utils.RequestMainThread(() =>
                                    new AlertDialog
                                    .Builder(this.GetTopActivity())
                                    .SetCancelable(false)
                                    .SetMessage(config.Message)
                                    .SetTitle(config.Title)
                                    .SetPositiveButton(config.OkText, (o, e) => config.OnOk?.Invoke())
                                    .ShowExt()
                                    );
        }
コード例 #22
0
        public override void Alert(AlertConfig config)
        {
            UIApplication.SharedApplication.InvokeOnMainThread(() => {
                if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) {
                    var alert = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => {
                        if (config.OnOk != null)
                            config.OnOk();
                    }));
                    this.Present(alert);
                }
                else {
                    var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, null, config.OkText);
                    if (config.OnOk != null)
                        dlg.Clicked += (s, e) => config.OnOk();

                    dlg.Show();
                }
            });
        }
コード例 #23
0
        public virtual Task AlertAsync(AlertConfig config, CancellationToken?cancelToken = null)
        {
            if (config.OnAction != null)
            {
                throw new ArgumentException(NO_ONACTION);
            }

            var tcs = new TaskCompletionSource <object>();

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

            var disp = this.Alert(config);

            cancelToken?.Register(() =>
            {
                disp.Dispose();
                tcs.TrySetCanceled();
            });

            return(tcs.Task);
        }
コード例 #24
0
        public override IDisposable Alert(AlertConfig config)
        {
            XButton positive = new XButton()
            {
                Text = config.OkText
            };
            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,
                Positive         = positive
            };

            dialog.OutsideClicked += (s, e) =>
            {
                dialog.Hide();
            };
            positive.Clicked += (s, e) =>
            {
                dialog.Hide();
                config.OnAction?.Invoke();
            };
            return(Show(dialog));
        }
コード例 #25
0
ファイル: UserDialogsImpl.cs プロジェクト: keozx/userdialogs
 public override void Alert(AlertConfig config)
 {
     var dialog = new MessageDialog(config.Message, config.Title);
     dialog.Commands.Add(new UICommand(config.OkText, x => config.OnOk?.Invoke()));
     this.Dispatch(() => dialog.ShowAsync());
 }
コード例 #26
0
ファイル: UserDialogsImpl.cs プロジェクト: umaqs/userdialogs
 public override IDisposable Alert(AlertConfig config) => this.Present(() =>
 {
     var alert = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert);
     alert.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnAction?.Invoke()));
     return(alert);
 });
コード例 #27
0
 public abstract IDisposable Alert(AlertConfig config);
コード例 #28
0
 public abstract void Alert(AlertConfig config);
コード例 #29
0
 public override IDisposable Alert(AlertConfig config)
 {
     throw new NotImplementedException();
 }
コード例 #30
0
        public LeaveAppFormAgentViewModel(INavigationService navigationService)
        {
            _navigationService = navigationService;

            QueryAgentListCommand = new DelegateCommand(async() =>
            {
                var fooProgressDialogConfig = new ProgressDialogConfig()
                {
                    MaskType = MaskType.Black,
                    Title    = "請稍後,正在查詢可用代理人清單..."
                };
                using (Acr.UserDialogs.UserDialogs.Instance.Progress(fooProgressDialogConfig))
                {
                    APIResult fooResult;
                    var fooQueryAgentRepository = new QueryAgentRepository();
                    string fooDep = DepartmentSelectedItem ?? "";
                    fooResult     = await fooQueryAgentRepository.Post(new LAFAgentQuery()
                    {
                        DepartmentName = fooDep,
                        Name           = UserName
                    });
                    if (fooResult.Success == false)
                    {
                        if (await MainHelper.CheckAccessToken(fooResult) == false)
                        {
                            return;
                        }

                        try
                        {
                            var fooAlertConfig = new AlertConfig()
                            {
                                Title   = "警告",
                                Message = $"查詢可用代理人清單發生了錯誤 {Environment.NewLine}{fooResult.Message}",
                                OkText  = "確定"
                            };
                            CancellationTokenSource fooCancelSrc = new CancellationTokenSource(10000);
                            await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(fooAlertConfig, fooCancelSrc.Token);
                        }
                        catch (OperationCanceledException)
                        {
                        }
                    }
                    else
                    {
                        QueryAgentListSource.Clear();
                        QueryAgentSelectedItem = null;
                        foreach (var item in fooQueryAgentRepository.Items)
                        {
                            QueryAgentListSource.Add(item);
                        }
                    }
                }
            });

            SelectAgentCommand = new DelegateCommand(async() =>
            {
                if (QueryAgentSelectedItem == null)
                {
                    var config = new Acr.UserDialogs.AlertConfig()
                    {
                        Title   = "警告",
                        Message = $"您尚未選取請假代理人",
                        OkText  = "確定",
                    };

                    await Acr.UserDialogs.UserDialogs.Instance.AlertAsync(config);
                }
                else
                {
                    LeaveAppFormItem.AgentId     = QueryAgentSelectedItem.MyUserId;
                    LeaveAppFormItem.AgentName   = QueryAgentSelectedItem.Name;
                    NavigationParameters fooPara = new NavigationParameters();
                    fooPara.Add(MainHelper.QueryUserAgent, LeaveAppFormItem.Clone());
                    await _navigationService.GoBackAsync(fooPara);
                }
            });
        }
コード例 #31
0
 public void Alert(string message)
 {
     var config = new AlertConfig() { Message = message, Title = "Alert", OkText = "Ok" };
     UserDialogs.Instance.Alert(config);
 }
コード例 #32
0
 public override IDisposable Alert(AlertConfig config)
 {
     throw new NotImplementedException ();
 }
コード例 #33
0
 public abstract void Alert(AlertConfig config);