How To Achieve World(-Ready) Domination In Silverlight Guy Smith-Ferrier Guy Smith-Ferrier Blog:

Slides:



Advertisements
Similar presentations
Unit 02. ASP.NET Introduction HTML & Server controls Postbacks Page Lifecycle.
Advertisements

ASP.NET Ajax Supplementary Tutorial. Why Use ASP.NET AJAX? - I ASP.NET AJAX enables you to build rich Web applications that have many advantages over.
Overview and Demonstration of declarative workflows in SharePoint using Microsoft SharePoint Designer 2007 Kevin Hughes MCT, MCITP, MCSA, MCTS, MCP, Network+,
Mobile Applications Development. Your next job: Mobile app developer? pp_developer_?taxonomyId=11&pageNumber=1.
ACT! “Web” Plugins ACC Webinar (Part 1of 2) Brian Mowka and Jamie Aurand December 2010.
.NET 3.5 SP1 New features Enhancements Visual Studio 2008 SP1 New features Enhancements Additional features/enhancements.
Master Pages, User Controls, Site Maps, Localization Svetlin Nakov Telerik Corporation
Building International Applications with Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corporation.
Developing Arabic Applications with Visual Studio 2005 Dina Lasheen Program Manager – Developer Division.
PRODUCT TRAINING Installation.
Win8 on Intel Programming Course Desktop : Sensors Cédric Andreolli Intel Software
Presentation Heading – font Arial
Building Localized Applications with Microsoft.NET Framework and Visual Studio.NET Achim Ruopp International Program Manager Microsoft Corp.
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Web Design with Cascading Style Sheet Lan Vu. Overview Introduction to CSS Designing CSS Using Visual Studio to create CSS Using template for web design.
Programering af mobile enheder Windows Phone Rss Feed.
11 Getting Started with ASP.NET Beginning ASP.NET 4.0 in C# 2010 Chapters 5 and 6.
Dinko Jakovljević Microsoft Student Partner | BambooLab
2 Internationalizing WPF And Silverlight Applications Guy Smith-Ferrier Technical Architect, Capella Software Ltd.
Web-Based Applications
Microsoft Visual Basic 2012 CHAPTER TWELVE (ENRICHMENT CHAPTER) Windows Store Apps.
Introduction to.Net and ASP.Net Course Introduction Build Your Own ASP.Net Website: Chapter 1 Microsoft ASP.Net Walkthrough: Creating a Basic Web Forms.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Introduction to Silverlight. Slide 2 What is Silverlight? It’s part of a Microsoft Web platform called Rich Internet Applications (RIA) There is a service.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
Esri UC2013. Technical Workshop. Technical Workshop 2013 Esri International User Conference July 8–12, 2013 | San Diego, California Creating.NET Add-ins.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Introduction to Mobile Programming. Slide 2 Overview Fundamentally, it all works the same way You get the SDK for the device (Droid, Windows, Apple) You.
IT 211 Project Integration and Deployment Lab #11.
An Introduction to Silverlight Matt Harrington Developer Evangelist, Microsoft October 20, 2011.
Creating Web Applications Using ASP.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
The Company….  The Market Leader in Globalization Technology –Pioneers in visual translation environments –Solutions for major platforms & programming.
Virtual techdays INDIA │ Nov 2010 Developing Office Biz Application using WPF on Windows 7 Sarang Datye │ Sr. Consultant, Microsoft Sridhar Poduri.
Silverlight Hitesh Trivedi Computer Science B.Tech A-Sec J.I.E.T.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
ASP.NET.. ASP.NET Environment ASP.NET is Microsoft's programming framework that enables the development of Web applications and services. It is an easy.
Scalable Game Development William Roberts Senior Game Engineer
Microsoft Visual Basic 2005 CHAPTER 7 Creating Web Applications.
Expression Web 3... now with TFS!. What is Expression Web 3? Professional web design and development tool Create standards-based Web sites faster & easier.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files.
10 – 12 APRIL 2005 Riyadh, Saudi Arabia. Building multi-lingual ASP.Net application that handle western languages and Arabic with a single code base.
DEV382 Building International Applications with the.NET Framework Christian Nagel Microsoft Regional Director Global Knowledge.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
New Features Overview. Agenda Silverlight - Intro Silverlight 3 New Features Overview with Demos, Demos and Demos… RIA Services Overview Demos, Demos,
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
C# GUI - Basics. Objectives.NET supports two types: WinForms, traditional, desktop GUI apps. WebForms – newer, for Web apps. Visual Studio.NET supports.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
All information's of PLINQO in this Document, I got it from: So, you could visit the link above to research.
SOP PENGGUNAAN JUPEM2U.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files 8/10/ :35 PM.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Working in a Mobile App Development Environment Lesson 2.
7/23/2016 CSC 325 Advanced Programming Techniques Localization Slide #1 1 Localization Mikhail Brikman.
Blended HTML and CSS Fundamentals 3 rd EDITION Tutorial 1 Using HTML to Create Web Pages.
Metropolia 2013 C# programming and .NET framework
Globalization support in ASP.NET
Introduction to Silverlight
Module 1: Getting Started
VISUAL BASIC.
.NET and .NET Core 7. XAML Pan Wuming 2017.
Microsoft PowerPoint 2007 – Unit 2
ASP.NET.
6. WinForms 2003 C# GUI - Basics.
How to organize and document your classes
Presentation transcript:

