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

相关文章

MySQL 获取字符串长度及注意事项

《MySQL获取字符串长度及注意事项》本文通过实例代码给大家介绍MySQL获取字符串长度及注意事项,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录mysql 获取字符串长度详解 核心长度函数对比⚠️ 六大关键注意事项1. 字符编码决定字节长度2

python3如何找到字典的下标index、获取list中指定元素的位置索引

《python3如何找到字典的下标index、获取list中指定元素的位置索引》:本文主要介绍python3如何找到字典的下标index、获取list中指定元素的位置索引问题,具有很好的参考价值,... 目录enumerate()找到字典的下标 index获取list中指定元素的位置索引总结enumerat

基于Python开发Windows屏幕控制工具

《基于Python开发Windows屏幕控制工具》在数字化办公时代,屏幕管理已成为提升工作效率和保护眼睛健康的重要环节,本文将分享一个基于Python和PySide6开发的Windows屏幕控制工具,... 目录概述功能亮点界面展示实现步骤详解1. 环境准备2. 亮度控制模块3. 息屏功能实现4. 息屏时间

SpringMVC高效获取JavaBean对象指南

《SpringMVC高效获取JavaBean对象指南》SpringMVC通过数据绑定自动将请求参数映射到JavaBean,支持表单、URL及JSON数据,需用@ModelAttribute、@Requ... 目录Spring MVC 获取 JavaBean 对象指南核心机制:数据绑定实现步骤1. 定义 Ja

C++中RAII资源获取即初始化

《C++中RAII资源获取即初始化》RAII通过构造/析构自动管理资源生命周期,确保安全释放,本文就来介绍一下C++中的RAII技术及其应用,具有一定的参考价值,感兴趣的可以了解一下... 目录一、核心原理与机制二、标准库中的RAII实现三、自定义RAII类设计原则四、常见应用场景1. 内存管理2. 文件操

使用Python开发一个现代化屏幕取色器

《使用Python开发一个现代化屏幕取色器》在UI设计、网页开发等场景中,颜色拾取是高频需求,:本文主要介绍如何使用Python开发一个现代化屏幕取色器,有需要的小伙伴可以参考一下... 目录一、项目概述二、核心功能解析2.1 实时颜色追踪2.2 智能颜色显示三、效果展示四、实现步骤详解4.1 环境配置4.

SpringBoot服务获取Pod当前IP的两种方案

《SpringBoot服务获取Pod当前IP的两种方案》在Kubernetes集群中,SpringBoot服务获取Pod当前IP的方案主要有两种,通过环境变量注入或通过Java代码动态获取网络接口IP... 目录方案一:通过 Kubernetes Downward API 注入环境变量原理步骤方案二:通过

使用Python实现获取屏幕像素颜色值

《使用Python实现获取屏幕像素颜色值》这篇文章主要为大家详细介绍了如何使用Python实现获取屏幕像素颜色值,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 一、一个小工具,按住F10键,颜色值会跟着显示。完整代码import tkinter as tkimport pyau

python获取cmd环境变量值的实现代码

《python获取cmd环境变量值的实现代码》:本文主要介绍在Python中获取命令行(cmd)环境变量的值,可以使用标准库中的os模块,需要的朋友可以参考下... 前言全局说明在执行py过程中,总要使用到系统环境变量一、说明1.1 环境:Windows 11 家庭版 24H2 26100.4061

使用Python获取JS加载的数据的多种实现方法

《使用Python获取JS加载的数据的多种实现方法》在当今的互联网时代,网页数据的动态加载已经成为一种常见的技术手段,许多现代网站通过JavaScript(JS)动态加载内容,这使得传统的静态网页爬取... 目录引言一、动态 网页与js加载数据的原理二、python爬取JS加载数据的方法(一)分析网络请求1