public Message(string content, MessageBoxMode mode) { Content = content; MessageBoxMode = mode; }
/// <summary> /// 显示 /// </summary> /// <param name="title"></param> /// <param name="content"></param> /// <param name="mode"></param> /// <param name="imageMode"></param> /// <param name="buttonMode"></param> /// <param name="Command"></param> internal void Show(string title, string content, MessageBoxMode mode, MessageBoxImageMode imageMode, MessageBoxButtonMode buttonMode, Action <string> Command, object args) { this.Command = Command; this.Mode = (int)mode; this.ImageMode = (int)imageMode; this.ButtonMode = (int)buttonMode; this.Title = title; this.Content = content; IsDisplay = true; if (buttonMode == MessageBoxButtonMode.YesNo) { Device.BeginInvokeOnMainThread(async() => { var answer = await App.Current.MainPage.DisplayAlert(this.Title, this.Content, CommandTitles.Instance.Yes, CommandTitles.Instance.No); if (null != Command) { if (answer) { this.OKCommand.Execute("YES"); } else { this.OKCommand.Execute("NO"); } } else { ExecuteCommand(null); } }); } else if (buttonMode == MessageBoxButtonMode.CustomMultiple) { Device.BeginInvokeOnMainThread(async() => { Dictionary <string, string> objList = args as Dictionary <string, string>; string answer = ""; if (objList.Count == 1) { answer = await App.Current.MainPage.DisplayActionSheet(this.Content, CommandTitles.Instance.Cancel, null, objList.ElementAt(0).Key); } else if (objList.Count == 2) { answer = await App.Current.MainPage.DisplayActionSheet(this.Content, CommandTitles.Instance.Cancel, null, objList.ElementAt(0).Key, objList.ElementAt(1).Key); } else if (objList.Count == 3) { answer = await App.Current.MainPage.DisplayActionSheet(this.Content, CommandTitles.Instance.Cancel, null, objList.ElementAt(0).Key, objList.ElementAt(1).Key, objList.ElementAt(2).Key); } else if (objList.Count == 4) { answer = await App.Current.MainPage.DisplayActionSheet(this.Content, CommandTitles.Instance.Cancel, null, objList.ElementAt(0).Key, objList.ElementAt(1).Key, objList.ElementAt(2).Key, objList.ElementAt(3).Key); } else if (objList.Count == 5) { answer = await App.Current.MainPage.DisplayActionSheet(this.Content, CommandTitles.Instance.Cancel, null, objList.ElementAt(0).Key, objList.ElementAt(1).Key, objList.ElementAt(2).Key, objList.ElementAt(3).Key, objList.ElementAt(4).Key); } if (null != Command && !string.IsNullOrWhiteSpace(answer) && objList.ContainsKey(answer)) { this.OKCommand.Execute(objList[answer]); } else { ExecuteCommand(null); } }); } else if (buttonMode == MessageBoxButtonMode.RetryExit) { Device.BeginInvokeOnMainThread(async() => { var answer = await App.Current.MainPage.DisplayAlert(this.Title, this.Content, CommandTitles.Instance.Retry, CommandTitles.Instance.Exit); if (null != Command) { if (answer) { this.OKCommand.Execute("Retry"); } else { this.OKCommand.Execute("Exit"); } } else { ExecuteCommand(null); } }); } else if (buttonMode == MessageBoxButtonMode.OK) { Device.BeginInvokeOnMainThread(async() => { await App.Current.MainPage.DisplayAlert(this.Title, this.Content, CommandTitles.Instance.OK); if (null != Command) { this.OKCommand.Execute("OK"); } else { ExecuteCommand(null); } if (OperatesService.Instance.IsExpired || OperatesService.Instance.IsAdminUsing) { MainViewModel viewModel = NavigationPath.Instance.CurrentNavigate.BindingContext as MainViewModel; if (null != viewModel) { viewModel.ReLyout(); } } }); } }
public void ShowMessage(MessageBoxMode mode, string text, params object[] args) { ShowMessage(mode, string.Format(text, args)); }
/// <summary> /// 注册 /// </summary> /// <param name="sender"></param> /// <param name="page"></param> /// <param name="title"></param> /// <param name="content"></param> /// <param name="mode"></param> /// <param name="imageMode"></param> /// <param name="buttonMode"></param> /// <param name="command"></param> /// <param name="args"></param> internal void Instance_NotificationMessageBox(object sender, object page, string title, string content, MessageBoxMode mode, MessageBoxImageMode imageMode, MessageBoxButtonMode buttonMode, Action <string> command, object args) { bool isCurrentPage = false; lock (NavigationPath.Instance) { if (_element == NavigationPath.Instance.CurrentNavigate) { isCurrentPage = true; } } if (isCurrentPage) { Show(title, content, mode, imageMode, buttonMode, command, args); } }
public void ShowMessage(MessageBoxMode mode, string text) { this.mode = mode; this.text = text; this.show = true; }