/// <summary> /// Displays information to the user. /// </summary> /// <param name="contentView">The custom view to be shown to the user.</param> /// <param name="title">The title of the dialog box. This may be null.</param> /// <param name="confirmButtonText">The text shown in the "confirm" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="neutralButtonText">The text shown in the "neutral" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="cancelButtonText">The text shown in the "cancel" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="canceledOnTouchOutside">Whether the dialog box is canceled when /// touched outside the window's bounds. </param> /// <param name="afterHideCallback">A callback that should be executed after /// the dialog box is closed by the user. The callback method will get a boolean /// parameter indicating if the "confirm" button (true) or the "cancel" button /// (false) was pressed by the user.</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage( IUIView contentView, string title, string confirmButtonText, string neutralButtonText, string cancelButtonText, bool canceledOnTouchOutside, Action <int> afterHideCallback) { AlertDialogViewModel viewModel = new AlertDialogViewModel(); viewModel.ContentView = contentView; viewModel.Title = title; viewModel.ConfirmButtonText = confirmButtonText; viewModel.NeutralButtonText = neutralButtonText; viewModel.CancelButtonText = cancelButtonText; viewModel.CanceledOnTouchOutside = canceledOnTouchOutside; viewModel.Click = afterHideCallback; viewModel.Closed = false; ApplicationContext context = Context.GetApplicationContext(); IUIViewLocator locator = context.GetService <IUIViewLocator>(); if (locator == null) { if (log.IsWarnEnabled) { log.Warn("Not found the \"IUIViewLocator\"."); } throw new NotFoundException("Not found the \"IUIViewLocator\"."); } AlertDialogWindow window = locator.LoadView <AlertDialogWindow>(ViewName); if (window == null) { if (log.IsWarnEnabled) { log.WarnFormat("Not found the \"{0}\".", typeof(AlertDialogWindow).Name); } throw new NotFoundException("Not found the \"AlertDialogWindow\"."); } AlertDialog dialog = new AlertDialog(window, viewModel); dialog.Show(); return(dialog); }
/// <summary> /// Displays information to the user. /// </summary> /// <param name="message">The message to be shown to the user.</param> /// <param name="title">The title of the dialog box. This may be null.</param> /// <param name="confirmButtonText">The text shown in the "confirm" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="neutralButtonText">The text shown in the "neutral" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="cancelButtonText">The text shown in the "cancel" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="canceledOnTouchOutside">Whether the dialog box is canceled when /// touched outside the window's bounds. </param> /// <param name="afterHideCallback">A callback that should be executed after /// the dialog box is closed by the user. The callback method will get a boolean /// parameter indicating if the "confirm" button (true) or the "cancel" button /// (false) was pressed by the user.</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage( string message, string title, string confirmButtonText, string neutralButtonText, string cancelButtonText, bool canceledOnTouchOutside, Action <int> afterHideCallback) { AlertDialogViewModel viewModel = new AlertDialogViewModel(); viewModel.Message = message; viewModel.Title = title; viewModel.ConfirmButtonText = confirmButtonText; viewModel.NeutralButtonText = neutralButtonText; viewModel.CancelButtonText = cancelButtonText; viewModel.CanceledOnTouchOutside = canceledOnTouchOutside; viewModel.Click = afterHideCallback; return(ShowMessage(ViewName, viewModel)); }
/// <summary> /// Displays information to the user. /// </summary> /// <param name="contentView">The custom content view to be shown to the user.</param> /// <param name="title">The title of the dialog box. This may be null.</param> /// <param name="confirmButtonText">The text shown in the "confirm" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="neutralButtonText">The text shown in the "neutral" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="cancelButtonText">The text shown in the "cancel" button /// in the dialog box. If left null, the button will be invisible.</param> /// <param name="canceledOnTouchOutside">Whether the dialog box is canceled when /// touched outside the window's bounds. </param> /// <param name="afterHideCallback">A callback that should be executed after /// the dialog box is closed by the user. The callback method will get a boolean /// parameter indicating if the "confirm" button (true) or the "cancel" button /// (false) was pressed by the user.</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage( IUIView contentView, string title, string confirmButtonText, string neutralButtonText, string cancelButtonText, bool canceledOnTouchOutside, Action <int> afterHideCallback) { AlertDialogViewModel viewModel = new AlertDialogViewModel(); viewModel.Title = title; viewModel.ConfirmButtonText = confirmButtonText; viewModel.NeutralButtonText = neutralButtonText; viewModel.CancelButtonText = cancelButtonText; viewModel.CanceledOnTouchOutside = canceledOnTouchOutside; viewModel.Click = afterHideCallback; IUIViewLocator locator = GetUIViewLocator(); AlertDialogWindow window = locator.LoadView <AlertDialogWindow>(ViewName); if (window == null) { if (log.IsWarnEnabled) { log.WarnFormat("Not found the dialog window named \"{0}\".", viewName); } throw new NotFoundException(string.Format("Not found the dialog window named \"{0}\".", viewName)); } AlertDialog dialog = new AlertDialog(window, contentView, viewModel); dialog.Show(); return(dialog); }
public AlertDialog(AlertDialogWindow window, IUIView contentView, AlertDialogViewModel viewModel) { this.window = window; this.contentView = contentView; this.viewModel = viewModel; }
public AlertDialog(AlertDialogWindow window, AlertDialogViewModel viewModel) : this(window, null, viewModel) { }
/// <summary> /// Displays information to the user. /// </summary> /// <param name="viewName">The view name of the dialog box,if it is null, use the default view name</param> /// <param name="contentViewName">The custom content view name to be shown to the user.</param> /// <param name="viewModel">The view model of the dialog box</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage(string viewName, string contentViewName, AlertDialogViewModel viewModel) { AlertDialogWindow window = null; IUIView contentView = null; try { ApplicationContext context = Context.GetApplicationContext(); IUIViewLocator locator = context.GetService <IUIViewLocator>(); if (locator == null) { if (log.IsWarnEnabled) { log.Warn("Not found the \"IUIViewLocator\"."); } throw new NotFoundException("Not found the \"IUIViewLocator\"."); } if (string.IsNullOrEmpty(viewName)) { viewName = ViewName; } window = locator.LoadView <AlertDialogWindow>(viewName); if (window == null) { if (log.IsWarnEnabled) { log.WarnFormat("Not found the dialog window named \"{0}\".", viewName); } throw new NotFoundException(string.Format("Not found the dialog window named \"{0}\".", viewName)); } if (!string.IsNullOrEmpty(contentViewName)) { contentView = locator.LoadView <IUIView>(contentViewName); } AlertDialog dialog = new AlertDialog(window, contentView, viewModel); dialog.Show(); return(dialog); } catch (Exception e) { if (window != null) { window.Dismiss(); } if (contentView != null) { GameObject.Destroy(contentView.Owner); } throw e; } }
/// <summary> /// Displays information to the user. /// </summary> /// <param name="viewName">The view name of the dialog box,if it is null, use the default view name</param> /// <param name="viewModel">The view model of the dialog box</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage(string viewName, AlertDialogViewModel viewModel) { return(ShowMessage(viewName, null, viewModel)); }
/// <summary> /// Displays information to the user. /// </summary> /// <param name="viewName">The view name of the dialog box,if it is null, use the default view name</param> /// <param name="contentViewName">The custom content view name to be shown to the user.</param> /// <param name="viewModel">The view model of the dialog box</param> /// <returns>A AlertDialog.</returns> public static AlertDialog ShowMessage(string viewName, string contentViewName, AlertDialogViewModel viewModel) { ApplicationContext context = Context.GetApplicationContext(); IUIViewLocator locator = context.GetService <IUIViewLocator>(); if (locator == null) { if (log.IsWarnEnabled) { log.Warn("Not found the \"IUIViewLocator\"."); } throw new NotFoundException("Not found the \"IUIViewLocator\"."); } if (string.IsNullOrEmpty(viewName)) { viewName = ViewName; } AlertDialogWindow window = locator.LoadView <AlertDialogWindow>(viewName); if (window == null) { if (log.IsWarnEnabled) { log.WarnFormat("Not found the \"{0}\".", typeof(AlertDialogWindow).Name); } throw new NotFoundException("Not found the \"AlertDialogWindow\"."); } IUIView contentView = null; if (!string.IsNullOrEmpty(contentViewName)) { contentView = locator.LoadView <IUIView>(contentViewName); } AlertDialog dialog = new AlertDialog(window, contentView, viewModel); dialog.Show(); return(dialog); }
public AlertDialog(AlertDialogWindow window, AlertDialogViewModel viewModel) { this.window = window; this.viewModel = viewModel; }