UI 设计概述

  • 启动屏幕(闪屏)
  • 屏幕方向

示例
1、UI 设计概述
UI/Summary.xaml

<Page
x:Class="Windows10.UI.Summary"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.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="10 0 10 10"> <TextBlock Name="lblMsg" TextWrapping="Wrap" Margin="0 10 10 10">
<Run>1、UWP - Universal Windows Platform</Run>
<LineBreak />
<Run>2、设计 UWP 应用时,要以有效像素(effective pixels)进行设计,而不是以物理像素(physical pixels)进行设计。因为系统会根据设备的像素密度和观看距离自动缩放</Run>
<LineBreak />
<Run>3、有效分辨率 - 以有效像素为单位的分辨率;物理分辨率 - 以物理像素为单位的分辨率</Run>
<LineBreak />
<Run>4、对于有效分辨率的理解可以参考 ios 的逻辑分辨率的概念,比如 iPhone 4s 的物理分辨率为 960 * 640,其逻辑分辨率为 480 * 320(设计时按照此分辨率设计)</Run>
<LineBreak />
<Run>5、有效分辨率和物理分辨率之间的比例是如何决定的呢?由系统根据设备的像素密度和观看距离来决定比例</Run>
<LineBreak />
<Run>6、当系统缩放 UI 时,会按 4 的倍数(multiples of 4, 从字面上理解不一定是整倍数)进行缩放。若要确保缩放后保持清晰的外观,请将你的设计贴靠到 4*4 像素网格,使 UI 元素的边距、大小和位置为 4 个有效像素的倍数</Run>
</TextBlock> </StackPanel>
</Grid>
</Page>

2、启动屏幕(闪屏)
UI/MySplashScreen.xaml

<Page
x:Class="Windows10.UI.MySplashScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.UI"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"> <!--
var color = (Color)this.Resources["SystemAccentColor"];
-->
<Grid Name="grid" Background="{ThemeResource SystemAccentColor}"> <Image x:Name="splashImage" Source="/Assets/SplashScreen.png" HorizontalAlignment="Center" /> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0 0 0 20">
<ProgressRing IsActive="True" Foreground="White" />
<TextBlock Name="lblMsg" Text="我是自定义启动页,1 秒后跳转到主页" Margin="0 10 0 0" />
</StackPanel> </Grid>
</Page>

UI/MySplashScreen.xaml.cs

/*
* 演示如何自定义启动屏幕(闪屏)
*
* 说明及应用场景:
* 1、在 Package.appxmanifest 中可以设置 app 的启动屏幕,例如: <uap:SplashScreen Image="Assets\SplashScreen.png" BackgroundColor="#ff0000" />,其就是一个显示在窗口中间的图片(620 * 300)以及一个全窗口背景色
* 2、在 app 的启动屏幕过后,可以显示一个自定义启动屏幕
* 3、在自定义启动屏幕显示时,可以做一些程序的初始化工作,初始化完成后再进入主程序
*/ using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; namespace Windows10
{
using Windows10.UI; public partial class App
{
// partial method,实现了 App.xaml.cs 中的声明
partial void OnLaunched_SplashScreen(LaunchActivatedEventArgs args)
{
// 启动后显示自定义启动屏幕
if (args.PreviousExecutionState != ApplicationExecutionState.Running)
{
MySplashScreen mySplashScreen = new MySplashScreen(args);
Window.Current.Content = mySplashScreen;
}
}
}
} namespace Windows10.UI
{
public sealed partial class MySplashScreen : Page
{
/*
* SplashScreen - app 的启动屏幕对象,在 Application 中的若干事件处理器中的事件参数中均可获得
* ImageLocation - app 的启动屏幕的图片的位置信息,返回 Rect 类型对象
* Dismissed - app 的启动屏幕关闭时所触发的事件
*/ // app 启动屏幕的相关信息
private SplashScreen _splashScreen; public MySplashScreen()
{
this.InitializeComponent(); lblMsg.Text = "自定义 app 的启动屏幕,打开 app 时可看到此页面的演示";
} public MySplashScreen(LaunchActivatedEventArgs args)
{
this.InitializeComponent(); ImplementCustomSplashScreen(args);
} private async void ImplementCustomSplashScreen(LaunchActivatedEventArgs args)
{
// 窗口尺寸发生改变时,重新调整自定义启动屏幕
Window.Current.SizeChanged += Current_SizeChanged; // 获取 app 的启动屏幕的相关信息
_splashScreen = args.SplashScreen; // app 的启动屏幕关闭时所触发的事件
_splashScreen.Dismissed += _splashScreen_Dismissed; // 获取 app 启动屏幕的图片的位置,并按此位置调整自定义启动屏幕的图片的位置
Rect splashImageRect = _splashScreen.ImageLocation;
splashImage.SetValue(Canvas.LeftProperty, splashImageRect.X);
splashImage.SetValue(Canvas.TopProperty, splashImageRect.Y);
splashImage.Height = splashImageRect.Height;
splashImage.Width = splashImageRect.Width; await Task.Delay(1000); // 关掉自定义启动屏幕,跳转到程序主页面
var rootFrame = new Frame();
rootFrame.Navigate(typeof(MainPage), args);
Window.Current.Content = rootFrame;
Window.Current.Activate();
} void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
{
// 获取 app 启动屏幕的图片的最新位置,并按此位置调整自定义启动屏幕的图片的位置
Rect splashImageRect = _splashScreen.ImageLocation;
splashImage.SetValue(Canvas.LeftProperty, splashImageRect.X);
splashImage.SetValue(Canvas.TopProperty, splashImageRect.Y);
splashImage.Height = splashImageRect.Height;
splashImage.Width = splashImageRect.Width;
} private void _splashScreen_Dismissed(SplashScreen sender, object args)
{
// app 的启动屏幕关闭了
}
}
}

