Exemplo n.º 1
0
    protected void OnOpenWheelWindow(object sender, InteractionEventArgs args)
    {
        try
        {
            IUIViewLocator viewLocator = Context.GetApplicationContext().GetService <IUIViewLocator>();
            WheelWindow    window      = viewLocator.LoadWindow <WheelWindow>(this.WindowManager, "UI/Wheel");
            //var callback = args.Callback;
            var model = args.Context;

            //if (callback != null)
            //{
            //    EventHandler handler = null;
            //    handler = (window, e) =>
            //    {
            //        cardBagWindow.OnDismissed -= handler;
            //        if (callback != null)
            //            callback();
            //    };
            //    cardBagWindow.OnDismissed += handler;
            //}

            window.SetDataContext(model);
            window.Create();
            window.Show();
        }
        catch (Exception e)
        {
            if (log.IsWarnEnabled)
            {
                log.Warn(e);
            }
        }
    }
Exemplo n.º 2
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.º 3
0
        protected override void OnCreate(IBundle bundle)
        {
            this.viewLocator = Context.GetApplicationContext().GetService <IUIViewLocator>();
            this.viewModel   = new StartupViewModel();

            //this.subscription = this.viewModel.Messenger.Subscribe ();

            //this.SetDataContext (viewModel);

            /* databinding, Bound to the ViewModel. */
            BindingSet <StartupWindow, StartupViewModel> bindingSet = this.CreateBindingSet(viewModel);

            bindingSet.Bind().For(v => v.OnOpenLoginWindow).To(vm => vm.LoginRequest);
            bindingSet.Bind().For(v => v.OnDismissRequest).To(vm => vm.DismissRequest);

            bindingSet.Bind(this.progressBarSlider).For("value", "onValueChanged").To("ProgressBar.Progress").TwoWay();
            //bindingSet.Bind (this.progressBarSlider).For (v => v.value, v => v.onValueChanged).To (vm => vm.ProgressBar.Progress).TwoWay ();

            /* //by the way,You can expand your attributes.
             *          ProxyFactory proxyFactory = ProxyFactory.Default;
             *          PropertyInfo info = typeof(GameObject).GetProperty ("activeSelf");
             *          proxyFactory.Register (new ProxyPropertyInfo<GameObject, bool> (info, go => go.activeSelf, (go, value) => go.SetActive (value)));
             */

            bindingSet.Bind(this.progressBarSlider.gameObject).For(v => v.activeSelf).To(vm => vm.ProgressBar.Enable).OneWay();
            bindingSet.Bind(this.progressBarText).For(v => v.text).ToExpression(vm => string.Format("{0}%", Mathf.FloorToInt(vm.ProgressBar.Progress * 100f))).OneWay();/* expression binding,support only OneWay mode. */
            bindingSet.Bind(this.tipText).For(v => v.text).To(vm => vm.ProgressBar.Tip).OneWay();

            //bindingSet.Bind(this.button).For(v => v.onClick).To(vm=>vm.OnClick()).OneWay(); //Method binding,only bound to the onClick event.
            bindingSet.Bind(this.button).For(v => v.onClick).To(vm => vm.Click).OneWay();//Command binding,bound to the onClick event and interactable property.
            bindingSet.Build();

            this.viewModel.Unzip();
        }
Exemplo n.º 4
0
        IEnumerator Start()
        {
            /* Create a window container */
            WindowContainer winContainer = WindowContainer.Create("MAIN");

            yield return(null);

            IUIViewLocator locator = Context.GetApplicationContext().GetService <IUIViewLocator>();
            StartupWindow  window  = locator.LoadWindow <StartupWindow>(winContainer, "UI/Startup.prefab");

            window.Create();
            ITransition transition = window.Show().OnStateChanged((w, state) =>
            {
                //log.DebugFormat("Window:{0} State{1}",w.Name,state);
            });

            yield return(transition.WaitForDone());


            //ApplicationContext context = ApplicationContext.GetApplicationContext();
            //ISession session = context.GetService<ISession>();
            //session.Send(10001, -1, new Login() { DriveId = "default" });

            //ApplicationContext context = Context.GetApplicationContext();
            //ISession session = context.GetService<ISession>();
            //session.Connect("127.0.0.1", 10001);
        }
Exemplo n.º 5
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);
    }
        /// <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.º 7
0
    protected void OnOpenRewardWindow(object sender, InteractionEventArgs args)
    {
        var            cardBagViewModel = args.Context;
        IUIViewLocator viewLocator      = Context.GetApplicationContext().GetService <IUIViewLocator>();
        RewardWindow   rewardWindow     = viewLocator.LoadWindow <RewardWindow>(this.WindowManager, "UI/Reward");

        rewardWindow.SetDataContext(cardBagViewModel);
        rewardWindow.Create();
        rewardWindow.Show();
    }
