• WPF使用扩展屏幕


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Forms;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace ScreenShadow
    {
        /// <summary>
        /// MainWindow.xaml 的交互逻辑
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                Window1 window = new Window1();
                window.Show();
            }
    
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                Window2 window = new Window2();
                window.Show();
            }
            List<Window> openWindows = new List<Window>();
            private void Button_Click_2(object sender, RoutedEventArgs e)
            {
                openWindows.Clear();
                Screen[] screens = Screen.AllScreens;
                if (screens.Length == 1)
                {
                    lblmsg.Content = "已经投射1个显示器";
                }
                else if (screens.Length == 2)
                {
                    lblmsg.Content = "已经投射2个显示器";
                }
                else if (screens.Length == 4)
                {
                    lblmsg.Content = "已经投射4个显示器";
                }
                else {
                    lblmsg.Content = "目前仅支持1,2,4个显示器模式";
                }
    
                //主屏幕显示
                Screen mainScreen = screens.FirstOrDefault(x=>x.Primary==true);
                //主屏幕显示window1
                Window1 win1 = new Window1();
                win1.WindowState = WindowState.Maximized;
                win1.WindowStartupLocation = WindowStartupLocation.Manual;
                System.Drawing.Rectangle mswa = mainScreen.WorkingArea;
                win1.Left = mswa.Left;
                win1.Top = mswa.Top;
                win1.Width = mswa.Width;
                win1.Height = mswa.Height;
                openWindows.Add(win1);
                win1.Show();
    
                //其他屏幕显示,这里假设有2个
                var subScreen = (from o in screens where o.Primary == false select o).ToList<Screen>();
                if (subScreen.Count > 0) {
                    var subscreen1 = subScreen[0];
                    Window2 win2 = new Window2();
                    win1.WindowState = WindowState.Maximized;
                    win1.WindowStartupLocation = WindowStartupLocation.Manual;
                    System.Drawing.Rectangle mswa2 = subscreen1.WorkingArea;
                    win2.Left = mswa2.Left;
                    win2.Top = mswa2.Top;
                    win2.Width = mswa2.Width;
                    win2.Height = mswa2.Height;
                    openWindows.Add(win2);
                    win2.Show();
                }
               
    
               
            }
    
            private void BtnClose_Click(object sender, RoutedEventArgs e)
            {
                if (openWindows.Count > 0) {
                    foreach (var item in openWindows)
                    {
                        item.Close();
                    }
                }
            }
    
        }
    }
    View Code
  • 相关阅读:
    在通达信里制作自己的指数
    Android Studio实现代码混淆
    python 安装anaconda, numpy, pandas, matplotlib 等
    阿里云服务(一) OSS
    阿里云存储OSS之九大使用技巧
    用云存储和CDN轻松搞定网站图片
    阿里云开放服务oss的api
    'htmlentities(): charset `utf8' not supported, assuming utf-8'
    TP自动生成模块目录
    TP框架中APP_SUB_DOMAIN_DEPLOY什么意思?
  • 原文地址:https://www.cnblogs.com/fuchongjundream/p/4206259.html
Copyright © 2020-2023  润新知