Exemplo n.º 1
0
        /// <summary>
        /// 提示信息
        /// </summary>
        /// <param name="msg">信息</param>
        /// <param name="keepTime">彈窗顯示持續時間(毫秒)</param>
        public static void Info(string msg, int keepTime, Action callBack = null)
        {
            try
            {
                if (keepTime <= 0)
                {
                    return;
                }
                if (Application.Current == null || Application.Current.MainWindow == null)
                {
                    return;
                }

                if (Application.Current.Dispatcher.CheckAccess())
                {
                    if (Application.Current.MainWindow.WindowState == WindowState.Minimized)
                    {
                        return;
                    }
                    InkMessageBox box = new InkMessageBox()
                    {
                        Message = msg, KeepTime = keepTime, ToastBack = callBack
                    };
                    RoutedEventHandler loadHandler = null;
                    loadHandler = (sender, e) =>
                    {
                        Window win = sender as Window;
                        win.Loaded -= loadHandler;
                        IntPtr hwnd = new WindowInteropHelper(win).Handle;
                        if (hwnd != IntPtr.Zero)
                        {
                            NativeMethods.SetWindowLong(hwnd, NativeMethods.GwlExstyle, NativeMethods.WsExToolwindow);
                        }
                    };
                    box.Loaded += loadHandler;
                    var winformWindow = (HwndSource.FromDependencyObject(Application.Current.MainWindow) as HwndSource);
                    if (winformWindow != null)
                    {
                        new WindowInteropHelper(box)
                        {
                            Owner = winformWindow.Handle
                        }
                    }
                    ;
                    box.Show();
                }
                else
                {
                    Action <string, int, Action> func = Info;
                    Application.Current.Dispatcher.Invoke(func, msg, keepTime, callBack);
                }
            }
            catch (Exception ex)
            {
                //LogFactory.Log.Error("MessageBox Info Error", ex);
            }
        }
Exemplo n.º 2
0
        private void Callback(object state)
        {
            InkMessageBox box = state as InkMessageBox;

            if (box.Dispatcher.CheckAccess())
            {
                box.Close();
            }
            else
            {
                box.Dispatcher.Invoke(new Action(delegate
                {
                    box.Close();
                }), null);
            }
        }
Exemplo n.º 3
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.inkHintLayer = ((System.Windows.InkMessageBox)(target));
                return;

            case 2:
                this.delayShow = ((System.Windows.Media.Animation.Storyboard)(target));
                return;

            case 3:
                this.borderMain = ((System.Windows.Controls.Border)(target));
                return;

            case 4:
                this.lblMsg = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }
Exemplo n.º 4
0
 /// <summary>
 /// 提示信息
 /// </summary>
 /// <param name="msg">信息</param>
 /// <param name="width">彈窗寬度</param>
 /// <param name="height">彈窗高度</param>
 /// <param name="keepTime">彈窗顯示持續時間</param>
 public static void Info(string msg)
 {
     InkMessageBox.Info(msg, 3000);
 }