1. Trang chủ
  2. » Thể loại khác

Tài liệu SilverLight2Programming docx

61 288 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 61
Dung lượng 6,79 MB

Nội dung

Programming Silverlight 2+1 Trịnh Minh Cường cuong@microsoft.com Blog: http://msdnvietnam.net/blogs/cuong/default.aspx Microsoft Silverlight cross-browser (IE, FireFox, Safari) cross-platform (Moonlight on Linux) cross-device Plug-in for building and delivering the next generation of NET based media experiences and rich interactive applications http://www.go-mono.com/moonlight/ for the Web Silverlight is a NET technology SilverLight 2.0 contains subset of NET Server & Services Desktop NET Browser Devices, Mobile Silverlight extends your NET Reach SilverLight vs Adobe Flash • Flash is born in 1996, already 13 years old Current version Adobe Flash CS4, version 10 Written in C++ • SilverLight ver 1.0 (2007), 2.0 (Oct 2008) years old Written in C++, C#, NET • Flash’s strong points: • Large market share (~85%) Many samples and source codes Friendly to web and graphics designer • Motion tween, time-line story board, vector graphics • Flash’s weak points: • ActionScript 3.0 is ECMA script, not powerful programming language Easy to learn but difficult to develop advanced application: data binding, algorithm, collections manipulation • Flash format is licensed • Hard to debug  • SilverLight’s strong and weak points: • See the page “Why SilverLight” SilverLight vs JavaScript, AJAX • JavaScript is a script language to manipulate HTML elements • SilverLight 1.0 use JavaScript as programming language • SilverLight 2.0 can invoke a JavaScript function, a JavaScript can invoke function in SilverLight See demo later • SilverLight make asynchronous request~ AJAX calling • JavaScript can interact with every DOM elements in web browser • SilverLight also interact with DOM See section “Browser Integration, JavaScript interaction” • Some good JavaScript frameworks: • Jquery • Mootools • Notes: In Javascript, we can use Canvas object to draw vector graphics See more at https://developer.mozilla.org/En/Drawing_Graphics_with_Canvas Silverlight and WPF • Silverlight is a subset of WPF • Plus a few extra web features and its own codecs • Reuse strategy • Same skills • Same tools • Same XAML and UI • Silverlight code should run on WPF with minor changes • Some cool features of WPF are not yet implemented in SilverLight • 3D support • Animation along curve path • Applying template SilverLight + WPF vs Adobe AIR vs JavaFX • Since Adobe AIR and JavaFX are designed to develop Rich Internet Application on desktop, browser and mobile, WPF and SilverLight are teamed up in comparison • online surveys from Oct 2008 to Feb 2009: • 70-85% Vietnamese developers are familiar with Visual Studio, C# or VB.net • 35% Visual Studio 2005, 28% Visual Studio 2008 16% older version Visual Studio • 80% of applications are Line of Business, RDBMS centric • 90-98% VN enterprises are using XP, Vista, Windows in client PCs Why SilverLight ? • SilverLight’s strong points: • Friendly to NET programmers Visual Studio, Express Blend • XAML is cool It is XML, it can be easily generated Soon many 3rd tools will appear • Rapidly and continuously evolve with WPF Initially, its code name was WPF/e ~ WPF everywhere • Future: will be integrated into MS Office and other products • Strong 3rd parties community: ComponentOne, Infrasgistic, Telerik, • Suitable for Line of Business Applications • SilverLight ’s weak points: • Not yet support motion tween, and Animation along curve path • Not support 3D • Don’t be panic, SilverLight 3.0 to be announced in March 18th 2009 SilverLight, Flash, JavaScript usage in Hanoi, Vietnam (100 samples) Web technologies usage: ASP.net 2.0 34% ASP.net 3.5 23% SharePoint 12% PHP 13% Ruby On Rails 1% Java 5% Other 12% Web client technologies usage: Flash 33% JavaScript 22% SilverLight 2.0 13% SilverLight 1.0 4% Other 14% Programming Languages: C# 40% JavaScript 33% VB.net 19% ActionScript 9% How Flash is used in Vietnam: Use tool to generate ready made effect 38% Use template in the Internet and modify 36% Copy all 7% Self coding 19% Demo of 3rd parties • http:// www.componentone.com/SuperProducts/StudioSilverlight/Live+Exampl es/ • http://labs.infragistics.com/silverlight/lobsamples/ • http://devexpress.com/Downloads/NET/OnlineDemos.xml • http://www.netikatech.com/ • http://www.vectorlight.net/ Networking Networking • Asynchronous HTTP requests • GET/POST • Access to most headers, cookies, • Uses browser networking stack • Caching, authentication, proxy , compression Sockets • TCP only • Asynchronous API • No explicit bind and no listen/accept support • Restricted ports ( 4502-4534) • For Beta1, site of origin only, cross-domain for RTW void Connect(AddressFamily family) { SocketAsyncEventArgs connectArgs = new SocketAsyncEventArgs(); connectArgs.RemoteEndPoint = new DnsEndPoint( Application.Current.Host.Source.Host, 4502); connectArgs.Completed += new EventHandler(OnConnectCompleted); socket = new Socket(family, SocketType.Stream, ProtocolType.Tcp); if (!socket.ConnectAsync(connectArgs)) OnConnectCompleted(socket, connectArgs); } Byte-range Seeking Support • Enables seeking to non-downloaded portions of a file stored on *any* HTTP 1.1-enabled web server • Win-win for content distributors and viewers • Distributors save on bandwidth on non-viewed parts of media • Viewers get smaller latencies when seeking • When Seek is called on the MediaElement • New byte-range request is made, if needed; • Silverlight keeps track of downloaded portions of the file; • Playback continues from new position • Supported almost everywhere WebClient • Easy to use, events-based async • Download string, stream • Progress information webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadCompleted); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged); webClient.DownloadStringAsync("http://www.data.com/data.xml"); void DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { Stream stream = e.Result; // Use stream } Demo Prosise/VideoOverlay HttpWebRequest/Response ~ AJAX • Primary API for HTTP/HTTPS • Greater control (GET & POST, headers, etc) private void MakeAsyncRequest() { HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://foo.com/api?token=89"); IAsyncResult asyncResult = request.BeginGetResponse( new AsyncCallback(ResponseCallback), request); } private void ResponseCallback(IAsyncResult ar) { HttpWebRequest request = ar.AsyncState as HttpWebRequest; WebResponse response = request.EndGetResponse(ar); Stream responseStream = response.GetResponseStream(); // Use stream } Cross-domain support • formats: • Flash policy file • Silverlight policy file

Ngày đăng: 13/12/2013, 01:15

TỪ KHÓA LIÊN QUAN

w