How To Achieve World(-Ready) Domination In Silverlight Guy Smith-Ferrier Guy Smith-Ferrier Blog: Blog:

 Author of.NET Internationalization  Visit to download the complete source code  The.NET Developer Network   Free user group for.NET developers, architects and IT Pros based in Bristol  DDD South West   Taunton, Saturday 23 rd May 2009

 Localizing Silverlight Using.resx Files  Downloading Localized Resources On Demand  Silverlight Installation User Experience  Silverlight UI Localization  Silverlight Fonts and Font Management  Silverlight Globalization

 Using Visual Studio 2008 create a new Silverlight app  Add a button  Add a Resources File (In Solution Explorer, right click WpfApplication1, select Add | New Item, select Resources File) and call it PageResources.resx  Add a new resource entry called "Button_1" with a value of "Hello World"  Set the Access Modifier to Public (using the combo box)  Change the constructor to public in PageResources.Designer.cs

 In Page.xaml add a "Resources" namespace, a static resource and change the button to use a static resource <UserControl x:Class="SilverlightApplication1.Page" xmlns=" xmlns=" xmlns:x=" xmlns:x=" xmlns:Resources="clr-namespace:SilverlightApplication1" xmlns:Resources="clr-namespace:SilverlightApplication1" Width="400" Height="300"> Width="400" Height="300"> </UserControl>

 In Visual Studio copy PageResources.resx to PageResources.fr-FR.resx  Change the "Button_1" resource value to "Bonjour Le Monde"  Open SilverlightApplication1.csproj using NotePad, locate the SupportedCultures element and set it to fr-FR <SupportedCultures>fr-FR</SupportedCultures>

 Open SilverlightApplication1TestPage.aspx and add InitParameters to the Silverlight control

 In App.xaml.cs change the Application_Startup method  Run the application private void Application_Startup( object sender, StartupEventArgs e) object sender, StartupEventArgs e){ string cultureName = e.InitParams["UICulture"].ToString(); string cultureName = e.InitParams["UICulture"].ToString(); if (! String.IsNullOrEmpty(cultureName)) if (! String.IsNullOrEmpty(cultureName)) Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName); new CultureInfo(cultureName); this.RootVisual = new Page(); this.RootVisual = new Page();}

 1. Use a different Strongly Typed Resource Class code generator  PublicResourceCodeGenerator  oviderCodeGenerators.zip  ResXFileCodeGeneratorEx 

 2. Write a wrapper for the Strongly Typed Resource Class and bind to the wrapper <UserControl.Resources> </UserControl.Resources> public class PublicPageResources { private static PageResources resources = new PageResources(); private static PageResources resources = new PageResources(); public PageResources { get { return resources; } } public PageResources { get { return resources; } }}

 Add the following directives to the ASP.NET Page attribute:-  Add the following script to the ASP.NET page:- UICulture="auto" Culture="auto" protected void Page_Load(object sender, EventArgs e) protected void Page_Load(object sender, EventArgs e) { Xaml1.InitParameters = "UICulture=" + System. Xaml1.InitParameters = "UICulture=" + System. Threading.Thread.CurrentThread.CurrentUICulture.Name; Threading.Thread.CurrentThread.CurrentUICulture.Name; }</script>

 Delete the InitParameters from the Silverlight control  Add a Spanish(Spain).resx file for PageResources  Change the SupportedCultures in the.csproj file <SupportedCultures>fr-FR,es-ES</SupportedCultures>

 Copy bin\debug\AppManifest.xaml to bin\debug\fr-FR  Ensure that the only AssemblyPart is:-  Create a ZIP file, fr-FR.zip, containing:-  AppManifest.xaml with no path information  SilverlightApplication1.resources.dll with fr-FR path  Rename fr-FR.zip to fr-FR.xap  Copy fr-FR.xap to SilverlightApplication1.Web\ClientBin <AssemblyPart Source= "fr-FR/SilverlightApplication1.resources.dll" /> "fr-FR/SilverlightApplication1.resources.dll" />

 Download the XapResourcePackager task from  Create an msbuild project to use the XapResourcePackager task:- <UsingTask TaskName="XapResourcePackager" AssemblyFile="Silverlight.Build.Tasks.dll"/> AssemblyFile="Silverlight.Build.Tasks.dll"/> <XapResourcePackager <XapResourcePackager XapResourceFilename="$(XapResourceFilename)" XapResourceFilename="$(XapResourceFilename)" AssemblyName="$(AssemblyName)" AssemblyName="$(AssemblyName)" XapResourceFileCultureName="$(XapResourceFileCultureName)"/> XapResourceFileCultureName="$(XapResourceFileCultureName)"/></Target>

 Empty the SupportedCultures in the.csproj file  Change the Application_Startup event to:- <SupportedCultures></SupportedCultures> private void Application_Startup(object sender, StartupEventArgs e) { string cultureName = e.InitParams["UICulture"]; string cultureName = e.InitParams["UICulture"]; if (!String.IsNullOrEmpty(cultureName)) if (!String.IsNullOrEmpty(cultureName)) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName); Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName); XapResourceLoader.Load(); XapResourceLoader.Load(); } else else this.RootVisual = new Page(); this.RootVisual = new Page();}

 Add the following lines to the App constructor  Add the following method to the App class XapResourceLoader.AssemblyFilename = App.Current.GetType().Assembly.FullName.Split(',')[0]; App.Current.GetType().Assembly.FullName.Split(',')[0]; XapResourceLoader.OpenReadCompleted += new OpenReadCompletedEventHandler( new OpenReadCompletedEventHandler( XapResourceLoader_OpenReadCompleted); XapResourceLoader_OpenReadCompleted); private void XapResourceLoader_OpenReadCompleted( object sender, OpenReadCompletedEventArgs e) object sender, OpenReadCompletedEventArgs e){ this.RootVisual = new Page(); this.RootVisual = new Page();}

