Exemple #1
0
        /// <summary>
        /// 全局异常处理
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="notify"></param>
        /// <returns></returns>
        public static void Error(Exception ex, Notify notify = Notify.Error)
        {
            string Icon  = string.Empty;
            string Color = string.Empty;
            bool   Hide  = true;

            switch (notify)
            {
            case Notify.Error:
                Icon  = "\xe676";
                Color = "#FF4500";
                break;

            case Notify.Warning:
                Icon  = "\xe623";
                Color = "#FF8247";
                break;

            case Notify.Info:
                Icon  = "\xe764";
                Color = "#1C86EE";
                break;

            default:
                Icon  = "\xe676";
                Color = "#FF4500";
                break;
            }
            MsgHostBoxViewModel msgBox = new MsgHostBoxViewModel();
            var    dialog = ServiceProvider.Instance.Get <IModelDialog>("MsgHostBoxViewDlg");
            string msg    = ExceptionLibrary.GetErrorMsgByExpId(ex);

            dialog.BindViewModel(new MsgHostBoxViewModel()
            {
                Msg     = msg,
                Icon    = Icon,
                Color   = Color,
                BtnHide = Hide
            });
            dialog.ShowDialog(null, msgBox.ExtendedClosingEventHandler);
        }
Exemple #2
0
        /// <summary>
        /// 弹出窗口
        /// </summary>
        /// <param name="notify">类型</param>
        /// <param name="msg">文本信息</param>
        /// <returns></returns>
        private static async Task <bool> Show(Notify notify, string msg, bool Host = true)
        {
            string Icon  = string.Empty;
            string Color = string.Empty;
            bool   Hide  = true;

            switch (notify)
            {
            case Notify.Error:
                Icon  = "\xe676";
                Color = "#FF4500";
                break;

            case Notify.Warning:
                Icon  = "\xe623";
                Color = "#FF8247";
                break;

            case Notify.Info:
                Icon  = "\xe764";
                Color = "#1C86EE";
                break;

            case Notify.Question:
                Icon  = "\xe6bd";
                Color = "#20B2AA";
                Hide  = false;
                break;
            }

            if (Host)
            {
                MsgHostBoxViewModel msgBox = new MsgHostBoxViewModel();
                var dialog = ServiceProvider.Instance.Get <IModelDialog>("MsgHostBoxViewDlg");
                dialog.BindViewModel(new MsgHostBoxViewModel()
                {
                    Msg = msg, Icon = Icon, Color = Color, BtnHide = Hide
                });
                var TaskResult = await dialog.ShowDialog(null, msgBox.ExtendedClosingEventHandler);

                if (TaskResult)
                {
                    return(true);
                }
                return(false);
            }
            else
            {
                MsgBoxViewModel msgBox = new MsgBoxViewModel();
                var             dialog = ServiceProvider.Instance.Get <IModelDialog>("MsgBoxViewDlg");
                dialog.BindViewModel(new MsgBoxViewModel()
                {
                    Msg = msg, Icon = Icon, Color = Color, BtnHide = Hide
                });
                var TaskResult = await dialog.ShowDialog();

                if (TaskResult)
                {
                    return(true);
                }
                return(false);
            }
        }