/// <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); }
public virtual Task AlertAsync(AlertConfig config) { var tcs = new TaskCompletionSource<object>(); config.OnOk = () => tcs.TrySetResult(null); this.Alert(config); return tcs.Task; }
public override void Alert(AlertConfig config) { var dlg = config.Title == null ? new MessageDialog(config.Message) : new MessageDialog(config.Message, config.Title); dlg.ShowAsync(); }
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; }); }
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 }
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() ); }
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); }
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); } }
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 }
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(); }); }
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); }
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)); }
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))); }
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() ); }
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)); }
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); }
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(); } }); }
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(); }); }
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() ); }
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; } }
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(); } }); }
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); }
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)); }
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()); }
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); });
public abstract IDisposable Alert(AlertConfig config);
public abstract void Alert(AlertConfig config);
public override IDisposable Alert(AlertConfig config) { throw new NotImplementedException(); }
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); } }); }
public void Alert(string message) { var config = new AlertConfig() { Message = message, Title = "Alert", OkText = "Ok" }; UserDialogs.Instance.Alert(config); }
public override IDisposable Alert(AlertConfig config) { throw new NotImplementedException (); }