public static event OpenReadCompletedEventHandler OpenReadCompleted; public static string AssemblyFilename { get; set; } public static void Load() { WebClient webClient = new WebClient(); WebClient webClient = new WebClient(); webClient.OpenReadCompleted += new webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(InternalOpenReadCompleted); OpenReadCompletedEventHandler(InternalOpenReadCompleted); if (OpenReadCompleted != null) if (OpenReadCompleted != null) { webClient.OpenReadCompleted += OpenReadCompleted; webClient.OpenReadCompleted += OpenReadCompleted; } Uri cultureUri = new Uri(String.Format("{0}.xap", Uri cultureUri = new Uri(String.Format("{0}.xap", Thread.CurrentThread.CurrentUICulture.Name), Thread.CurrentThread.CurrentUICulture.Name), UriKind.Relative); UriKind.Relative); webClient.OpenReadAsync(cultureUri); webClient.OpenReadAsync(cultureUri);}

private static void InternalOpenReadCompleted( object sender, OpenReadCompletedEventArgs e) object sender, OpenReadCompletedEventArgs e){ if (e.Error == null && !e.Cancelled) if (e.Error == null && !e.Cancelled) { Stream xapStream = e.Result; Stream xapStream = e.Result; Uri resourcesAssemblyUri = Uri resourcesAssemblyUri = new Uri(GetResourcesAssemblyPath(), UriKind.Relative); new Uri(GetResourcesAssemblyPath(), UriKind.Relative); StreamResourceInfo xapStreamResourceInfo = StreamResourceInfo xapStreamResourceInfo = new StreamResourceInfo(xapStream, null); new StreamResourceInfo(xapStream, null); StreamResourceInfo resourcesAssemblyStreamResourceInfo = StreamResourceInfo resourcesAssemblyStreamResourceInfo = Application.GetResourceStream( Application.GetResourceStream( xapStreamResourceInfo, resourcesAssemblyUri); xapStreamResourceInfo, resourcesAssemblyUri); if (resourcesAssemblyStreamResourceInfo != null) if (resourcesAssemblyStreamResourceInfo != null) { AssemblyPart assemblyPart = new AssemblyPart(); AssemblyPart assemblyPart = new AssemblyPart(); assemblyPart.Load(resourcesAssemblyStreamResourceInfo.Stream); assemblyPart.Load(resourcesAssemblyStreamResourceInfo.Stream); } }}