3、屏幕方向
UI/ScreenOrientation.xaml

<Page
x:Class="Windows10.UI.ScreenOrientation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Windows10.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="10 0 10 10"> <ToggleButton Name="btnLock" Content="锁定当前方向" IsChecked="False" Checked="btnLock_Checked" Unchecked="btnLock_Unchecked" /> <TextBlock Name="lblMsg" Margin="0 10 0 0" /> </StackPanel> </Grid>
</Page>

UI/ScreenOrientation.xaml.cs

/*
* 演示“屏幕方向”相关知识点
*/ using System;
using Windows.Graphics.Display;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation; namespace Windows10.UI
{
public sealed partial class ScreenOrientation : Page
{
public ScreenOrientation()
{
this.InitializeComponent();
} protected override void OnNavigatedTo(NavigationEventArgs e)
{
// 使用设备时的推荐方向,一般而言就是当“windows”键在下方时,设备的方向。手机一般是 Portrait,平板一般是 Landscape
lblMsg.Text = "NativeOrientation: " + DisplayInformation.GetForCurrentView().NativeOrientation.ToString();
lblMsg.Text += Environment.NewLine; // 设备的方向(Windows.Graphics.Display.DisplayOrientations 枚举:None, Landscape, Portrait, LandscapeFlipped, PortraitFlipped)
// 注:LandscapeFlipped 是 Landscape 翻转了 180 度,PortraitFlipped 是 Portrait 翻转了 180 度
// 注:Landscape 顺时针转(右转) 90 度是 Portrait,再顺时针转(右转) 90 度是 LandscapeFlipped
lblMsg.Text += "CurrentOrientation: " + DisplayInformation.GetForCurrentView().CurrentOrientation.ToString(); // NativeOrientation 或 CurrentOrientation 发生变化时触发的事件(NativeOrientation 一般是不会变的)
DisplayInformation.GetForCurrentView().OrientationChanged += ScreenOrientation_OrientationChanged;
} private void ScreenOrientation_OrientationChanged(DisplayInformation sender, object args)
{
lblMsg.Text += Environment.NewLine;
lblMsg.Text += "NativeOrientation: " + DisplayInformation.GetForCurrentView().NativeOrientation.ToString();
lblMsg.Text += Environment.NewLine;
lblMsg.Text += "CurrentOrientation: " + DisplayInformation.GetForCurrentView().CurrentOrientation.ToString();
} protected override void OnNavigatedFrom(NavigationEventArgs e)
{
DisplayInformation.GetForCurrentView().OrientationChanged -= ScreenOrientation_OrientationChanged;
} private void btnLock_Checked(object sender, RoutedEventArgs e)
{
/* 在 Package.appxmanifest 中可以配置 app 的允许方向,类似如下(如果不配置就是允许任何方向)
<uap:InitialRotationPreference>
<uap:Rotation Preference="portrait" />
<uap:Rotation Preference="landscape" />
<uap:Rotation Preference="portraitFlipped" />
<uap:Rotation Preference="landscapeFlipped" />
<uap:InitialRotationPreference>
*/ // DisplayInformation.AutoRotationPreferences - 指定当前 app 的首选方向,即强制通过指定的方向显示(必须是在 Package.appxmanifest 配置的允许方向之一)
DisplayInformation.AutoRotationPreferences = DisplayInformation.GetForCurrentView().CurrentOrientation;
btnLock.Content = "解除方向锁定";
} private void btnLock_Unchecked(object sender, RoutedEventArgs e)
{
DisplayInformation.AutoRotationPreferences = DisplayOrientations.None;
btnLock.Content = "锁定当前方向";
}
}
}

