mail ria & silverlight – defining new experience on the web our ria objectives - eric hoffman...

55
Building AOL's High Performance Rich Internet Application in Silverlight 2.0 AOL Mail

Upload: emerald-haynes

Post on 03-Jan-2016

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Building AOL's High Performance Rich Internet Application in Silverlight 2.0AOL Mail

Page 2: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Eric HoffmanDirector, AOL Mail RIA’s

Marc KatchayLead Engineer, AOL Mail RIA’s

Stefan GalArchitect, AOL Mail RIA

Seth HalvakszAOL Mail Product Mgmt

Page 3: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Outline ...Mail RIA & Silverlight – Defining new experience on the Web

Our RIA objectives - Eric HoffmanA Silverlight development tale – Eric HoffmanA new verse in web User Interface – Marc KatchayThe underlying nuts and bolts – Stefan GalMonetization opportunities – Seth Halvaksz An Invitation

Page 4: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Our RIA primitives

The next chapter for web applicationsRich and performantPersonalization taken to another level Write it once, run it everywhereBeyond the web cacheEnhanced engagementNew monetization opportunities

Page 5: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

A Silverlight RIA taleSummer 2007

Beginning with Silverlight 1.0 / 2.0Research and exploration projectWe were hopeful…

High Definition video and audio playback Compact size and the idea of “write it once” The “DNA” for some controls.NET runtime – really appealing to us developersChallenges presented themselves throughout the summer of 07

Page 6: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

A Silverlight RIA tale ..December 2007

“grid” & “stack” prototype

Page 7: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

A Silverlight tale …December/January 2008

Silverlight 2.0 provided…Basic layout Grid & stack panels Isolated storage – size was a factor stillCould we build an application with just this ..

Pivotal moment was reachedHybrid approach was contemplatedDelay project several monthsIn the end ..our team decided to write some code ..

Page 8: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

A Silverlight RIA tale

