C#获取屏幕大小的“简单整理”。。
生活随笔
收集整理的這篇文章主要介紹了
C#获取屏幕大小的“简单整理”。。
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
額……
首先是有一個(gè)需求,兩個(gè)顯示器,程序自動(dòng)獲取自己所在的顯示器大小,并顯示到右下角。
我們都知道C#有一個(gè)Screen.PrimaryScreen.Bounds,可以獲取屏幕的完整尺寸,但是只能獲取主顯示器的尺寸,后來我發(fā)現(xiàn)又一個(gè)Screen.GetBounds(this),可以獲取程序所在的屏幕尺寸。
代碼如下
Console.WriteLine("主顯示器完整尺寸:"); Console.WriteLine("寬:" + Screen.PrimaryScreen.Bounds.Width); Console.WriteLine("高:" + Screen.PrimaryScreen.Bounds.Height);Console.WriteLine("主顯示器工作尺寸(排除任務(wù)欄、工具欄):"); Console.WriteLine("寬:" + Screen.PrimaryScreen.WorkingArea.Width); Console.WriteLine("高:" + Screen.PrimaryScreen.WorkingArea.Height);Console.WriteLine("當(dāng)前顯示器完整尺寸:"); Console.WriteLine("寬:" + Screen.GetBounds(this).Width); Console.WriteLine("高:" + Screen.GetBounds(this).Height);Console.WriteLine("當(dāng)前顯示器工作尺寸(排除任務(wù)欄、工具欄):"); Console.WriteLine("寬:" + Screen.GetWorkingArea(this).Width); Console.WriteLine("高:" + Screen.GetWorkingArea(this).Height);來回就這么兩句,還有其他的功能可以看一下官方幫助文檔。
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的C#获取屏幕大小的“简单整理”。。的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TextView 单行显示长文本
- 下一篇: mysql中int、bigint、sma