共用方式為


SystemSettings 類別

提供裝置上之使用者介面設定和原生 (Native) Windows Embedded CE 作業系統設定的存取。

命名空間:  Microsoft.WindowsCE.Forms
組件:  Microsoft.WindowsCE.Forms (在 Microsoft.WindowsCE.Forms.dll 中)

語法

'宣告
Public NotInheritable Class SystemSettings
'用途
Dim instance As SystemSettings
public sealed class SystemSettings
public ref class SystemSettings sealed
public final class SystemSettings

備註

目前,這個類別 (Class) 只提供 ScreenOrientationPlatform 屬性的設定。

範例

下列程式碼範例會示範如何將裝置的螢幕方向,從預設縱向檢視的 0 度依序旋轉到 90 度、180 度、270 度,然後旋轉回 0 度。按鈕點選會在 ScreenOrientation 列舉型別中循環。

Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports Microsoft.WindowsCE.Forms



Public Class Form1
   Inherits System.Windows.Forms.Form
   Private WithEvents Button1 As System.Windows.Forms.Button
   Private mainMenu1 As System.Windows.Forms.MainMenu
   Private StatusBar1 As System.Windows.Forms.StatusBar

   ' Set a variable to be incremented by button clicks
   ' that will change the orientation by rotating
   ' through the ScreenOrientation enumeration.
   Private x As Integer = 0


   Public Sub New()
      InitializeComponent()

      Me.MinimizeBox = False

      ' Set the screen orientation to normal
      ' and display the value on the status bar.
      SystemSettings.ScreenOrientation = ScreenOrientation.Angle0
      Me.StatusBar1.Text = SystemSettings.ScreenOrientation.ToString()
   End Sub

   Protected Overrides Sub Dispose(disposing As Boolean)
      MyBase.Dispose(disposing)
   End Sub

   Private Sub InitializeComponent()
      Me.Button1 = New System.Windows.Forms.Button()
      Me.StatusBar1 = New System.Windows.Forms.StatusBar()
      '
      ' Button1
      '
      Me.Button1.Location = New System.Drawing.Point(16, 128)
      Me.Button1.Text = "Rotate"
      '
      ' Form1
      '
      Me.Controls.Add(Button1)
      Me.Controls.Add(StatusBar1)
      Me.Text = "Orientation Demo"
   End Sub

   Shared Sub Main()
      Application.Run(New Form1())
   End Sub


   ' Each click event changes the screen orientation, as determined
   ' by the variable x, which increments from 0 to 3 and then back
   ' to 0. Four clicks cycle through the ScreenOrientation enumeration.
   Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click

      Select Case x
         Case 0

            ' Pass a value for the ScreenOrientation enumeration
            ' to the SetOrientation method, defined below,
            ' and increment x so that the next button
            ' click rotates the screen orientation.
            SetOrientation(ScreenOrientation.Angle90)
            x += 1
         Case 1
            SetOrientation(ScreenOrientation.Angle180)
            x += 1
         Case 2
            SetOrientation(ScreenOrientation.Angle270)
            x += 1
         Case 3
            SetOrientation(ScreenOrientation.Angle0)
            x = 0
         Case Else
            SetOrientation(ScreenOrientation.Angle0)
            x = 0
      End Select
   End Sub


   ' Set the orientation to a value of the
   ' ScreenOrienation enumeration and update the
   ' status bar with the current angle.
   Private Sub SetOrientation(so As ScreenOrientation)
      ' Set the requested orientation.
      SystemSettings.ScreenOrientation = so

      Me.StatusBar1.Text = SystemSettings.ScreenOrientation.ToString()
   End Sub

End Class
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using Microsoft.WindowsCE.Forms;

namespace SystemSettingsTest
{
public class Form1 : System.Windows.Forms.Form
{
 private System.Windows.Forms.Button button1;
 private System.Windows.Forms.MainMenu mainMenu1;
 private System.Windows.Forms.StatusBar statusBar1;

 // Set a variable to be incremented by button clicks
 // that will change the orientation by rotating
 // through the ScreenOrientation enumeration.
 int x = 0;

 public Form1()
 {
  InitializeComponent();

  this.MinimizeBox = false;

  // Set the screen orientation to normal
  // and display the value on the status bar.
  SystemSettings.ScreenOrientation = ScreenOrientation.Angle0;
  this.statusBar1.Text = SystemSettings.ScreenOrientation.ToString();

 }
 protected override void Dispose( bool disposing )
 {
  base.Dispose( disposing );
 }
 #region Windows Form Designer generated code
 private void InitializeComponent()
 {
  this.mainMenu1 = new System.Windows.Forms.MainMenu();
  this.button1 = new System.Windows.Forms.Button();
  this.statusBar1 = new System.Windows.Forms.StatusBar();
  //
  // button1
  //
  this.button1.Location = new System.Drawing.Point(16, 128);
  this.button1.Text = "Rotate";
  this.button1.Click += new System.EventHandler(this.button1_Click);
  //
  // Form1
  //
  this.Controls.Add(this.button1);
  this.Controls.Add(this.statusBar1);
  this.Menu = this.mainMenu1;
  this.Text = "Orientation Demo";
 }
 #endregion
 static void Main()
 {
  Application.Run(new Form1());
 }


  // Each click event changes the screen orientation, as determined
  // by the variable x, which increments from 0 to 3 and then back
  // to 0. Four clicks cycle through the ScreenOrientation enumeration.

 private void button1_Click(object sender, System.EventArgs e)
 {

  switch(x)
  {
   case 0:

    // Pass a value for the ScreenOrientation enumeration
    // to the SetOrientation method, defined below,
    // and increment x so that the next button
    // click rotates the screen orientation.
    SetOrientation(ScreenOrientation.Angle90);
    x++;
    break;
   case 1:
    SetOrientation(ScreenOrientation.Angle180);
    x++;
    break;
   case 2:
    SetOrientation(ScreenOrientation.Angle270);
    x++;
    break;
   case 3:
    SetOrientation(ScreenOrientation.Angle0);
    x = 0;
    break;
   default:
    SetOrientation(ScreenOrientation.Angle0);
    x = 0;
    break;
  }
 }

  // Set the orientation to a value of the
  // ScreenOrienation enumeration and update the
  // status bar with the current angle.
 private void SetOrientation(ScreenOrientation so)
 {
  // Set the requested orientation.

  SystemSettings.ScreenOrientation = so;

  this.statusBar1.Text = SystemSettings.ScreenOrientation.ToString();
 }

繼承階層架構

System.Object
  Microsoft.WindowsCE.Forms.SystemSettings

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

平台

Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Compact Framework

支援版本:3.5、2.0

請參閱

參考

SystemSettings 成員

Microsoft.WindowsCE.Forms 命名空間

其他資源

HOW TO:處理方向和解析度變更