返回首页


{S0的}有时候,我们要显示系统信息的用户,无论是应用程序或一个简单的游戏。我们需要到Windows Phone 7用户通过系统页面显示这些系统的具体信息。因此,在这种情况下,如何将你获取信息,并显示给用户?
好了,这篇文章将帮助你了解它,让你知道这个数据在Windows Phone 7设备。阅读以了解更多有关此主题的。知道有关System.Environment
System命名空间下,我们有一个类叫什么名字??代码>环境??具有不同的属性返回有关Windows Phone 7的设备的信息。下文所述公开的API。阅读评论部分,在这里了解更多有关这些:

namespace System

{

    // Summary:

    //     Provides information about, and means to manipulate, the current environment

    //     and platform. This class cannot be inherited.

    public static class Environment

    {

        // Summary:

        //     When called by trusted applications, gets the fully qualified path of the

        //     current working directory.

        public static string CurrentDirectory { get; set; }

 

        // Summary:

        //     Gets a value indicating whether the common language runtime is shutting down

        //     or the current application domain is unloading.

        public static bool HasShutdownStarted { get; }

 

        // Summary:

        //     Gets the newline string defined for this environment.

        public static string NewLine { get; }

 

        // Summary:

        //     Gets an System.OperatingSystem object that contains the current platform

        //     identifier and version number.

        public static OperatingSystem OSVersion { get; }

 

        // Summary:

        //     Gets the number of processors on the current machine.

        public static int ProcessorCount { get; }

 

        // Summary:

        //     Gets the number of milliseconds elapsed since the system started.

        public static int TickCount { get; }

 

        // Summary:

        //     Gets a System.Version object that describes the major, minor, build, and

        //     revision numbers of the common language runtime.

        public static Version Version { get; }

 

        // Summary:

        //     Gets the path to the system special folder identified by the specified 

        //     enumeration.



        [SecurityCritical]

        public static string GetFolderPath(Environment.SpecialFolder folder);

 

        // Summary:

        //     When it is called by trusted applications, specifies enumerated constants

        //     used to retrieve directory paths to system special folders.

        public enum SpecialFolder

        {

            // Summary: The directory that contains the user's program groups.

            Programs = 2,

 

            // Summary: The directory that serves as a common repository for documents.

            Personal = 5,

 

            // Summary: The directory that corresponds to the user's Startup program group.

            Startup = 7,

 

            // Summary: The directory that contains the Start menu items.

            StartMenu = 11,

 

            // Summary: The directory that serves as a common repository for the user's 

            // favorite items.



            Favorites = 22,

 

            // Summary: The directory that serves as a common repository for 

            // application-specific data for the current roaming user.



           ApplicationData = 26,

        }

    }

}

希望你有一个类和它的各种属性的基本思路。让我们创建一个示例演示,讨论其中的几个。我们将公开我们自己的属性显示在手机用户界面的设备信息。示范
首先,让我们设计的用户界面(图1)如下所示,我们将有两列和多行内容电网。第一列将有属性的标签,我们将显示在第二列。之后,我们将公开一些自定义的依赖项属性的代码隐藏页的ViewModel(如果你是MVVM模式),我们将结合目前在XAML容器的TextBlocks。一旦你运行的应用程序,你会看到在UI中的正确的信息,如下面的图2所示:{S1} {S2的}
让我们来看看我们在代码隐藏文件。在那里,我们将下文所述的DependencyProperty有:{C}
在构造函数中,我们将填充System.Environment类的所有这些特性。下面是该代码片段:
OSVersion = System.Environment.OSVersion.ToString();

CLRVersion = System.Environment.Version.ToString();

TickCount = System.Environment.TickCount;

一旦我们的后端代码是准备好了,我们需要创建UI和UI元素绑定正确的数据。下面是我们的XAML代码的情况下,你需要一个参考:{体C3}
这是从所有编码的一部分。现在,建立并运行应用程序。你会看到在手机屏幕上填入适当的数据。
希望这篇文章有助于了解系统环境信息的基本概念。现在,您将能够轻松地获取系统信息的设备。:_注:Kunal乔杜里_

回答

评论会员: 时间:2
h