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.
1140 0
|
Windows
[UWP]使用AdaptiveTrigger实现自适应布局
原文:[UWP]使用AdaptiveTrigger实现自适应布局 这篇博客将介绍如何在UWP开发中使用AdaptiveTrigger实现自适应布局。 场景1:窗体宽度大于800时,窗体背景色为绿色,窗体在0到800之间为蓝色。
1015 0
|
编解码 C# Windows
WPFの获取屏幕分辨率并自适应
原文:WPFの获取屏幕分辨率并自适应 double x = SystemParameters.WorkArea.Width;//得到屏幕工作区域宽度 double y = SystemParameters.
1910 0
win10 uwp 毛玻璃
原文:win10 uwp 毛玻璃 版权声明:博客已迁移到 http://lindexi.gitee.io 欢迎访问。如果当前博客图片看不到,请到 http://lindexi.gitee.io 访问博客。
1065 0
|
编解码 C#
WPF 获取屏幕分辨率(获取最大宽高)等
原文:WPF 获取屏幕分辨率(获取最大宽高)等 double x = SystemParameters.WorkArea.Width;//得到屏幕工作区域宽度 double y = SystemParameters.
1486 0
UWP 裁切 SoftwareBitmap
//设置源图ImageSource为WriteableBitmap类型 BitmapImage himage = this.imageTarget2.Source as BitmapImage; RandomAccessStreamReference random = RandomAccessStreamReference.
909 0
|
开发框架 前端开发 .NET
|
Windows 容器
背水一战 Windows 10 (17) - 动画: ThemeTransition(过渡效果)
原文:背水一战 Windows 10 (17) - 动画: ThemeTransition(过渡效果) [源码下载] 背水一战 Windows 10 (17) - 动画: ThemeTransition(过渡效果) 作者:webabcd介绍背水一战 Windows 10 之 动画 Theme...
986 0
|
前端开发 Windows
背水一战 Windows 10 (15) - 动画: 缓动动画
原文:背水一战 Windows 10 (15) - 动画: 缓动动画 [源码下载] 背水一战 Windows 10 (15) - 动画: 缓动动画 作者:webabcd介绍背水一战 Windows 10 之 动画 缓动动画 - easing 示例演示缓动(easing)的应用Animation/EasingAnimation.
1286 0