Windows 8 Store Apps學習(56)系統UI Scale, Snap,Orientation,High Contrast

來源:互聯網
上載者:User

介紹

重新想象 Windows 8 Store Apps 之 系統 UI

擷取系統的 UI 相關的設定 資訊

螢幕方向

Snap

為 snap 操作和螢幕方向的改變增加動畫效果

縮放至不同螢幕

高對比

樣本

1、示範如何擷取系統的 UI 相關的設定 資訊

UI/UISettingsInfo.xaml.cs

/* * 示範如何擷取系統的 UI 相關的設定資訊 */    using System;using Windows.UI.ViewManagement;using Windows.UI.Xaml.Controls;using Windows.UI.Xaml.Navigation;    namespace XamlDemo.UI{    public sealed partial class UISettingsInfo : Page    {        public UISettingsInfo()        {            this.InitializeComponent();        }            protected override void OnNavigatedTo(NavigationEventArgs e)        {            UISettings uiSettings = new UISettings();                lblMsg.Text = "AnimationsEnabled: " + uiSettings.AnimationsEnabled; // 是否啟用動畫            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "CaretBlinkRate: " + uiSettings.CaretBlinkRate; // 輸入游標的游標閃爍頻率            lblMsg.Text += Environment.NewLine;                /*             * 游標瀏覽模式(Caret Browsing) - 在頁面中會出現一個類似於記事本中的輸入游標,使用者可以使用鍵盤(按 Shift 鍵 + 方向鍵)來精確地進行頁面文字的選擇             * IE8 以上可以通過“F7”來開啟/關閉游標瀏覽模式             */            lblMsg.Text += "CaretBrowsingEnabled: " + uiSettings.CaretBrowsingEnabled; // 當前輸入游標是否可用於游標瀏覽模式            lblMsg.Text += Environment.NewLine;                lblMsg.Text += "CaretWidth: " + uiSettings.CaretWidth; // 輸入游標的寬度            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "CursorSize: " + uiSettings.CursorSize; // 指標的尺寸            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "DoubleClickTime: " + uiSettings.DoubleClickTime; // 捕獲雙擊時,兩次單擊間的最長時間            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "HandPreference: " + uiSettings.HandPreference; // 使用者介面的方向(LeftHanded 或 RightHanded)            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "MessageDuration: " + uiSettings.MessageDuration; // 訊息顯示的期間,單位:秒            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "MouseHoverTime: " + uiSettings.MouseHoverTime; // hover 事件觸發之前,指標可以 hover 的時間            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "ScrollBarArrowSize: " + uiSettings.ScrollBarArrowSize; // 當前視窗捲軸的箭頭的大小            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "ScrollBarSize: " + uiSettings.ScrollBarSize; // 當前視窗捲軸的大小            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "ScrollBarThumbBoxSize: " + uiSettings.ScrollBarThumbBoxSize; // 當前視窗捲軸 thumb 的大小            lblMsg.Text += Environment.NewLine;                    // 擷取當前系統的相關顏色            lblMsg.Text += "ActiveCaption: " + uiSettings.UIElementColor(UIElementType.ActiveCaption);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "Background: " + uiSettings.UIElementColor(UIElementType.Background);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "ButtonFace: " + uiSettings.UIElementColor(UIElementType.ButtonFace);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "ButtonText: " + uiSettings.UIElementColor(UIElementType.ButtonText);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "CaptionText: " + uiSettings.UIElementColor(UIElementType.CaptionText);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "GrayText: " + uiSettings.UIElementColor(UIElementType.GrayText);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "Highlight: " + uiSettings.UIElementColor(UIElementType.Highlight);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "HighlightText: " + uiSettings.UIElementColor(UIElementType.HighlightText);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "Hotlight: " + uiSettings.UIElementColor(UIElementType.Hotlight);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "InactiveCaption: " + uiSettings.UIElementColor(UIElementType.InactiveCaption);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "InactiveCaptionText: " + uiSettings.UIElementColor(UIElementType.InactiveCaptionText);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "Window: " + uiSettings.UIElementColor(UIElementType.Window);            lblMsg.Text += Environment.NewLine;            lblMsg.Text += "WindowText: " + uiSettings.UIElementColor(UIElementType.WindowText);            lblMsg.Text += Environment.NewLine;                    AccessibilitySettings accessibilitySettings = new AccessibilitySettings();            lblMsg.Text += "是否啟用了高對比模式: " + accessibilitySettings.HighContrast; // 是否啟用了高對比模式        }    }}

2、示範與“螢幕方向”相關的知識點

UI/ScreenOrientation.xaml

<Page    x:Class="XamlDemo.UI.ScreenOrientation"    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    xmlns:local="using:XamlDemo.UI"    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    mc:Ignorable="d">        <Grid Background="Transparent">        <StackPanel Margin="120 0 0 0">                <ToggleButton Name="btnLock" Content="鎖定當前方向" IsChecked="False" Checked="btnLock_Checked_1" Unchecked="btnLock_Unchecked_1" />                <TextBlock Name="lblMsg" FontSize="14.667" Margin="0 10 0 0" />                        </StackPanel>                </Grid></Page>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.