inmeta crayon as

of 23/23
Inmeta Crayon AS Resource management in WinRT Jonny Bekkum .NET Architect and Developer at Inmeta Core developer CSLA.NET

Post on 24-Feb-2016

50 views

Category:

Documents

1 download

Embed Size (px)

DESCRIPTION

Inmeta Crayon AS. Resource management in WinRT Jonny Bekkum .NET Architect and Developer at Inmeta Core developer CSLA.NET. .NET Code. Resx – filetype Codegen Resources.designer.cs Translation is convention based on filename, Resources..resx for translated resources - PowerPoint PPT Presentation

TRANSCRIPT

PowerPoint Presentation

Inmeta Crayon ASResource management in WinRTJonny Bekkum.NET Architect and Developer at InmetaCore developer CSLA.NET

1.NET CodeResx filetypeCodegen Resources.designer.csTranslation is convention based on filename, Resources..resx for translated resourcesDefault resource file in project properties.

2.NET DeploymentDefault resources.resx embedded in assembly.Translated resources compiled into satellite assemblies \.resources.dll

3.NET DEMO.NET med Resource Files* default resource* filname convention* codegen designer.cs p hver hoved resourceILSPY* default resource in assembly* satellite assembly per assembly per language * all must be distributed with app 4WinRT CodeNew filetype .resw (same XML specification as resx)No codegen, no default resource fileConvention based on file structure and files must have identical filename.

5WinRT CompileResw files is compiled into pri files by makepri.exe Resources per project is compiled into .pri

6WinRT DeployApplication ALL language resources for application and libraries is merged into a common tree (ResourceMap) and placed in resources.priResouces.pri must be deployed with your application

7Package Resource Index (.pri)The PRI contains actual string resources, and an indexed set of file paths that refer to the files in the package.Packages typically contain a single PRI file named resources.pri.PRI files are data-only and are not of the PE format. They are specifically designed to be data-only as the resource format for Windows. They replace resources contained within DLLs in the Win32 app model.Use makepri.exe /dump to see the content of the .pri file.8Load resources by ResourceLoaderApplication var rl = new ResourceLoader(); // default is Resources var stringVal = rl.GetString();

In an assembly var rl = new ResourceLoader("/Resources"); var stringVal = rl.GetString();

In a custom resource tree var rl = new ResourceLoader("//"); var stringVal = rl.GetString();9Load resources by ResourceManagerWindows.ApplicationModel.Resources.Core.ResourceManagerRequires more knowledge of the ResourceMapCan retrive other types than string (=> StorageFile)Can enumerate through/inspect all possible values

Use the ms-resource spec10WinRT - resourcesDEMORT app with resource strings * no codegen * no default resources in assembly* show Certification languages vs Allowable languages* compiler put resources in PRI files per assembly (used for UnitTests)* aggregates all resources into resources.pri and a common ResourceMap. * pri files is not assemblies - optimized for data storage* Override language preference sequence. * Respond to language preference changes.11Image localization in XamlIf you are referencing the image from XAML, localizing an image is as simple as creating folders for the locals you need to support and put localized versions of the image file into the local folderAnd referencing the image in XAML is the normal relative URL without the culture code as shown in the following example.

12Image localization in codeUsing a relative URI to reference package content is not permitted in Metro XAML apps. Instead you have to use an absolute URI using the ms-appx scheme.

13Contrast and scale conventionsHigh Contrast : contrast-black contrast-white

Pixel Density: scale-80 (start screen only) scale-100 (normal DPI, no scaling)scale-140 (1920*1080, minimum DPI 174)scale-180 (2560*1440, minimum DPI 240)

100% when no scaling is applied140% for 1920 x 1080 devices that have a minimum DPI of 174 180% for 2560 x 1440 devices that have a minimum DPI of 240 NoteFor the Logo and WideLogo images specified in the manifest, you can specify an additional 80% scale percentage. For best results, provide four scales of these images.

14Image scaling conventionsUse scalable vector graphics - SVGOr use resource loading for bitmap images:Option #1 - File naming convention: \test.scale-100.jpg \test.scale-140.jpg \test.scale-180.jpg Option #2 - Folder naming convention: \scale-100\test.jpg \scale-140\test.jpg \scale-180\test.jpg 15WinRT image localizationDEMO* Urn: prefix allows you to create "standard styles" or different look per language without changes to Xaml code * Image localization* Image localization in code (ms-appx:)* High Contrast : contrast-black and contrast-white* Pixel Density: scale-80 (start screen only), scale-100 (normal DPI), scale-140 (1920*1080, minimum DPI 174), scale-180 (2560*1440, minimum DPI 240)

* makepri /dump * Qualifiers header include Languages, Contrasts, and Scales* Typically there are two main ResourceMapSubtree in a ResourceMap, one is named Files for images, xaml, and media files. The other is named Resources for string resources.16.NET and WinRT side by sideSo you have business / framework code in NET that you want to share into WinRT projects?Code can be linked into other projectThen theres the case of resource strings

Copy .resx files to new folder structure and name .reswCreate your own Resources.Designer.cs so you can use resource strings as in .NET. Use ResEx to update your resource files.Only one master set of resx files

17NET and winRTMakepri.exe has better checks than .NET compilerAllowed languages (not supprort for legacy languages)Invalid language name causes duplicate name causes errorsResources in localized languages only causes warningsStart wth default language and add languages one by one. 18Net and WinRTDEMONET library in RT * link files * add compiler directives / add missing classes * add Resources.Designer.cs as manual static class* Use ResourceLoader with "/Resources" parameter* Show invalid culture name - error* Show localized resource only - warning19SummaryUnderstand resources and assets is handled in WinRTUnderstand how to localize and style your Windows Store AppUnderstand ResourceMAP and PRI files.Share code between .NET and WinRT.

20Resources MSDNGuidelines for scaling to pixel densityResource Management SystemChoosing your languages

Windows 8 Recipes Building Global Windows 8 Metro XAML Apps Part 1Building Global Windows 8 Metro XAML Apps Part 2 Building Global Windows 8 Metro XAML Apps Part 3ResourcesResEx - the composite, translation friendly .NET Resource editor.ILSpy - the open-source .NET assembly browser and decompiler.Thank you Mail: [email protected]: http://jonnybekkum.wordpress.com