Redefining Perspectives 4 - Metro ui Session 2 ver 3 5 (5)

  • 747 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
747
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Metro UI: A deep diveSession 2
  • 2. 2© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALWhat we’ll cover:ApplicationModelCollaborationbetween appsDevelopmentand executionmodel changesDeep-Dive into developing real world capital market appsusing WinRT & Metro UI
  • 3. 3© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALRunningNot RunningSuspendedActivating SuspendingTerminatingResumingApplication Model | App LifecycleActivated Suspended Terminated
  • 4. 4© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALApplication Model | State ManagementLocalStateTransient State PersistenceTempFolderLocal Folder / SettingsCloud
  • 5. 5© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIAL// Handle OnLaunched handler of application class and check for previous execution stateprotected override void OnLaunched(LaunchActivatedEventArgs args){if(args.PreviousExecutionState == ApplicationExecutionState.Terminated) {foreach (var item in ApplicationData.Current.LocalSettings.Values){AppSettings.Instance.Settings[item.Key] = item.Value;} }}State Management | Implementationpublic App(){//Add application suspending handler.this.Suspending += OnSuspending;}// Handler for suspending eventvoid OnSuspending(object sender, SuspendingEventArgs e){foreach (var item in AppSettings.Instance.Settings){ApplicationData.Current.LocalSettings.Values[item.Key] = item.Value;}}
  • 6. 6© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALThings to remember…Save application data when the app isbeing suspendedRelease exclusive resources and filehandles when the app is beingsuspendedSave less data (only as much as yourequire) and save as you go
  • 7. 7© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALCollaboration between Apps Sharing Search Activation Mechanisms
  • 8. 8© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALCollaboration | Sharing
  • 9. 9© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSharing | Manifest Declaration Target Application
  • 10. 10© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSharing | Prepare Data in Source Application// Prepare data to share in DataRequested handlervoid DataRequested(DataTransferManager sender, DataRequestedEventArgs e){// Set context information about sharing.e.Request.Data.Properties.Title = "Orders Manager";e.Request.Data.Properties.Description = "Order Details for " + orderCount.ToString() + "order(s)";// Specify the format and set actual data to be shared with another application.e.Request.Data.SetData(StandardDataFormats.Html,OrderItemCollection.ToHTML(_data));}// Add handler to Data Requested event of DataTransferManager class.public OrdersPage(){DataTransferManager datatransferManager = DataTransferManager.GetForCurrentView();// Add handler that gets invoked when sharing starts.datatransferManager.DataRequested += new TypedEventHandler<DataTransferManager,DataRequestedEventArgs>(this.DataRequested);}
  • 11. 11© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSharing | Consume Data in Target Application// Add handler for activated event in javascript file.WinJS.Application.addEventListener("activated",activatedHandler, false);// Handle share activation kind, extract data and draw graphs.function activatedHandler(args) {if (args.detail.kind ==Windows.ApplicationModel.Activation.ActivationKind.shareTarget){// Check for Html data format and extract dataif(args.detail.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.html)) {eventArgs.detail.data.getHtmlFormatAsync().then(function (htmlFormat){ //Draw the charts using the collection } }}
  • 12. 12© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSharing | Report Complete in Target Application// Call report completed on click of close button to report thecompleteness of share operation.function reportCompleted(){shareOperation.reportCompleted();}
  • 13. 13© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALCollaboration| Search
  • 14. 14© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSearch | Manifest Declaration
  • 15. 15© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSearch | In Application Context// In OrderPage.xaml.cs add handler for QuerySubmitted event of CurrentView’s SearchPane.public void OrderPage (){// In QuerySubmitted handler navigate user to search result page.Windows.ApplicationModel.Search.SearchPane.GetCurrentView().QuerySubmitted +=(sender, queryArgs) =>PMWorkbench.SearchResultsPage1.Activate(queryArgs.QueryText);}// Handle visibility change of search page and add context information about search criteria.public OrdersPage(){// Get search pane for current view and add handler to visibility change.var searchPane = SearchPane.GetForCurrentView();searchPane.VisibilityChanged += (sender, args) =>{if (args.Visible)sender.PlaceholderText = "Deal ID /Symbol /Counterparty";}}
  • 16. 16© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSearch | Handle Activation Kind// In App.xaml.cs handle OnSearchActivated method of// application class. This gets invoked by system.protected override voidOnSearchActivated(Windows.ApplicationModel.Activation.SearchActivatedEventArgs args){// Navigate user to Search result page with search context.PMWorkbench.SearchResultsPage1.Activate(args.Query Text);}
  • 17. 17© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALOther Activation Kinds| Protocol Activation
  • 18. 18© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALProtocol Activation | Manifest Declaration
  • 19. 19© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIAL// Prepare a URI with the name of the protocol and the data to// be passed to the app to be launchedOrder Managerprivate async void btnAddToWatch_Click(object sender,RoutedEventArgs e){Uri uri = new Uri(@"watch://" + orderItem.Security);// Launch the URIWindows.System.Launcher.LaunchUriAsync(uri);}Protocol Activation | Prepare URI in Source App
  • 20. 20© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALProtocol Activation | Activation in Target App// Handle activated event and check for kind = protocol// Parse data passed along with the protocolWatch listprotected override void OnActivated(IActivatedEventArgs args){if (args.Kind == ActivationKind.Protocol){var protocolActivatedEventArgs = args asProtocolActivatedEventArgs;if (protocolActivatedEventArgs != null)OnProtocolActivated(protocolActivatedEventArgs.Uri.ToString());}}
  • 21. 21© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALThings to remember…Use the standard charms and contracts acrossapps to provide consistent user experienceProvide contextual information while usingSearch and Share charmsUse various application activation mechanismsto create powerful mash-ups
  • 22. 22© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALDevelopment and execution modelchanges Visual Studio .Net Profile Application Deployment & Execution Model
  • 23. 23© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALDevelopment Changes | Visual Studio
  • 24. 24© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALDevelopment Changes | .NET ProfileUI stack moved to WinRTWCF changesXMLHTTPWCFSerializationBCL.NET for Metro Apps.Net Framework4.5WindowsPhone 7.1.Net for MetroappsSilverlight 5
  • 25. 25© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALDeployment & Execution Model ChangesClassCatalogExtensionCatalogDeploymentEngine<Applications><ApplicationId="App"StartPage="default.html"><VisualElementsDisplayName="Hello World"Logo="imageslogo.png"Description="Hello_World"....xCopy Deployment will not workAppContainers - New security modelCapabilities - To access system resources
  • 26. 26© COPYRIGHT 2012 SAPIENT CORPORATION | CONFIDENTIALSharing Perspectives Q&A session