Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

WP7, Droid, iPhone, Oh my!

on

  • 3,730 views

Slides for the DDD8a Modern .Net day on MonoTouch, MonoDroid and Windows Phone 7. The videos are up on YouTube and are talked over "live" so apologies if they don't make too much sense!

Slides for the DDD8a Modern .Net day on MonoTouch, MonoDroid and Windows Phone 7. The videos are up on YouTube and are talked over "live" so apologies if they don't make too much sense!

Statistics

Views

Total Views
3,730
Views on SlideShare
3,122
Embed Views
608

Actions

Likes
0
Downloads
55
Comments
0

5 Embeds 608

http://weblogs.asp.net 529
http://jbablog.com 69
http://soapbox.gruden.com 8
http://passing.tk 1
http://vps.bouantoun.com.au 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

WP7, Droid, iPhone, Oh my! WP7, Droid, iPhone, Oh my! Presentation Transcript

  • WP7, iPhone, Android Oh my! Modern .NET day Reading 23rd October 2010 Chris Hardy
  • Chris Hardy • ASPInsider • Mobile is my hobby • http://twitter.com/chrisntr
  • http://greatfridays.com
  • http://emmawatson.com
  • http://dominion-funds.com
  • Covering... • Windows Phone 7 • MonoTouch • MonoDroid • Code reuse • Porting code • Demos
  • Windows Phone 7 • Windows Only • Visual Studio 2010 / Expression Blend 4 • Silverlight for Windows Phone... • Great information for developers
  • MonoTouch • Mac only • MonoDevelop • Apple’s Interface Builder • Superset of Silverlight 3 • Good community around
  • MonoDroid (currently in preview form) • Cross platform • Visual Studio 2010 / MonoDevelop • XML Files / DroidDraw • Superset of Silverlight 3 • Early days
  • Windows Phone 7 • Metro • Panorama/Pivot • Launchers/Choosers • Tombstoning
  • Metro http://crocusgirl.wordpress.com/
  • Panorama/Pivot
  • Launchers/Choosers • CameraCaptureTask • EmailAddressChooserTask • MarketplaceHubTask • PhoneCallTask • PhotoChooserTask • SearchTask • SmsComposeTask
  • Tombstoning sort of multi-tasking
  • Demo Twitter on Windows Phone 7
  • Twitter on Windows Phone 7 http://www.youtube.com/watch?v=CZcS5PYG9kw
  • What is MonoTouch?
  • What is Mono? The .Net Framework created by Miguel De Icaza et al.
  • Miguel de Icaza
  • Mono’s JIT Engine Memory Mono CIL
  • Apple Rules • Contractual Requirements • No interpreted code • No shared libraries • Kernel Limitations • iPhone OS 2.0+ disables JIT
  • Mono’s AOT Engine Native Code Mono AOT Mono Runtime CIL ARM
  • MonoTouch Features • mtouch • MonoDevelop iPhone Add-In • CocoaTouch.NET / monotouch.dll • Full static AOT compiler • Support for all your existing code • Reflection • Generics • LINQ • Anonymous Methods • Lambda’s etc...
  • MonoTouch’s APIs
  • The Bindings • MonoTouch namespace • MonoTouch.Foo namespace • Maps to CocoaTouch’s Foo Framework • 1:1 Mapping of classes. • MonoTouch.UIKit.UILabel • CocoaTouch’s UIKit framework, UILabel class
  • Strong Types • Objective-C • Arrays are weakly typed: • NSArray return values. • MonoTouch has strong types • UIView[] Subviews { get; } • vs • NSArray *subviews; • Intellisense - explore the API...
  • Garbage Collection • Automatic: • Mono’s GC will collect objects on demand • Deterministic: • Use when you need control. • Every object in MonoTouch implements IDisposable using (var image = UIImage.FromFile(“foo.png”)){ surface.DrawImage(image, 20, 20); }
  • Linker and the application size...
  • Linking Assemblies
  • App-store MonoTouch Minimum App Size ~6MB
  • Integration • Tight integration between MD and IB • IB produces XIBs with MD parses • Automatic class generation in MD • Generates partial classes for all types, outlets and actions defined in Interface Builder
  • MonoTouch Events • Supports Objective-C pattern: webView.Delegate = new MyWebViewDelegate(); • C# style events as well: webView.PageLoaded += delegate { HideSpinningWheel(); }
  • Debugging • Console.WriteLine(“Debugging inside of MonoTouch”); • printf(“I made it to this line!n”)
  • Debugger • MonoTouch debugger leverages Mono’s new Soft-Debugger • Supports the Simulator • Supports the Device... • even over WiFi
  • Professional iPhone Programming with MonoTouch and .NET/ C# Wallace B. McClure Rory Blyth Martin Bowling Craig Dunn and me... Chris Hardy Out Now!
  • Demo Twitter on iPhone with MonoTouch
  • Twitter on iPhone with MonoTouch Will probably do a video in the future :)
  • What is MonoDroid?
  • What is MonoDroid?
  • What is MonoDroid? C# on Android
  • What is MonoDroid? A commercial product
  • What is MonoDroid? Preview release Not Alpha Not Beta
  • What is MonoDroid? Cross-platform
  • What is MonoDroid? Sign-up for preview access http://go-mono.com/monodroid/
  • Demo Twitter on Android with MonoDroid
  • Twitter on Android with MonoDroid http://www.youtube.com/watch?v=TKXgugOj56I
  • Application Stores
  • Windows Phone 7 $99 Per Year Android $25 Registration iPhone $99 Per Year
  • Code reuse
  • Code reuse Json.Net FlickrNet XNATouch
  • Rebuild your libraries • Can’t just use any DLL • Re-compile for each lib • Each framework has its own class library
  • Not an abstraction!
  • Not an abstraction! • Platform specific APIs • Platform specific look and feel
  • Mono for WP7?
  • Mono for WP7? • Look at Mono code and copy over! • IQueryable support in WP7 • More later...
  • Porting over Hanselminutes
  • Porting over Hanselminutes hanselminutesiphone.codeplex.com
  • Porting over Hanselminutes • Make sure your business logic is separate • Use actions for returning results
  • Getting XML
  • Persisting the XML
  • Isolated Storage vs File Storage
  • Storing data void SaveLocal(string data) { #if (MonoTouch || MonoDroid) File.WriteAllText(_localPath, data); #elif WINDOWS_PHONE using (var appStorage = IsolatedStorageFile.GetUserStoreForApplication()) { var file = appStorage.OpenFile(_localPath, FileMode.Create); FileExtension.WriteAllText(file, data); } #endif }
  • Storing data void SaveLocal(string data) { #if (MonoTouch || MonoDroid) File.WriteAllText(_localPath, data); #elif WINDOWS_PHONE using (var appStorage = IsolatedStorageFile.GetUserStoreForApplication()) { var file = appStorage.OpenFile(_localPath, FileMode.Create); FileExtension.WriteAllText(file, data); } #endif }
  • No File.WriteAllText? No problem!
  • Implementing File.WriteAllText public static void WriteAllText(IsolatedStorageFileStream fileStream, string data) { using (StreamWriter sw = new StreamWriter(fileStream)) { sw.Write(data); sw.Close(); } } public static void WriteAllText(string path, string contents) { WriteAllText(path, contents, Encoding.UTF8); } public static void WriteAllText(string path, string contents, Encoding encoding) { using (StreamWriter sw = new StreamWriter(path, false, encoding)) { sw.Write(contents); } }
  • Limited WebClient calls
  • Downloading a file - MonoTouch _webClient = new WebClient (); _webClient.DownloadFileCompleted += (sender, e) => { _fileDownloaded = true; if (_downloadCompletedSuccessfully) { File.Copy (_show.PartialAudioPath, _show.OfflineAudioPath); } UIHelper.StopInternetActivity (); }; _webClient.DownloadProgressChanged += HandleClientDownloadProgressChanged; _webClient.DownloadFileAsync (new Uri (_show.Url), _show.PartialAudioPath);
  • Downloading a file WP7 var client = new WebClient(); client.DownloadProgressChanged += (s, e) => { progressBar1.Value = e.ProgressPercentage / 100; }; client.OpenReadCompleted += (s, e) => { using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication()) using (var fs = new IsolatedStorageFileStream(CurrentShow.OfflineAudioPath, FileMode.Create, isoStore)) { int bytesRead; byte[] bytes = new byte[1024 * 1024 * 1]; // 1meg while ((bytesRead = e.Result.Read(bytes, 0, bytes.Length)) != 0) { fs.Write(bytes, 0, bytesRead); } _fileDownloaded = true; fs.Flush(); } }; client.OpenReadAsync(new Uri(CurrentShow.Url, UriKind.Absolute));
  • Porting your code • MOMA for Mobile?
  • Conclusions
  • Thanks! Any questions? twitter.com/chrisntr chrisntr@gmail.com