介绍
重新想象 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>
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索光标
, 系统
, text
, environment
, 方向
, text decorationa
text()
,以便于您获取更多的相关知识。
时间: 2024-10-29 04:37:47