20150812 4시간만에 따라해보는 windows 10 앱 개발

Post on 21-Jan-2017

600 Views

Category:

Mobile

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

4시간만에따라해보는Windows 10 앱개발

김영욱 Evangelist

Yowkim@Microsoft.com

http://windows.Microsoft.com

Agenda

1. UWP

2. XAML Controls

3. Networking

4. Linq

5. Data Binding

7. SQLite Local Database

8. Toast

9. Adaptive UI

Introducing the UWP

http://windows.Microsoft.com

Phone Small Tablet2-in-1s

(Tablet or Laptop)Desktops

& All-in-OnesPhablet Large TabletClassic Laptop

Xbox IoTSurface Hub Holographic

Windows 10

http://windows.Microsoft.com

One Store +One Dev Center

Reuse Existing Code

One SDK + Tooling

Adaptive User Interface

NaturalUser Inputs

One Universal Windows Platform

http://windows.Microsoft.com

Universal Windows Platform

A single API surfaceA guaranteed API surface

The same on all devices

PhoneDevice

XboxDevice

DesktopDevice

Windows Core

Universal Windows Platform

http://windows.Microsoft.com

Windows app

A single binary Running on any device

Testing for capabilities

Adjusting to devices

PhoneDevice

XboxDevice

DesktopDevice

Windows Core

Universal Windows Platform

Windows App

DEMO

2:05

Hello devices

http://windows.Microsoft.com

http://windows.Microsoft.com

Platform extensions

Device-specific APIFamily-specific capabilities

Compatible across devices

Unique update cadence

PhoneDevice

XboxDevice

DesktopDevice

Windows Core

Universal Windows Platform

Windows App

Phoneextension

Xboxextension

Desktopextension

http://windows.Microsoft.com

Universal Windows Platform

One Operating SystemOne Windows core for all devices

One App PlatformApps run across every family

One Dev CenterSingle submission flow and dashboard

One Store Global reach, local monetization Consumers, Business & Education

http://windows.Microsoft.com

Windows 10operating system

Bridging technologies

Win32desktop

Webhosted

JavaAndroid

Obj.CiOS

Universal Windows Platform

WWAC++& CX

.Netlanguages

HTMLDirectX

XAML

C++

.Netlanguages

MFCWFWPF

.Netruntime

http://windows.Microsoft.com

Let’s talk about bridge technologies

Objective-CAt Build we announced iOS code can be reused in a Windows app

AndroidAt Build we announced Android code can be reused in a Windows app to run on Windows Phone

WebAt Build we announced web sites can be wrapped to run on Windows

Win32At Build we announced that Classic Windows Apps (CWA) can be packaged as an Appx

http://windows.Microsoft.com

Blend for Visual Studio

The XAML Developer’s IDEAlways part of Visual Studio

Uses the Visual Studio shell

Full auto-complete & intellisense

• Validation

• Snippets

• Peek

File & solution management

Resource management

Data management

Animation

States

http://windows.Microsoft.com

Visual Studio 2015 Editions

EnterpriseArchitecture Modeling, Diagnostics, VSO/ALM & Release Management

ProfessionalArchitecture Validation, VSO/ALM & Feedback Management

Community EditionsVisual Studio Professional Edition

http://windows.Microsoft.com

Microsoft Developer Network

Microsoft documentationhttp://msdn.Microsoft.com

http://dev.Windows.com

Microsoft traininghttp://msevents.Microsoft.com

http://MicrosoftVirtualAcademy.com

MSDN SubscriptionOperating Systems

Server/Client Products

Developer Tools

Azure/O365 Credits

http://windows.Microsoft.com

Developer unlock

XAML controls

http://windows.Microsoft.com

Layout controls

<Border Thickness="" Brush="" />

<Canvas />

<Grid />

<RelativePanel />

<ScrollViewer />

<SplitView DisplayMode="" />

<StackPanel Orientation="" />

<VariableSizedWrapGrid />

<ViewBox Stretch="" />

http://windows.Microsoft.com

Canvas

http://windows.Microsoft.com

StackPanel

http://windows.Microsoft.com

Grid

http://windows.Microsoft.com

WrapGrid

http://windows.Microsoft.com

ScrollViewer

http://windows.Microsoft.com

Viewbox

http://windows.Microsoft.com

RelativePanel

Some child elementsact as anchors

Most child elementsrelate to others

It's a layout techniquefriendly with States

http://windows.Microsoft.com

Buttons

<Button Content="" />

<HyperlinkButton />

<RepeatButton />

<ToggleButton IsChecked="" />

http://windows.Microsoft.com

Text controls

