コード例 #1
0
        public static bool?ShowDialogEx(this Window window)
        {
            bool?result;

            if (window.Owner == null)
            {
                var owner = WpfUtil.GetTopWindow();
                if (owner != window)
                {
                    window.Owner = owner;
                }
            }
            if (window.Owner != null)
            {
                if (window.Owner is IMaskWindow maskWindow)
                {
                    maskWindow.ShowMask();
                    result = window.ShowDialog();
                    maskWindow.HideMask();
                }
                else
                {
                    double ownerOpacity = window.Owner.Opacity;
                    window.Owner.Opacity = 0.6;
                    result = window.ShowDialog();
                    window.Owner.Opacity = ownerOpacity;
                }
            }
            else
            {
                result = window.ShowDialog();
            }
            return(result);
        }
コード例 #2
0
ファイル: WindowExtension.cs プロジェクト: suifengtec/NtMiner
 private static void ShowDialog(Window window, bool useSoftDialog)
 {
     if (window.Owner == null)
     {
         var owner = WpfUtil.GetTopWindow();
         if (owner != null && owner != window && owner.GetType() != typeof(NotiCenterWindow))
         {
             window.Owner = owner;
         }
     }
     if (window.Owner != null)
     {
         // 因为挖矿端主界面是透明的,遮罩方法和普通窗口不同,如果按照通用的方法遮罩的话会导致能透过窗口看见windows桌面或者下面的窗口。
         if (window.Owner is IMaskWindow maskWindow)
         {
             maskWindow.ShowMask();
             window.Owner.IsEnabled = false;
             window.Closing        += (sender, e) => {
                 maskWindow.HideMask();
                 window.Owner.IsEnabled = true;
             };
         }
         else
         {
             double ownerOpacity = window.Owner.Opacity;
             window.Owner.Opacity   = 0.6;
             window.Owner.IsEnabled = false;
             window.Closing        += (sender, e) => {
                 window.Owner.Opacity   = ownerOpacity;
                 window.Owner.IsEnabled = true;
             };
         }
         window.Closed += (sender, e) => {
             window.Owner.Activate();
         };
     }
     if (useSoftDialog)
     {
         window.Show();
     }
     else
     {
         window.ShowDialog();
     }
 }