コード例 #1
0
        public static void ShowView(this IBluescreenViewModel bluescreen)
        {
            var attribute = bluescreen.GetType().GetCustomAttribute <BluescreenViewAttribute>();

            if (attribute is null)
            {
                throw new InvalidOperationException("No BluescreenViewAttribute has been found");
            }
            var type = attribute.WindowType;

            void DispatcherWindowShow()
            {
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var window = (Window)Activator.CreateInstance(type, bluescreen);
                    window.ShowOnMonitor(Screen.PrimaryScreen);
                    window.Activate();
                    window.Focus();
                    window.Loaded += (sender, _) => (sender as Window)?.Focus();
                    foreach (var otherScreen in Screen.AllScreens.Where(s => !Equals(s, Screen.PrimaryScreen)))
                    {
                        var blackScreenWindow = new BlackWindow(window);
                        blackScreenWindow.ShowOnMonitor(otherScreen);
                    }
                    return(window);
                });
            }

            bluescreen.ExecuteCommand.Execute((Action)DispatcherWindowShow);
        }
コード例 #2
0
 /// <summary>
 /// 初始化BlackWindow的属性,事件等
 /// </summary>
 private void InitBlackWindow()
 {
     blackWindow = new BlackWindow();
     tpBlack.Controls.Add(blackWindow);
     if (loginInfo.b2b.lr.AuthorityOfFunction("004"))//黑屏权限004
     {
         blackWindow.KeyUp   += new KeyEventHandler(blackWindow_KeyUp);
         blackWindow.MouseUp += new MouseEventHandler(blackWindow_MouseUp);
     }
     else
     {
         blackWindow.ReadOnly = true;
     }
     AppendBlackWindow(string.Format("{0}注意:在字体设置建议使用英文字体,推荐使用Courier New字体\n使用中文字体可能会使字体紊乱!{1}\n", '\x1c', '\x1d'));
 }