/// <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;
            }
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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)
 {
 }
예제 #7
0
 public AlertDialog(AlertDialogWindow window, AlertDialogViewModel viewModel)
 {
     this.window    = window;
     this.viewModel = viewModel;
 }