Silverlight获取屏幕分辨率

简介: ///     /// 浏览器屏幕信息类    ///     public class Browser    {        ///            /// During stati...

/// <summary>
   
/// 浏览器屏幕信息类
   
/// </summary>
    public class Browser
    {
       
/// <summary>  
       
/// During static instantiation, only the Netscape flag is checked  
       
/// </summary>  
        static Browser()
        {
            _isNavigator
= HtmlPage.BrowserInformation.Name.Contains("Netscape");
        }

       
/// <summary>  
       
/// Flag indicating Navigator/Firefox/Safari or Internet Explorer  
       
/// </summary>  
        private static bool _isNavigator;

       
/// <summary>  
       
/// Provides quick access to the window.screen ScriptObject  
       
/// </summary>  
        private static ScriptObject Screen
        {
           
get
            {
                ScriptObject screen
= (ScriptObject)HtmlPage.Window.GetProperty("screen");

               
if (screen == null)
                {
                   
throw new InvalidOperationException();
                }

               
return screen;
            }
        }

       
/// <summary>  
       
/// Gets the window object's client width  
       
/// </summary>  
        public static double ClientWidth
        {
           
get
            {
               
return _isNavigator ? (double)HtmlPage.Window.GetProperty("innerWidth")
                    : (
double)HtmlPage.Document.Body.GetProperty("clientWidth");
            }

        }

       
/// <summary>  
       
/// Gets the window object's client height  
       
/// </summary>  
        public static double ClientHeight
        {
           
get
            {
               
return _isNavigator ? (double)HtmlPage.Window.GetProperty("innerHeight")
                    : (
double)HtmlPage.Document.Body.GetProperty("clientHeight");
            }
        }

       
/// <summary>  
       
/// Gets the current horizontal scrolling offset  
       
/// </summary>  
        public static double ScrollLeft
        {
           
get
            {
               
return _isNavigator ? (double)HtmlPage.Window.GetProperty("pageXOffset")
                    : (
double)HtmlPage.Document.Body.GetProperty("scrollLeft");
            }
        }

       
/// <summary>  
       
/// Gets the current vertical scrolling offset  
       
/// </summary>  
        public static double ScrollTop
        {
           
get
            {
               
return _isNavigator ? (double)HtmlPage.Window.GetProperty("pageYOffset")
                    : (
double)HtmlPage.Document.Body.GetProperty("scrollHeight");
            }
        }

       
/// <summary>  
       
/// Gets the width of the entire display  
       
/// </summary>  
        public static double ScreenWidth
        {
           
get
            {
               
return (double)Screen.GetProperty("width");
            }
        }

       
/// <summary>  
       
/// Gets the height of the entire display  
       
/// </summary>  
        public static double ScreenHeight
        {
           
get
            {
               
return (double)Screen.GetProperty("height");
            }
        }

       
/// <summary>  
       
/// Gets the width of the available screen real estate, excluding the dock  
       
/// or task bar  
       
/// </summary>  
        public static double AvailableScreenWidth
        {
           
get
            {
               
return (double)Screen.GetProperty("availWidth");
            }
        }

       
/// <summary>  
       
/// Gets the height of the available screen real estate, excluding the dock /// or task bar  
       
/// </summary>  
        public static double AvailableScreenHeight
        {
           
get
            {
               
return (double)Screen.GetProperty("availHeight");
            }
        }

       
/// <summary>  
       
/// Gets the absolute left pixel position of the window in display coordinates  
       
/// </summary>  
        public static double ScreenPositionLeft
        {
           
get
            {
               
return _isNavigator ? (double)HtmlPage.Window.GetProperty("screenX")
                    : (
double)HtmlPage.Window.GetProperty("screenLeft");
            }
        }

       
/// <summary>  
       
/// Gets the absolute top pixel position of the window in display coordinates  
       
/// </summary>  
        public static double ScreenPositionTop
        {
           
get
            {
               
return _isNavigator ? (double)HtmlPage.Window.GetProperty("screenY")
                    : (
double)HtmlPage.Window.GetProperty("screenTop");
            }
        }
    }

相关文章
|
前端开发 Windows
闲来无事,倒腾了一个简单的silverlight视频播放器
#silverlightControlHost { height:407px; width:480px; padding:3px; text-align:center; border:solid 1px #ccc; margin:10px; } 近二日闲来无事,把silverlight的官方文档瞅了瞅,倒腾了一个简单的视频播放器,顺便也测试了下能否播放传说中的h.
1123 0
|
Windows
[UWP]使用AdaptiveTrigger实现自适应布局
原文:[UWP]使用AdaptiveTrigger实现自适应布局 这篇博客将介绍如何在UWP开发中使用AdaptiveTrigger实现自适应布局。 场景1:窗体宽度大于800时,窗体背景色为绿色,窗体在0到800之间为蓝色。
985 0
|
编解码 C# Windows
WPFの获取屏幕分辨率并自适应
原文:WPFの获取屏幕分辨率并自适应 double x = SystemParameters.WorkArea.Width;//得到屏幕工作区域宽度 double y = SystemParameters.
1808 0
win10 uwp 毛玻璃
原文:win10 uwp 毛玻璃 版权声明:博客已迁移到 http://lindexi.gitee.io 欢迎访问。如果当前博客图片看不到,请到 http://lindexi.gitee.io 访问博客。
1039 0
|
C# Windows
WPF Windows背景透明其中的文字保持不透明
原文:WPF Windows背景透明其中的文字保持不透明 版权声明:本文为博主原创,未经允许不得转载。交流、源码资料加群:161154103 https://blog.
1735 0
|
容器 数据可视化 内存技术
Silverlight & Blend动画设计系列一:偏移动画(TranslateTransform)
原文:Silverlight & Blend动画设计系列一:偏移动画(TranslateTransform)   用户界面组件、图像元素和多媒体功能可以让我们的界面生动活泼,除此之外,Silverlight还具备动画功能,它可以让应用程序“动起来”。
795 0
|
编解码 C#
WPF 获取屏幕分辨率(获取最大宽高)等
原文:WPF 获取屏幕分辨率(获取最大宽高)等 double x = SystemParameters.WorkArea.Width;//得到屏幕工作区域宽度 double y = SystemParameters.
1414 0
|
编解码 C#
WPF中三种方法得到当前屏幕的宽和高
原文:WPF中三种方法得到当前屏幕的宽和高 WPF程序中的单位是与设备无关的单位,每个单位是1/96英寸,如果电脑的DPI设置为96(每个英寸96个像素),那么此时每个WPF单位对应一个像素,不过如果电脑的DPI设备为120(每个英寸120个像素),那此时每个WPF单位对应应该是120/96=1.
1139 0
|
C#
WPF 控件库——仿制Windows10的进度条
原文:WPF 控件库——仿制Windows10的进度条 一、其实有现成的   先来看看Windows10进度条的两种模式:       网上有不少介绍仿制Windows10进度条的文章,也都实现了不错的效果。
1337 0
UWP 滚动条私人定制
原文:UWP 滚动条私人定制 最近突然发现微软自带的滚动条好挫哦   微软哒(棒棒哒)       网上找的(美美哒)     好了。 如果你想要棒棒哒,那么就不用往下看了(手动再见)。
923 0