Silverlight获取屏幕分辨率

2024-03-17 13:32

本文主要是介绍Silverlight获取屏幕分辨率,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

/// <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");
            }
        }
    }

这篇关于Silverlight获取屏幕分辨率的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/819105

相关文章

macOS Sequoia 15.5 发布: 改进邮件和屏幕使用时间功能

《macOSSequoia15.5发布:改进邮件和屏幕使用时间功能》经过常规Beta测试后,新的macOSSequoia15.5现已公开发布,但重要的新功能将被保留到WWDC和... MACOS Sequoia 15.5 正式发布!本次更新为 Mac 用户带来了一系列功能强化、错误修复和安全性提升,进一步增

通过C#获取Excel单元格的数据类型的方法详解

《通过C#获取Excel单元格的数据类型的方法详解》在处理Excel文件时,了解单元格的数据类型有助于我们正确地解析和处理数据,本文将详细介绍如何使用FreeSpire.XLS来获取Excel单元格的... 目录引言环境配置6种常见数据类型C# 读取单元格数据类型引言在处理 Excel 文件时,了解单元格

Java根据IP地址实现归属地获取

《Java根据IP地址实现归属地获取》Ip2region是一个离线IP地址定位库和IP定位数据管理框架,这篇文章主要为大家详细介绍了Java如何使用Ip2region实现根据IP地址获取归属地,感兴趣... 目录一、使用Ip2region离线获取1、Ip2region简介2、导包3、下编程载xdb文件4、J

SpringBoot整合mybatisPlus实现批量插入并获取ID详解

《SpringBoot整合mybatisPlus实现批量插入并获取ID详解》这篇文章主要为大家详细介绍了SpringBoot如何整合mybatisPlus实现批量插入并获取ID,文中的示例代码讲解详细... 目录【1】saveBATch(一万条数据总耗时:2478ms)【2】集合方式foreach(一万条数

python获取网页表格的多种方法汇总

《python获取网页表格的多种方法汇总》我们在网页上看到很多的表格,如果要获取里面的数据或者转化成其他格式,就需要将表格获取下来并进行整理,在Python中,获取网页表格的方法有多种,下面就跟随小编... 目录1. 使用Pandas的read_html2. 使用BeautifulSoup和pandas3.

SpringBoot UserAgentUtils获取用户浏览器的用法

《SpringBootUserAgentUtils获取用户浏览器的用法》UserAgentUtils是于处理用户代理(User-Agent)字符串的工具类,一般用于解析和处理浏览器、操作系统以及设备... 目录介绍效果图依赖封装客户端工具封装IP工具实体类获取设备信息入库介绍UserAgentUtils

C# foreach 循环中获取索引的实现方式

《C#foreach循环中获取索引的实现方式》:本文主要介绍C#foreach循环中获取索引的实现方式,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、手动维护索引变量二、LINQ Select + 元组解构三、扩展方法封装索引四、使用 for 循环替代

Android实现两台手机屏幕共享和远程控制功能

《Android实现两台手机屏幕共享和远程控制功能》在远程协助、在线教学、技术支持等多种场景下,实时获得另一部移动设备的屏幕画面,并对其进行操作,具有极高的应用价值,本项目旨在实现两台Android手... 目录一、项目概述二、相关知识2.1 MediaProjection API2.2 Socket 网络

Linux下如何使用C++获取硬件信息

《Linux下如何使用C++获取硬件信息》这篇文章主要为大家详细介绍了如何使用C++实现获取CPU,主板,磁盘,BIOS信息等硬件信息,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录方法获取CPU信息:读取"/proc/cpuinfo"文件获取磁盘信息:读取"/proc/diskstats"文

Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案

《Vue3组件中getCurrentInstance()获取App实例,但是返回null的解决方案》:本文主要介绍Vue3组件中getCurrentInstance()获取App实例,但是返回nu... 目录vue3组件中getCurrentInstajavascriptnce()获取App实例,但是返回n