Esempio n. 1
0
        private void OnShowOrHideLoading(object sender, InteractionEventArgs args)
        {
            VisibilityNotification notification = args.Context as VisibilityNotification;

            if (notification == null)
            {
                return;
            }

            if (notification.Visible)
            {
                this.list.Add(Loading.Show());
            }
            else
            {
                if (this.list.Count <= 0)
                {
                    return;
                }

                Loading loading = this.list[0];
                loading.Dispose();
                this.list.RemoveAt(0);
            }
        }
Esempio n. 2
0
        public InterationViewModel()
        {
            //创建一个交互请求,这个交互请求的作用就是向控制层(InteractionExample)发送一个打开对话窗的通知
            this.alertDialogRequest = new InteractionRequest <DialogNotification>(this);
            this.toastRequest       = new InteractionRequest <ToastNotification>(this);
            this.loadingRequest     = new InteractionRequest <VisibilityNotification>();

            //创建一个打响应按钮事件的命令
            this.openAlertDialog = new SimpleCommand(() =>
            {
                //设置命令的Enable为false,通过数据绑定解耦,间接将视图层按钮设置为不可点击状态
                this.openAlertDialog.Enabled = false;
                //创建一个对话框通知
                DialogNotification notification = new DialogNotification("Interation Example", "This is a dialog test.", "Yes", "No", true);
                //创建一个回调函数,此回调函数会在AlertDialog对话框关闭时调用
                Action <DialogNotification> callback = n =>
                {
                    //设置命令的Enable为true,通过绑定会自动恢复按钮的点击状态
                    this.openAlertDialog.Enabled = true;

                    if (n.DialogResult == AlertDialog.BUTTON_POSITIVE)
                    {
                        Debug.LogFormat("Click: Yes");
                    }
                    else if (n.DialogResult == AlertDialog.BUTTON_NEGATIVE)
                    {
                        Debug.LogFormat("Click: No");
                    }
                };
                //交互请求向View层OnOpenAlert函数发送通知
                this.alertDialogRequest.Raise(notification, callback);
            });

            this.showToast = new SimpleCommand(() =>
            {
                ToastNotification notification = new ToastNotification("This is a toast test.", 2f);
                this.toastRequest.Raise(notification);
            });

            this.showLoading = new SimpleCommand(() =>
            {
                VisibilityNotification notification = new VisibilityNotification(true);
                this.loadingRequest.Raise(notification);
            });

            this.hideLoading = new SimpleCommand(() =>
            {
                VisibilityNotification notification = new VisibilityNotification(false);
                this.loadingRequest.Raise(notification);
            });
        }
Esempio n. 3
0
        public InterationViewModel()
        {
            this.alertDialogRequest = new InteractionRequest <DialogNotification>(this);
            this.toastRequest       = new InteractionRequest <Notification>(this);
            this.loadingRequest     = new InteractionRequest <VisibilityNotification>();

            this.openAlertDialog = new SimpleCommand(() =>
            {
                this.openAlertDialog.Enabled = false;

                DialogNotification notification = new DialogNotification("Interation Example", "This is a dialog test.", "Yes", "No", true);

                Action <DialogNotification> callback = n =>
                {
                    this.openAlertDialog.Enabled = true;

                    if (n.DialogResult == AlertDialog.BUTTON_POSITIVE)
                    {
                        Debug.LogFormat("Click: Yes");
                    }
                    else if (n.DialogResult == AlertDialog.BUTTON_NEGATIVE)
                    {
                        Debug.LogFormat("Click: No");
                    }
                };

                this.alertDialogRequest.Raise(notification, callback);
            });

            this.showToast = new SimpleCommand(() =>
            {
                Notification notification = new Notification("This is a toast test.");
                this.toastRequest.Raise(notification);
            });

            this.showLoading = new SimpleCommand(() =>
            {
                VisibilityNotification notification = new VisibilityNotification(true);
                this.loadingRequest.Raise(notification);
            });

            this.hideLoading = new SimpleCommand(() =>
            {
                VisibilityNotification notification = new VisibilityNotification(false);
                this.loadingRequest.Raise(notification);
            });
        }