Exemplo n.º 8
0
    protected void OnOpenCardBagWindow(object sender, InteractionEventArgs args)
    {
        IUIViewLocator viewLocator    = Context.GetApplicationContext().GetService <IUIViewLocator>();
        CardTurnWindow cardDrawWindow = viewLocator.LoadWindow <CardTurnWindow>(this.WindowManager, "UI/CardTurn");
        var            cardDrawModel  = args.Context;

        cardDrawWindow.SetDataContext(cardDrawModel);
        cardDrawWindow.Create();
        cardDrawWindow.Show();
    }
        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.º 10
0
        private void AddAllWindows(WindowContainer windowContainer, IUIViewLocator locator)
        {
            windowManager = FindObjectOfType <GlobalWindowManager>();
            if (windowManager == null)
            {
                Debug.Log("没有找到GlobalWindowManager");
            }

            //添加场景中所需要的window
            windowManager.Add(locator.LoadWindow <StartWindow>(windowContainer, "Prefabs/UI/StartWindow"));
        }
Exemplo n.º 11
0
        protected override void OnCreate(IBundle bundle)
        {
            this.viewLocator    = Context.GetApplicationContext().GetService <IUIViewLocator>();
            this.startViewModel = new StartViewModel();

            BindingSet <StartWindow, StartViewModel> bindingSet = this.CreateBindingSet(startViewModel);

            bindingSet.Bind(this.startButton).For(v => v.onClick).To(vm => vm.StartCommand).OneWay();
            bindingSet.Bind(this.quitButton).For(v => v.onClick).To(vm => vm.CancelCommand).OneWay();
            bindingSet.Bind().For(v => v.StartGame).To(vm => vm.StartInteractionRequest);

            bindingSet.Build();
        }
Exemplo n.º 12
0
        // Start is called before the first frame update
        void Start()
        {
            WindowContainer windowContainer = WindowContainer.Create("MAIN");

            IUIViewLocator locator = applicationContext.GetService <IUIViewLocator>();

            AddAllWindows(windowContainer, locator);

            GameMainWindow startWindow = windowManager.Find <GameMainWindow>();

            startWindow.Create();
            startWindow.Show();
        }
Exemplo n.º 13
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.º 14
0
 protected Loading(bool ignoreAnimation)
 {
     this.ignoreAnimation = ignoreAnimation;
     lock (_lock)
     {
         if (refCount <= 0)
         {
             IUIViewLocator locator = GetUIViewLocator();
             window = locator.LoadWindow <LoadingWindow>(ViewName);
             window.Create();
             window.Show(this.ignoreAnimation);
         }
         refCount++;
     }
 }
Exemplo n.º 15
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.º 16
0
 protected Loading(bool ignoreAnimation)
 {
     this.ignoreAnimation = ignoreAnimation;
     lock (_lock)
     {
         if (refCount <= 0)
         {
             ApplicationContext context = Context.GetApplicationContext();
             IUIViewLocator     locator = context.GetService <IUIViewLocator>();
             window = locator.LoadWindow <LoadingWindow>(ViewName);
             window.Create();
             window.Show(this.ignoreAnimation);
         }
         refCount++;
     }
 }
Exemplo n.º 17
0
    protected override void OnCreate(IBundle bundle)
    {
        viewLocator    = Context.GetApplicationContext().GetService <IUIViewLocator>();
        this.viewModel = new SelectLanguageViewModel();

        BindingSet <SelectLanguageView, SelectLanguageViewModel> bindingSet = this.CreateBindingSet(viewModel);

        // binding interaction request
        bindingSet.Bind().For(v => v.OnClosePopup).To(vm => vm.ClosePopupRequest);

        // binding command
        bindingSet.Bind(this.variables.Get <Button>("btn_close")).For(v => v.onClick).To(vm => vm.ClosePopupCommand);
        bindingSet.Build();

        LoadSystemLanguage();
    }
Exemplo n.º 18
0
    private void Start()
    {
        /* Create a window container */
        WindowContainer winContainer = WindowContainer.Create("main");

        IUIViewLocator  locator = context.GetService <IUIViewLocator>();
        LoadingGameView window  = locator.LoadWindow <LoadingGameView>(winContainer, "UI/popup_loading");

        window.Create();
        window.Show();

        for (int i = 0; i < listPopup.Length; i++)
        {
            SmartPool.Instance.Preload(listPopup[i], 1);
        }
    }
