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 == )
{
lblmsg.Content = "已经投射1个显示器";
}
else if (screens.Length == )
{
lblmsg.Content = "已经投射2个显示器";
}
else if (screens.Length == )
{
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 > ) {
var subscreen1 = subScreen[];
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 > ) {
foreach (var item in openWindows)
{
item.Close();
}
}
} }
}
WPF使用扩展屏幕的更多相关文章
- WPF的单位 屏幕 分辨率
原文:WPF的单位 屏幕 分辨率 WPF程序中的单位是与设备无关的单位,每个单位是1/96英寸,如果电脑的DPI设置为96(每个英寸96个像素),那么此时每个WPF单位对应一个像素,不过如果电脑的DP ...
- ubuntu扩展屏幕
1.了解设置的名称 直接运行xrandr(不带任何参数)就可以显示出当前的显示设备及设备的模式. xdj@xdj-Presario-CQ42-Notebook-PC:~$ xrandr Screen ...
- WPF 获取鼠标屏幕位置、窗口位置、控件位置
原文:WPF 获取鼠标屏幕位置.窗口位置.控件位置 public struct POINT { public int X; public int Y; public POINT(int x, int ...
- winform,wpf,winrt获取屏幕分辨率
winform 当前的屏幕除任务栏外的工作域大小 this.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Widt ...
- linux屏幕扩展、扩展屏幕的校准
#xrandr命令为屏幕扩展 #xinput命令为输入设备 #设置DSI-1为HDMI-1的右扩展 xrandr --output DSI- --right-of HDMI- --auto #DSI- ...
- 2.6 wpf标记扩展
1.什么是标记扩展?为什么要有标记扩展? 标记扩展是扩展xmal的表达能力 为了克服现存的类型转换机制存在的 常用的标记扩展有如下: x:Array 代表一个.net数组,它的子元素都是数组元素.它必 ...
- WPF treeview扩展
记录一下工作中遇到的问题,以便以后忘记了可以来看. 在工作中遇到一个问题,就是要实现类型如下的界面,没有使用Telerik和Dev库.本来最开始是想使用Datagrid,但不知道怎么实现treevie ...
- 设置Ubuntu右侧显示扩展屏幕。。。
sudo xrandr --output VGA1 --right-of LVDS1 --auto
- Wpf窗口设置屏幕居中最前显示
public Window() { InitializeComponent(); WindowStartupLocation = Win ...
随机推荐
- WPF快速入门系列(2)——深入解析依赖属性
一.引言 感觉最近都颓废了,好久没有学习写博文了,出于负罪感,今天强烈逼迫自己开始更新WPF系列.尽管最近看到一篇WPF技术是否老矣的文章,但是还是不能阻止我系统学习WPF.今天继续分享WPF中一个最 ...
- Sqoop2 环境搭建
原文地址:http://www.cnblogs.com/luogankun/p/4209017.html 正在准备做Spark SQL external data source与关系型数据库交互的部分 ...
- 在stackoverflow上使用markdown
stackoverflow流派的markdown. Code and Preformatted Text 缩进四个空格,就可以写代码片段了 def hello(): print "hello ...
- Neo4j:Data Model Transformation:From Relation To Graph
Here are some tips that help you with the transformation: Each entity table is represented by a labe ...
- tomcat安全配置
1. 注释或删除 tomcat-users.xml 所有用户权限,看上去如下: <tomcat-users></tomcat-users> 2. 隐藏tomcat版本信息 1 ...
- SQL——用户定义函数
根据用户定义函数返回值的类型,可将用户定义函数分为如下三个类别: (1) 返回值为可更新表的函数 若用户定义函数包含单个 SELECT 语句且该语句可更新,则该函数返回的表也可更新,这样的函数称为内嵌 ...
- atitit. 统计功能框架的最佳实践(1)---- on hibernate criteria
atitit. 统计功能框架的最佳实践(1)---- on hibernate criteria 1. 关键字 1 2. 统计功能框架普通有有些条件选项...一个日期选项..一个日期类型(日,周,月份 ...
- MySQL分区表
当数据库数据量涨到一定数量时,性能就成为我们不能不关注的问题,如何优化呢? 常用的方式不外乎那么几种: 1.分表,即把一个很大的表达数据分到几个表中,这样每个表数据都不多. 优点:提高并发量,减小锁的 ...
- 虚拟机下samba简单安装配置
系统是Win7 虚拟机是CenterOS6.5 1.关闭防火墙以及关闭SELINUX的强制模式(重要): service iptables stop//关闭防火墙 setenforce 0 //关闭S ...
- js Array 交集 并集 差集 去重
最劲项目需要用到js数组去重和交集的一些运算,我的数组元素个数可能到达1000以上,网上的实现方式都是2次循环,性能不适合我的需求,1000*1000那循环次数太多了,所以我这里采用对象object来 ...