<TextBox Text="" />

<PasswordBox Text="" />

<TextBlock Text="" />

<RichEditBox Content="" />

<RichTextBlock Content="" />

<BitmapIcon UriSource="" />

<FontIcon Glyph="" />

<SymbolIcon Icon="" />

<PathIcon Data="" />

http://windows.Microsoft.com

SplitViewIsPaneOpen="True" IsPaneOpen="False"

DisplayMode=

"Inline"

DisplayMode=

"Overlay"

DisplayMode=

"CompactInline"

DisplayMode=

"CompactOverlay"

DEMO

2:05

SplitView

http://windows.Microsoft.com

App bars and commands

<AppBar />

<CommandBar />

<AppBarButton Label="" Icon="" />

<AppBarToggleButton IsChecked="" />

<AppBarSeparator />

DEMO

2:05

AppBar

Networking

Daum 검색 APIhttp://developers.daum.net/

http://windows.Microsoft.com

Daum Open APIs

http://windows.Microsoft.com

Daum Open APIs

http://windows.Microsoft.com

System.Net.Http.HttpClient

Namespace: System.Net.Http.HttpClientAssembly: System.Net.Http (in System.Net.Http.dll)

DEMO

System.Net.Http.HttpClient

http://windows.Microsoft.com

Entity Class

class BookItem

{public Int64 Id { get; set; }public string Title { get; set; }public string Category { get; set; }public string ImageUrl { get; set; }public string Description { get; set; }

}

Linq

http://windows.Microsoft.com

Architecture

OthersC# VB.NET

.NET Language Integrated Query (LINQ)

LINQto SQL

LINQto Objects

LINQto XML

LINQto Datasets

LINQto Entities

LINQ data source providers

ADO.NET support for LINQ

http://windows.Microsoft.com

LINQ to Objects

C#int[] nums = new int[] {0,4,2,6,3,8,3,1};double average = nums.Take(6).Average();var above = from n in nums

where n > averageselect n;

http://windows.Microsoft.com

System.Net.Http.HttpClient

DEMO

Linq

Data binding

Data binding basics

http://windows.Microsoft.com

https://msdn.microsoft.com/ko-kr/library/ms752347(v=VS.110).aspx

http://windows.Microsoft.com

Dynamic Data

Use data binding to connect to a data sourceTypical data source would be a view model

DEMO

Data Binding

SQLite Local Database

http://windows.Microsoft.com

SQLite.org

Documentation

SQL Syntax

C/C++ API Reference

Source and toolsdownload

http://windows.Microsoft.com

Choice of .NET APIs

SQLite-NETLINQ syntaxLightweight ORM

SQLitePCLSQL statementsThin wrapper around the SQLite C API

using (var conn = new SQLiteConnection("demo.db"))

{

Customer customer = null;

using (var statement = conn.Prepare(

"SELECT Id, Name FROM Customer WHERE Id = ?"))

{

statement.Bind(1, customerId);

if (SQLiteResult.DONE == statement.Step()) {

customer = new Customer() {

Id = (long)statement[0],

Name = (string)statement[1] };

}

}

}

var db =new SQLite.SQLiteAsyncConnection(App.DBPath);

var _customer = await(from c in db.Table<Customer>() where c.Id == customerIdselect c).FirstOrDefaultAsync();

if (customer != null) {

var Id = _customer.Id; var Name = _customer.Name;

}

…and others!

http://windows.Microsoft.com

Installing SQLitePCL to your Solution

DEMO

SQLitePCL

http://windows.Microsoft.com

Create database and tables

private void LoadDatabase()

{

// Get a reference to the SQLite database

conn = new SQLiteConnection("sqlitepcldemo.db");

string sql = @"CREATE TABLE IF NOT EXISTS

Customer (Id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,

Name VARCHAR( 140 ),

City VARCHAR( 140 ),

Contact VARCHAR( 140 )

);";

using (var statement = conn.Prepare(sql))

{

statement.Step();

}

}

http://windows.Microsoft.com

Insert

// SqlConnection was opened in App.xaml.cs and exposed through property conn

var db = App.conn;

try

{

using (var custstmt = db.Prepare("INSERT INTO Customer (Name, City, Contact) VALUES (?, ?, ?)"))

{

custstmt.Bind(1, customerName);

custstmt.Bind(2, customerCity);

custstmt.Bind(3, customerContact);

custstmt.Step();

}

}

catch (Exception ex)

{

// TODO: Handle error

}

http://windows.Microsoft.com

Select

public Customer GetCustomer(int customerId)

