/// <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;
            }
        }
Exemplo n.º 2
0
    public static DrawDialog ShowDrawDialog(int countDown, Action <int> afterHideCallback)
    {
        DrawDialogViewModel viewModel = new DrawDialogViewModel(countDown, afterHideCallback);
        ///viewModel.DrawCount = 20;

        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\".");
        }
        DrawDialogWindow window = locator.LoadView <DrawDialogWindow>(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));
        }
        DrawDialog drawDialog = new DrawDialog(window, viewModel);

        drawDialog.Show();
        return(drawDialog);
    }
Exemplo n.º 3
0
        public static Toast Show(string viewName, IUIViewGroup viewGroup, string text, float duration, UILayout layout, Action callback)
        {
            if (string.IsNullOrEmpty(viewName))
            {
                viewName = ViewName;
            }

            IUIViewLocator locator = GetUIViewLocator();
            ToastView      view    = locator.LoadView <ToastView>(viewName);

            if (view == null)
            {
                throw new NotFoundException("Not found the \"ToastView\".");
            }

            if (viewGroup == null)
            {
                viewGroup = GetCurrentViewGroup();
            }

            Toast toast = new Toast(view, viewGroup, text, duration, layout, callback);

            toast.Show();
            return(toast);
        }
Exemplo n.º 4
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);
        }
        public override void Action(object viewModel, Action callback)
        {
            Window window = null;

            try
            {
                ApplicationContext context = Context.GetApplicationContext();
                IUIViewLocator     locator = context.GetService <IUIViewLocator>();
                if (locator == null)
                {
                    throw new NotFoundException("Not found the \"IUIViewLocator\".");
                }

                if (string.IsNullOrEmpty(viewName))
                {
                    throw new ArgumentNullException("The view name is null.");
                }

                window = locator.LoadView <Window>(viewName);
                if (window == null)
                {
                    throw new NotFoundException(string.Format("Not found the dialog window named \"{0}\".", viewName));
                }

                if (window is AlertDialogWindow && viewModel is AlertDialogViewModel)
                {
                    (window as AlertDialogWindow).ViewModel = viewModel as AlertDialogViewModel;
                }
                else
                {
                    window.SetDataContext(viewModel);
                }

                EventHandler handler = null;
                handler = (sender, eventArgs) =>
                {
                    window.OnDismissed -= handler;
                };
                window.Create();
                window.OnDismissed += handler;
                window.Show(true);
            }
            catch (Exception e)
            {
                if (window != null)
                {
                    window.Dismiss();
                }

                if (log.IsWarnEnabled)
                {
                    log.Error("", e);
                }
            }
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public static Toast Show(string viewName, IUIViewGroup viewGroup, string text, float duration, UILayout layout, Action callback)
        {
            if (string.IsNullOrEmpty(viewName))
            {
                viewName = ViewName;
            }

            ApplicationContext context = Context.GetApplicationContext();
            IUIViewLocator     locator = context.GetService <IUIViewLocator>();
            ToastView          view    = locator.LoadView <ToastView>(viewName);
            Toast toast = new Toast(viewGroup, text, duration, layout);

            toast.View = view;
            toast.Show();
            return(toast);
        }
Exemplo n.º 8
0
    public void LoadSystemLanguage()
    {
        var languageGroup = this.variables.Get <RectTransform>("language_group");
        List <SystemLanguage> languageList = this.viewModel.GetSystemLanguages();

        for (int i = 0; i < languageList.Count; i++)
        {
            LanguageElementView      languageElementView = viewLocator.LoadView <LanguageElementView>("UI/language_element");
            LanguageElementViewModel viewModel           = new LanguageElementViewModel()
            {
                Language = languageList[i],
                Label    = languageList[i].ToString(),
            };
            languageElementView.SetDataContext(viewModel);
            languageElementView.Visibility = true;
            languageElementView.transform.SetParent(languageGroup);
        }
    }
Exemplo n.º 9
0
        public static Toast Show(string viewName, IUIViewGroup viewGroup, string text, float duration, UILayout layout, Action callback)
        {
            if (string.IsNullOrEmpty(viewName))
            {
                viewName = ViewName;
            }

            ApplicationContext context = Context.GetApplicationContext();
            IUIViewLocator     locator = context.GetService <IUIViewLocator>();
            ToastView          view    = locator.LoadView <ToastView>(viewName);

            if (view == null)
            {
                throw new NotFoundException("Not found the \"ToastView\".");
            }

            Toast toast = new Toast(view, viewGroup, text, duration, layout);

            toast.Show();
            return(toast);
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        public virtual IAsyncResult <TViewModel> ShowDialog <TViewModel>(string viewName, TViewModel viewModel)
        {
            AsyncResult <TViewModel> result = new AsyncResult <TViewModel>();
            Window window = 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))
                {
                    throw new ArgumentNullException("The view name is null.");
                }

                window = locator.LoadView <Window>(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 (window is AlertDialogWindow && viewModel is AlertDialogViewModel)
                {
                    (window as AlertDialogWindow).ViewModel = viewModel as AlertDialogViewModel;
                }
                else
                {
                    window.SetDataContext(viewModel);
                }

                EventHandler handler = null;
                handler = (sender, eventArgs) =>
                {
                    window.OnDismissed -= handler;
                    result.SetResult(viewModel);
                };
                window.Create();
                window.OnDismissed += handler;
                window.Show(true);
            }
            catch (Exception e)
            {
                result.SetException(e);
                if (window != null)
                {
                    window.Dismiss();
                }
            }
            return(result);
        }