private static string GetResourcesAssemblyPath() { // e.g. "fr-FR/SilverlightApplication1.resources.dll" // e.g. "fr-FR/SilverlightApplication1.resources.dll" return Thread.CurrentThread.CurrentUICulture.Name + "/" + return Thread.CurrentThread.CurrentUICulture.Name + "/" + AssemblyFilename + ".resources.dll"; AssemblyFilename + ".resources.dll";}

 The Silverlight install image is retrieved from  This reads the browser's HTTP accept language setting and returns an image for that culture  English  French  Spanish  Japanese

 The Silverlight add-in is installed using a Windows application  The Windows application uses the operating system's culture (e.g. en-US) to determine the localized resources to display  If you set your browser's language to a different language to your operating you will see a schizophrenic installation experience

 To save from having to uninstall and reinstall Silverlight to test the installation experience disable Silverlight:-  In Internet Explorer select Tools | Manage Add-ons | Enable or Disable Add-ons  Select Microsoft Silverlight and click on the Disable radio button

 Silverlight is a single runtime that includes all supported languages:-  English (en-US)  French (fr)  German (de)  Italian (it)  Japanese (jp)  Korean (ko)  Spanish (es)  Chinese Simplified (zh-Hans)  Chinese Traditional (zh-Hant)

 The Config dialog's UI is dictated by the operating system (only)  Defaults to English

 These dialogs' UIs are dictated by the operating system (only)

 The DatePicker and Calendar controls respect the Thread.CurrentCulture setting en-GBfr-FRnb-NOja-JP

UI ElementOriginControlled By.aspx/.ascx pages/controlsYour applicationCurrentUICulture (& CurrentCulture) Silverlight install imageMicrosoft's serverBrowser's HTTP ACCEPT LANGUAGE Silverlight install dialogsSilverlight install package OS's UI Culture Silverlight applicationYour applicationCurrentUICulture (& CurrentCulture) Silverlight config dialogSilverlight runtimeOS's UI Culture Silverlight file dialogsClient's operating system OS's UI Culture Silverlight controlsSilverlight runtimeCurrentUICulture (& CurrentCulture)

 Silverlight supports 9 fonts on all platforms

 If you use a font that is not in the list Silverlight asks the operating system for the font  The operating system uses Font Fallback to find the best match for unknown fonts  Lucida Sans Unicode on Windows Vista Ultimate  Lucida Sans Unicode on Windows XP SP2 (East Asian support not installed)

 Silverlight uses the "Portable User Interface" font by default  The "Portable User Interface" font is an alias for Lucida Grande

 Create a new Silverlight project  Add a folder called Fonts  Add a font, Oz.ttf, to the Fonts folder  Ensure that Build Action is set to Resource  Add a button to Page.xaml:- <Button FontFamily="Fonts/Oz.ttf#Australian" Content="Hello World"/> Content="Hello World"/>

 Delete the FontFamily from the Button control  Select Oz.ttf in the Fonts folder, set Build Action to None  Create a Fonts folder in the web project and add the font file to the folder  Add a click event with the following code:- private void Button_Click(object sender, RoutedEventArgs e) { WebClient webClient = new WebClient(); WebClient webClient = new WebClient(); webClient.OpenReadCompleted += new webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCompleted); OpenReadCompletedEventHandler(OpenReadCompleted); webClient.OpenReadAsync( webClient.OpenReadAsync( new Uri("/Fonts/Oz.ttf", UriKind.Relative)); new Uri("/Fonts/Oz.ttf", UriKind.Relative));}

 Add a TextBlock to the page  Add the following code:-  Only TextBlock and TextBox have a FontSource property private void OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) OpenReadCompletedEventArgs e){ this.TextBlock1.FontSource = new FontSource(e.Result); this.TextBlock1.FontSource = new FontSource(e.Result); this.TextBlock1.FontFamily = new FontFamily("Australian"); this.TextBlock1.FontFamily = new FontFamily("Australian"); this.TextBlock1.Text = "The font has landed"; this.TextBlock1.Text = "The font has landed";}

 Open a Silverlight project in Blend 2 or above  Add a font  Tools | Font Manager  Select Mongolian Baiti (349K)  Check the "Auto fill" checkbox  Add a TextBlock, set the Font Family to the new font and set the Content to "Hello World"  Build the project

 Open the subsetted font (obj\Debug\Fonts\monbaiti0.subset.ttf, 101K)

 When you add a Font to your project Blend does the following:-  Adds "SubsetFont.targets" to the project root folder  Adds "SubsetFontTask.dll" to the project root folder  Adds the following line to the.csproj file:-

 Comparison between the.NET Framework and the Silverlight Framework:-  ilverlightGlobalizationClassComparison.pdf  No support for locale IDs (LCIDs)  No lunisolar calendars  No Windows-specific features  CultureInfo.ThreeLetterWindowsLanguageName  RegionInfo.GeoId  No code page support (Unicode only)

 The CultureAndRegionInfoBuilder class is not supported in Silverlight  Silverlight does read custom cultures if they are present on the client's operating system

 No built in support in Silverlight 2 and 3  FrameworkElement.FlowDirection is not supported  Expected for Silverlight 4  Almost all workarounds require the creation of a separate RTL version of the Silverlight application

 A library of Silverlight RTL controls  deplex.com

 Static markup extension is not supported  Silverlight's MarkupExtension is not public  See "Differences Between WPF and Silverlight" 

 Culture data varies across operating systems  Sort, casing and comparison results vary across operating systems

 Localization is possible through.resx files  Bind to the strongly typed resource classes  If you have more than one culture you should consider "download on demand"  Avoiding a schizophrenic user interface can be a challenge  Globalization support is dependent upon the operating system