博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WPF使用扩展屏幕
阅读量:6266 次
发布时间:2019-06-22

本文共 3123 字,大约阅读时间需要 10 分钟。

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{    ///     /// MainWindow.xaml 的交互逻辑    ///     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
openWindows = new List
(); 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
(); 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

 

转载地址:http://fwdpa.baihongyu.com/

你可能感兴趣的文章
linux建立用户 详细
查看>>
jquery获取radio的值
查看>>
创建索引
查看>>
jQuery基础-创建HTML
查看>>
spring boot 热部署
查看>>
NYOJ-214 单调递增子序列(二) AC 分类: NYOJ ...
查看>>
[HDU 4417]Super Mario
查看>>
clip-path的妙用
查看>>
在FMOD中使用customRollOff实现更自然的声音衰减
查看>>
java日常-map转成json
查看>>
动画view
查看>>
自己写个多任务多线程断点下载框架
查看>>
Css 按钮
查看>>
Silverlight显示WCF详细异常信息
查看>>
BZOJ5299:[CQOI2018]解锁屏幕(状压DP)
查看>>
BZOJ1042:[HAOI2008]硬币购物(DP,容斥)
查看>>
[项目管理]关于项目的工期控制
查看>>
hdu3976(Electric resistance) 高斯消元
查看>>
重启eclipse color theme失效的解决办法
查看>>
使用腾讯云COS与CDN提示跨域的解决方案
查看>>