{

Customer customer = null;

using (var statement = dbconn.Prepare("SELECT Id, Name, City, Contact FROM Customer WHERE Id = ?"))

{

statement.Bind(1, customerId);

if (SQLiteResult.DONE == statement.Step())

{

customer = new Customer()

{

Id = (long)statement[0],

Name = (string)statement[1],

City = (string)statement[2],

Contact = (string)statement[3]

};

}

}

return customer;

}

http://windows.Microsoft.com

Update

// See if the customer already exists

var existingCustomer = GetCustomer(customer.Id);

if (existingCustomer != null)

{

using (var custstmt =

dbconn.Prepare("UPDATE Customer SET Name = ?, City = ?, Contact = ? WHERE Id=?"))

{

// NOTE when using anonymous parameters the first has an index of 1, not 0.

custstmt.Bind(1, customer.Name);

custstmt.Bind(2, customer.City);

custstmt.Bind(3, customer.Contact);

custstmt.Bind(4, customer.Id);

custstmt.Step();

}

}

http://windows.Microsoft.com

Delete

public void DeleteCustomer(int customerId)

{

using (var statement = dbconn.Prepare("DELETE FROM Customer WHERE Id = ?"))

{

statement.Bind(1, customerId);

statement.Step();

}

}

DEMO

SQLite using SQLitePCL

Toast

http://windows.Microsoft.com

Toasts

Glance (consume)See new information from your apps.

Act (chase, or take actions)Toasts invite you to begin or complete a task.

The toast is the app’s door by chasing (clicking) it.

Additional actions enable users to perform simple tasks without context switching.

http://windows.Microsoft.com

Toast templates

If a template meets your needs, go ahead and use it.

Previous templates remainPhone and Windows templates have been merged

Adaptive templateSame XML syntax as tiles

http://windows.Microsoft.com

Sending toast

ScheduledSet template and time with “ScheduledToastNotification”

Toast can also be set to be recurring.

LocalSend from (foreground/background) app

This includes desktop apps with “AppUserModelID”

PushUse push services

http://windows.Microsoft.com

Interactive toast

Adaptive UI

http://windows.Microsoft.com

http://windows.Microsoft.com

http://windows.Microsoft.com

Adaptive design

Phone (portrait)

Tablet (landscape) / Desktop

http://windows.Microsoft.com

http://windows.Microsoft.com

Tailored design

Phone (portrait)

Tablet (landscape) / Desktop

http://windows.Microsoft.com

Tailored design

Build pages/code for individual familiesUse MRT in App.xaml.cs to determine the family

One-handed interface?Typically phone or small tablets

Test diagonal screen size (<7")

if (physical_diagonal_size <= 7)

// optimized for one-handed operation

rootFrame.Navigate(typeof(MainPage_OneHanded), e.Arguments);

else

rootFrame.Navigate(typeof(MainPage), e.Arguments);

http://windows.Microsoft.com

Visual States

Define XAML viewsUnique layout for distinct states

Simplify animationAutomatically implement state transitions

Build in BlendDesign and preview states and transitions

http://windows.Microsoft.com

DEMO

Visual states

http://windows.Microsoft.com

How to set the visual state

VisualStateManager.Goto(element, state, transition)

public MainPage(){

this.InitializeComponent();this.SizeChanged += (s, e) =>{

var state = "VisualState000min";if (e.NewSize.Width > 500)

state = "VisualState500min";else if (e.NewSize.Width > 800)

state = "VisualState800min";else if (e.NewSize.Width > 1000)

state = "VisualState1000min";VisualStateManager.GoToState(this, state, true);

};}

DEMO

Adaptive triggers

A Developer’s Guide to Windows 10 Preview

http://www.microsoftvirtualacademy.com/training-courses/a-developers-guide-to-windows-10-preview

Adaptive Code

http://windows.Microsoft.com

Adding extensions

http://windows.Microsoft.com

Extension SDKs

UWP

Windows Core Windows Core Windows Core Windows Core

UWP UWP UWP

Desktop Mobile Xbox More…

The device families you choose determines which APIs you can call freely

http://windows.Microsoft.com

Testing for capabilities

IsApiContractPresentIsEnumNamedValuePresentIsEventPresentIsMethodPresentIsPropertyPresentIsReadOnlyPropertyPresentIsTypePresentIsWriteablePropertyPresent

Windows.Foundation.Metadata.ApiInformation

http://windows.Microsoft.com

Test capabilities at runtime

var api = "Windows.Phone.UI.Input.HardwareButtons";

if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(api))

{

Windows.Phone.UI.Input.HardwareButtons.CameraPressed

+= CameraButtonPressed;

}

top related