UI: 概述, 启动屏幕, 屏幕方向的更多相关文章

  1. 背水一战 Windows 10 (2) - UI: 概述, 启动屏幕, 屏幕方向

    [源码下载] 背水一战 Windows 10 (2) - UI: 概述, 启动屏幕, 屏幕方向 作者:webabcd 介绍背水一战 Windows 10 之 UI UI 设计概述 启动屏幕(闪屏) 屏 ...

  2. Web开发中管理ipad屏幕的方向变化

    Web开发中,我们会遇到在手机垂直或水平视角时展示不同状态的情况.下面我来总结一下检测移动设备方向变化的一些方法. 1 使用javascript 直接看代码: <script type=&quo ...

  3. java 24 - 9 GUI 之 给窗体换图标、设置启动在屏幕中间、更换皮肤

    A.首先更改窗体左上角的图片 步骤一: 创建3个包,分别建立1个类 第一个是窗体的包,窗体类:设置窗体的主要布置和功能 第二个是资源包,图片:把想要改的图案拉进来 第三个是UI界面包,UI界面设计类: ...

  4. Ubuntu出现卡logo、卡住、黑屏无法正常启动、屏幕和键盘背光无法调节等一系列问题?可能是NVIDIA显卡驱动没装好

    也不知道是幸运还是不幸,我从一开始接触ubuntu就遇到这一系列的问题, 而且一直没有一个彻底解决的办法,搞得我无比头疼,也害得我重装了无数遍系统... 国际惯例,只按照个人习惯和喜好来写,对某些人来 ...

  5. UI基础:视图控制器.屏幕旋转.MVC 分类: iOS学习-UI 2015-07-02 22:21 62人阅读 评论(0) 收藏

    UIViewController 视图控制器,继承自UIResponder,作用:管理视图并且响应事件 功能: 1.分担APPdelegate的工作 2.实现模块独立,能提高复用性 创建UIViewC ...

  6. Android 屏幕自适应方向尺寸

    最近感觉要被屏幕适配玩死了…… 安卓的手机为虾米不能像苹果那样只有几个分辨率呢?为什么呢!!!!!!!阿门…… 目前想到有两种解决办法…… 第一种:   HTML5+CSS3+WebView交互……目 ...

  7. 【iOS】屏幕旋转,屏幕自适应方向变化

    1. iOS有四个方向的旋转,为了保证自己的代码能够支持旋转,我们必须首先处理一个函数: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInter ...

  8. (转)iOS7界面设计规范(3) - UI基础 - 启动与退出

    周二晚间来第三发,搞得好像今天是周六的赶脚.发掉之后再奖励自己一点冰啤酒吧,然后扑床去.天气热起来了,各位注意防暑降温呗.走起. 重要:这是针对于正在开发中的API或技术的预备文档(预发布版本).虽然 ...

  9. android自适应屏幕方向和大小

    一:不同的layout Android手机 屏幕 大小不一,有480x320, 640x360, 800x480.怎样才能让App自动 适应不同的屏幕 呢?      其实很简单,只需要在res目录下 ...

随机推荐

  1. ionic 使用sqlite

    昨天被ionic和sqlite折腾一天,怎么也无法实现读取,后来才发现,原来是codova中的sqliteplugin版本问题. 问题:Database location or iosDatabase ...

  2. LVS+Keepalived+Squid+Nginx+MySQL主从高性能集群架构部署方案

    方案一,在tomcat的workers.properties里面配置相关条件 worker.tomcat.lbfactor= worker.tomcat.cachesize= worker.tomca ...

  3. AEAI Portal V3.5.4升级说明,门户集成平台

    1 总体说明 本次升级是AEAI Portal的一次重要升级,主要扩展了开发社区(论坛).移动门户功能,同时修正一些功能BUG等,具体内容如下: 2 升级内容 功能扩展: 扩展开发社区导航 扩展移动门 ...

  4. Reporting Service 服务启动时报错The service did not respond to the start or control request in a timely fashion

    案例环境: 启动一台数据库服务器(Windows Server 2003)的Reporting Service(SQL Server 2008 R2)服务时,出现如下错误信息: System.Inva ...

  5. [MySQL] Buffer Pool Adaptive Flush

    Buffer Pool Adaptive Flush 在MySQL的帮助文档中Tuning InnoDB Buffer Pool Flushing提到, innodb_adaptive_flushin ...

  6. 关于xml的使用。

    使用的常用类: XmlSerializer ParaMapping StreamReader DirectionaryInfo FileInfo using as object 例子: public ...

  7. Tomcat 启动报错:No default web.xml

    原因是:tomcat 中conf 目录中的 web.xml 被无意删除掉了.从其他tomcat中复制一个过来就行了. conf 目录 没有 web.xml 导致的问题是,server.xml 中配置的 ...

  8. BOOST.Asio——扫盲

    以下内容来自互联网. 鉴于版权之类的东西,我只贴出标题和URL. (无法考证下述资料是否原创.) asio串口编程                                            ...

  9. 问题解决——MFC error RC2170: bitmap file res\XXXXXXX.png is not in 3.00 format

    =================================版权声明================================= 版权声明:原创文章 谢绝转载  请通过右侧公告中的“联系邮 ...

  10. 通过重构VO实现校验功能

    现有个需求,需要添加供应商的页面校验功能,当填写一二级时,供应商是必填项,并且所填的供应商必须是二级分类下的,否则下一步和保存过不去: 解决方案: 1.在页面AM的XXXImpl.java中, 加入引 ...