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 ...
随机推荐
- Asp.Net Web API 2 官网菜鸟学习系列导航[持续更新中]
详情请查看http://aehyok.com/Blog/Detail/67.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本文文章链接:ht ...
- ASP.NET Web API从注释生成帮助文档
默认情况下,ASP.NET Web API不从Controller的注释中生成帮助文档.如果要将注释作为Web API帮助文档的一部分,比如在帮助文档的Description栏目中显示方法注释中的su ...
- SQL Server FileStream
以往我们对文件管理有两种方法: 数据库只保存文件的路径,具体的文件保存在文件服务器(NFS)上,使用时,编程实现从文件服务器读取文件: 将文件直接以varbinary(max)或image数据类型保存 ...
- ActiveMQ第五弹:增加ReDelivery功能
在使用Message Queue的过程中,总会由于种种原因而导致消息失败.一个经典的场景是一个生成者向Queue中发消息,里面包含了一组邮件地址和邮件内容.而消费者从Queue中将消息一条条读出来,向 ...
- Gradle里配置jetty实现静态资源的热部署
通过Gradle我们可以很方便的使用内置jetty启动我们的web程序,在本地进行调试.但是在使用的过程中,我发现了几个问题,导致本地调试的效率大受影响. 如果使用gradle jettyRun启动j ...
- iOS UICollectionView的实现
ios的UICollectionView并不能在iOS6之前的版本中使用,为了兼容之前的版本需要自定义UICollectionView.写完之后发现人家已经有开源了,下过来看了看发现我是用UIScro ...
- Struts2学习笔记-jsp中引用struts2框架
如果在jsp中需要引用struts2 框架,需在前面加上以下内容 <%@taglib prefix="s" uri="/struts-tags" %> ...
- 攻城利器 —— Carthage简单介绍
01 Carthage简单介绍 主页:https://github.com/Carthage/Carthage.git 作者:Justin Spahr-Summers等 版本:0.18 目标:用最简单 ...
- ubuntu下安装 infer
sudo apt-get updatesudo apt-get upgradesudo apt-get install git openjdk-7-jdk m4 zlib1g-dev python-s ...
- iOS Vuforia:TextReco 增加自己的单词库
Vuforia的文字识别引擎提供了很好的文字识别功能.引擎依赖于UTF-8字符编码,现支持的字符有A-Z a-z,换行符.空格.单引号.短斜杠.Note:不支持中文及数字.能识别的字体是: ...