namespace Client.Controls.Button{ [TemplatePart(Name="Part_MouseUp“,Type=typeof(Storyboard)),…public abstract class ButtonBase : Control

{…

}}

Page 9: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

A Silverlight RIA tale Jan 08

What we really needed … more advanced controls..

Buttons, checkboxesTree controlListView,- virtualized ..Listboxes – for settingsHtml control for read and write mailGrid splitters & custom layoutDatabinding – move data from model to our controls

Page 10: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

A Silverlight RIA taleLate Jan 2008

Morphed into a Collaboration ..Contribution to the core Silverlight feature setRequest functionality as we needed ..A validation of the usability of the frameworkSome examples

Adding encryption for secure isolated storageImagine background worker threads – in a web application ! Cross domain would be nice …

Page 11: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Road to Silverlight RIA – Dencryption Code using (Stream xstream = new CryptoStream(stream, _alghoritm.CreateDecryptor(), CryptoStreamMode.Read)) {

using (Stream zstream = new GZipStream(xstream, CompressionMode.Decompress))

{ data = LoadObject<T>(zstream); } }

Page 12: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Road to Silverlight RIA – Worker Thread Code public void SaveObject<T>(string path, T data, Action<Exception> cb) where T : class  { // Main thread here …   ThreadPool.QueueUserWorkItem(delegate(object state)   { // Anonymous function – C#      // Worker thread here …

Exception exception = null;        try{             SaveObject(path, data);            }         catch (Exception ex){               exception = ex;                }    }}

Page 13: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Mail RIA

demo

Page 14: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Marc KatchayLead Engineer, RIA Engineering AOL Mail

announcing…

Page 15: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Visual Requirements

Appealing – Look goodRich in assets - VibrantFeel alive!! – non static lookDynamic/ResizableSkinnableFast – seem effortless

Page 16: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Building Top Down

Designers create UI layoutDevelopers build controls and componentsControls paint visuals and bind to business dataUI elements taken from designers layout and rendered in respective controls

Page 17: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Creating UI – Designers FirstArtists/Designers create applicationThink multiple/Differentiating skinsUtilize tools. Create in natural format - xamlBuild application to adopt designer requirements

Page 18: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Application layout - InfrastructureIdentify Key Components

Components are themselves controlsDefine Root Layout of Application

Page 19: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Visual Controls - Infrastructure

First things first!! -- Custom ControlsDataGridCellsListTreeTreeNodesGridSplitterButtons…

Page 20: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Control Templates

Custom visual controls derive from control classControl Class supports Control TemplatesAll components and visual controls use templatesCritical for skinning modelTemplates collected to form a skin

Page 21: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Control Template Markup

<ControlTemplate/>

<Grid x:Name="Part_Root">

<Grid.Resources> <Storyboard x:Name="Part_MouseEnter"> <ColorAnimation Duration="00:00:00.2“ To="#50FFFFFF"

Storyboard.TargetName="Part_HighlightRect”Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)" /> </Grid.Resources>

<Rectangle x:Name="Part_HighlightRect" Fill="#00FFFFFF"/> <TextBlock x:Name="Part_Caption” FontSize="12" Text="Button" />

</ControlTemplate>

Page 22: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Loading Control Skin

namespace Client.Controls{ public class ButtonCell : Control {

ResourceHelper.GetControlTemplate(typeof(ButtonCell)); }

public ButtonCell() { base.Template = s_CellTemplate; base.ApplyTemplate();

}}

Page 23: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Challenge - Skin motion

Browser resizesGrid SplittersSome UI elements grow as skin is resizedManage Multiple UI elementsBuilt specialized layout panels to encapsulate and draw multiple elements of a skinCode behind should never have custom code dedicated to a skin

Page 24: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

ViewPanel – Layout Control

<ControlTemplate>

<Grid x:Name=“Part_Root”><Controls:ViewPanel> <Path x:Name=“Part_Frame” Data=“….”/> <Rectangle x:Name=“Part_Background” /></Controls:ViewPanel></Grid>

<ControlTemplate>

Page 25: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

ViewPanel – Layout Control

public abstract class ViewPanel : Panel { protected override Size MeasureOverride(Size availableSize) {

} protected override Size ArrangeOverride(Size finalSize) {

} }

Page 26: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

SkinsSkin is a projectComprised of Templates and Images

Page 27: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Skins

ResourceHelper ClassLoads Skin AssemblyHelper functions to locate and load templates

GetControlTemplate()Helper functions to load resources

Application BackgroundBackground animation

Page 28: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Summary

We have a skin solutionSeparate assembliesChange skinsDynamic living skinsWell defined layer for designers to work with

UI InfrastructureControls – TemplatesComponents – define key sections of app

Page 29: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Stefan GalArchitect, RIA Mail Engineering AOL Mail

announcing…

Page 30: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Overview

The quest for a rich, interactive user experienceCustom controlsSilverlight overlays

Page 31: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Custom Controls - Goals

High performanceExtreme flexibilitySkinnableSmall download

Page 32: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Custom Controls - Patterns

Template based controlsExtensive data bindingTemplate binding whenever possibleShared resources and stylesVirtualized controls for large data sets

Page 33: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Observable Data

public class ItemData: INotifyPropertyChanged

{ public event PropertyChangedEventHandler PropertyChanged;}

Page 34: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Observable Data Source

VirtualizedList _list1;ObservableCollection<ItemData> _dataSource;…_list1.ItemsSource = _dataSource;

Page 35: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Flexible Data & Visuals

public class VirtualizedList : Control{ … public IList ItemsSource { … } public DataTemplate ItemTemplate { … }}

Page 36: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Virtualized Databinding

<c:VirtualizedList x:Name="_list1”> <c:VirtualizedList.ItemTemplate> <DataTemplate> <c:ListItem Foreground="Blue“ Text=“{Binding Caption}”/> </DataTemplate> </c:VirtualizedList.ItemTemplate></c:VirtualizedList>

Page 37: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Custom Item Template

<DataTemplate> <TextBlock

Text="{Binding Caption}" Foreground="Gold“ Padding="2"/></DataTemplate>

Page 38: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Virtualized List

AOL

demo

Page 39: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Layered Silverlight Plugins

HTML

Overlay

Page 40: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Layered Silverlight Plugins

Requirement introduced by the usage of browser based HTML rendering and compositionAlso used for

Context menusModal dialogsRich Tooltips‘Out of banner’ Silverlight adsLegacy ads

Page 41: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Layering Challenges

Creating Silverlight overlay pluginCommunication between pluginsSharing code and resourcesPlugin lifetime management

Page 42: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Creating Overlay Plugin

Hosted by an absolute positioned DIVHost element is child of main host element, sibling of the main pluginSilverlight.js support to create the additional pluginWindowless mode supports transparency and irregularly shaped windows

Page 43: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Creating Overlay Plugin

ScriptObject arg = (ScriptObject)HtmlPage.Window.Eval("new Object;");arg.SetProperty("initParams", “parentId=" + HtmlPage.Plugin.Id;

ScriptObject slso = (ScriptObject)HtmlPage.Window. GetProperty("Silverlight");slso.Invoke("createObjectEx", arg);

Page 44: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Communicating Between Plugins

Each plugin runs in its own application domainJSON payload passed as parameters and returned as result.Input and output passed by value.Scriptable objects used for callbacks and interactionCreation is asynchronous, the child plugin will find and connect to the parent based on initialization parameters

Page 45: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Sharing Code and Resources

Separate .xap archive files are used for main plugin and overlay pluginsDistributing shared code and resources in both archives is possible but not desirable due to increased download size.We chose to have the overlay load the required assemblies dynamically from the main archiveIt is fast because the download will find the main archive cached by the browser

Page 46: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Sharing Code and Resources

Main.xap

Model.dll

Controls.dll

Popup.xap

Popup.dll

Page 47: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Retrieving Main Archive

_webClient = new WebClient();_webClient.OpenReadCompleted += delegate(object sender,… e) { Load(new StreamResourceInfo (e.Result, null)); };

_webClient.OpenReadAsync(new Uri(“shared.xap",

UriKind.Relative));

Page 48: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Loading Assemblies On DemandStreamResourceInfo ri = Application.GetResourceStream(xap, new Uri(“shared.dll“, UriKind.Relative));

AssemblyPart p = new AssemblyPart();Assembly a = p.Load(ri.Stream);

Page 49: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Silverlight Overlay Ad

AOL

demo

Page 50: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Summary

Flexible separation of data, control logic and control visualsLightweight and high performanceExtensive bindingVirtualized controls for large data setsRich, highly interactive visualsSkins downloaded on demand

Page 51: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

Seth HalvakszProduct Management, RIA Engineering AOL Mail

announcing…

Page 52: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

AOL Mail RIA & Monetization

ObjectivesEngagingHigh-performingStandards-based

Integration between ads and application

SkinsPanels

Rich media optionsHigh impact audio & videoRich animations

Page 53: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

AOL Mail RIA & Silverlight

A new experience on the webIndustry-leading performanceUnique skinning capabilitiesHigh impact content delivery

Mail from AOLInnovative productsGet the email identity and experience that expresses who you are and what you like

Page 54: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse

An Invitation

Sign up today to be notified when the preview is available

http://ria.mail.aol.com

Page 55: Mail RIA & Silverlight – Defining new experience on the Web Our RIA objectives - Eric Hoffman A Silverlight development tale – Eric Hoffman A new verse