Transcript
Page 1: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1
Page 2: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

http://curah.microsoft.com/60638/reusing-code-between-windows-store-apps-and-windows-phone

Page 3: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

The Windows Runtime (WinRT) is the shared runtime and API space used by store apps across the Windows platform (phone and client)

3

Common WinRT APIs

Phone-specific WinRT APIs

Windows-specific WinRT APIs

Dramatic convergence in 8.1 •  Goal is 100% convergence for dev scenarios •  In 8.0, we had ~30% API convergence •  With 8.1, we move well past 90%+ convergence

Page 4: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

HTML

Win32

JavaScript Code

WinRT

C++ Code C#/VB Code

HTML XAML XAML

Windows Runtime XAML

WinJS .NET for Windows Store

C#/VB Code

Silverlight XAML

Silverlight .NET

Windows Phone Silverlight XAML

Page 5: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1
Page 6: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1
Page 7: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

Windows Phone 8.1 App Windows 8.1 App

XAML View Phone UI

XAML View Windows UI

Shared Code, Images, Files

WinRT

Page 8: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

Windows Phone 8.1 App Windows 8.1 App

XAML View XAML UI

XAML View XAML UI

Logic Logic

Data Data

?

Logic

Data

Page 9: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

Code files XAML Images XML/JSON RESW

Page 10: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

Supports WinRT APIs

Expose libraries to C++, Javascript apps

Page 11: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

Decouple UI from logic

plus platform specific API sets (some geolocation, media, sensors)

plus XAML components that “make sense”

Page 12: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

Windows 8.1 Windows Phone 8.1

some common APIs may have different behaviour across Windows/Phone

Windows Only WinRT

e.g. search contract e.g. multiple windows e.g. resizable windows e.g. printing support

Phone Only WinRT

e.g. action center e.g. status bar e.g. back key handling

Page 13: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

files & settings: local, temp, roaming, pickers…

network: http, websockets, sockets…

notifications: tiles, toasts, badges, push

store: app purchases, receipts…

sensors: gps, geofencing, gyro, compass…

lifecycle: launch, suspend, resume, background tasks

localisation: resource resolution from XAML/code…

Page 14: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

//Create  the  picker  object  FileOpenPicker  openPicker  =  new  FileOpenPicker();  openPicker.ViewMode  =  PickerViewMode.Thumbnail;  openPicker.SuggestedStartLocation  =            PickerLocationId.PicturesLibrary;    //  Users  expect  to  have  a  filtered  view  of  their  folders    openPicker.FileTypeFilter.Add(".jpg");  openPicker.FileTypeFilter.Add(".png");    //  Open  the  picker  for  the  user  to  pick  a  file  StorageFile  file  =                await  openPicker.PickSingleFileAsync();    if  (file  !=  null)  {          //  Do  something  with  the  file...  }  

  //Create  the  picker  object  FileOpenPicker  openPicker  =  new  FileOpenPicker();  

  //  On  Windows  Phone,  setting  Filtering  to  image  types    //  causes  Picker  to  show  Camera  Roll  openPicker.FileTypeFilter.Add(".jpg");  

  openPicker.FileTypeFilter.Add(".png");    //  Open  the  picker  for  the  user  to  pick  a  file  openPicker.PickSingleFileAndContinue();  

Page 15: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

100%

100%

No: Location (Windows) vs. Geopoint (WP)

No: Bing Maps (Windows) vs. WinRT Map control (WP)

Page 16: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

"""

Page 17: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

Windows = WINDOWS_APP Windows Phone = WINDOWS_PHONE_APP

Page 18: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

C#

   #if  WINDOWS_PHONE_APP        Windows.Phone.UI.Input.HardwareButtons.BackPressed  +=                            this.HardwareButtons_BackPressed;      #endif  

C++        #if  WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP        _backPressedEventToken  =  HardwareButtons::BackPressed  +=            ref  new  EventHandler<BackPressedEventArgs^>(this,        &NavigationHelper::HardwareButton_BackPressed);      #endif

Page 19: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1
Page 20: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1
Page 21: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

///  <summary>  ///  DataSource.cs  ///  </summary>  public  partial  class  DataSource  :IDataSource  {          public  async  Task<IEnumerable<IFolder>>  RetrieveFolders(IFolder  root)  {                  ...  //  other  logic                  var  folders  =  await  LoadFolders(root);                  ...  //  other  logic                  return  folders          }  }    ///  <summary>  ///  DataSource.WP.cs  ///  </summary>  public  partial  class  DataSource  {          private  async  Task<IEnumerable<IFolder>>  LoadFolders(IFolder  root)  {                  ...          }  }  

Page 22: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

"

"

Page 23: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

"

"

"

Page 24: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

HERE maps on Windows (8.1)/Phone (8.0)

Page 25: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

common, same rendering Button

Slider

ToggleSwitch

ProgressBar

etc (many more)

common, different content Hub

ListView GridView etc.

common, different rendering DatePicker

TimePicker CommandBar AppBar etc.

unique

SearchBox

Pivot ContentDialog AutoSuggestBox etc.

Page 26: Александр Краковецкий_Разработка универсальных приложений для Windows Phone 8.1 и Windows 8.1

www.microsoft.com/learning

http://microsoft.com/msdn http://microsoft.com/technet

http://channel9.msdn.com/Events/TechEd


Top Related