Exemplo n.º 19
0
        IEnumerator Start()
        {
            /* Create a window container */
            WindowContainer winContainer = WindowContainer.Create("MAIN");

            yield return(null);

            IUIViewLocator locator = context.GetService <IUIViewLocator>();
            StartupWindow  window  = locator.LoadWindow <StartupWindow>(winContainer, "UI/Startup/Startup");

            window.Create();
            ITransition transition = window.Show().OnStateChanged((w, state) =>
            {
                //log.DebugFormat("Window:{0} State{1}",w.Name,state);
            });

            yield return(transition.WaitForDone());
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
    protected override void OnCreate(IBundle bundle)
    {
        viewLocator    = Context.GetApplicationContext().GetService <IUIViewLocator>();
        this.viewModel = new LoadingGameViewModel();

        BindingSet <LoadingGameView, LoadingGameViewModel> bindingSet = this.CreateBindingSet(viewModel);

        // binding interaction request
        bindingSet.Bind().For(v => v.OnOpenPopupSelectLanguage).To(vm => vm.SelectLanguageRequest);
        bindingSet.Bind().For(v => v.OnTapToStart).To(vm => vm.TapToStartRequest);

        // binding command
        bindingSet.Bind(this.variables.Get <Button>("select_language")).For(v => v.onClick).To(vm => vm.SelectLanguageCommand);
        bindingSet.Bind(this.variables.Get <Button>("tap_to_start")).For(v => v.onClick).To(vm => vm.TapToStartCommand);
        bindingSet.Build();


        SmartPool.Instance.Spawn(this.variables.Get <GameObject>("loading_game"), Vector3.zero, Quaternion.identity);
    }
Exemplo n.º 22
0
        IEnumerator Start()
        {
            /* Create a window container */
            //创建一个窗口容器,默认会在全局窗口管理器中创建
            WindowContainer winContainer = WindowContainer.Create("MAIN");

            yield return(null);

            IUIViewLocator locator = context.GetService <IUIViewLocator>();
            StartupWindow  window  = locator.LoadWindow <StartupWindow>(winContainer, "UI/Startup/Startup");

            window.Create();
            //返回一个transition对象,窗口显示一般会有窗口动画,所以是一个持续过程的操作
            ITransition transition = window.Show().OnStateChanged((w, state) =>
            {
                //log.DebugFormat("Window:{0} State{1}",w.Name,state);
            });

            yield return(transition.WaitForDone());
        }
Exemplo n.º 23
0
    protected void OnOpenIdleWindow(object sender, InteractionEventArgs args)
    {
        IUIViewLocator viewLocator = Context.GetApplicationContext().GetService <IUIViewLocator>();

        //WheelWindow wheelWindow = viewLocator.LoadWindow<WheelWindow>(this.WindowManager, "UI/Wheel");
        //var wheelViewModel = args.Context;
        //wheelWindow.SetDataContext(wheelViewModel);
        //wheelWindow.Create();
        //wheelWindow.Show();

        //CardDrawWindow cardDrawWindow = viewLocator.LoadWindow<CardDrawWindow>(this.WindowManager, "UI/CardDraw");
        //var cardDrawModel = args.Context;
        //cardDrawWindow.SetDataContext(cardDrawModel);
        //cardDrawWindow.Create();
        //cardDrawWindow.Show();

        IdleWindow idleWindow = viewLocator.LoadWindow <IdleWindow>(this.WindowManager, "UI/Idle");

        idleWindow.Create();
        idleWindow.Show();
    }
Exemplo n.º 24
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.º 25
0
        private static IUIViewLocator GetUIViewLocator()
        {
            ApplicationContext context = Context.GetApplicationContext();
            IUIViewLocator     locator = context.GetService <IUIViewLocator>();

            if (locator == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.Warn("Not found the \"IUIViewLocator\" in the ApplicationContext.Try loading the AlertDialog using the DefaultUIViewLocator.");
                }

                locator = context.GetService <IUIViewLocator>(DEFAULT_VIEW_LOCATOR_KEY);
                if (locator == null)
                {
                    locator = new DefaultUIViewLocator();
                    context.GetContainer().Register(DEFAULT_VIEW_LOCATOR_KEY, locator);
                }
            }
            return(locator);
        }
Exemplo n.º 26
0
    protected void OnOpenCardBagWindow(object sender, InteractionEventArgs args)
    {
        try
        {
            IUIViewLocator viewLocator   = Context.GetApplicationContext().GetService <IUIViewLocator>();
            CardBagWindow  cardBagWindow = viewLocator.LoadWindow <CardBagWindow>(this.WindowManager, "UI/CardBag");
            var            cardBagModel  = args.Context;


            cardBagWindow.SetDataContext(cardBagModel);
            cardBagWindow.Create();
            cardBagWindow.Show();
        }
        catch (Exception e)
        {
            if (log.IsWarnEnabled)
            {
                log.Warn(e);
            }
        }
    }
Exemplo n.º 27
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.º 28
0
 public VMCreator(IUIViewLocator viewLocator)
 {
     SetViewLocator(viewLocator);
 }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
0
 public void SetViewLocator(IUIViewLocator viewLocator)
 {
     _viewLocator = viewLocator;
 }