inmeta crayon as

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

Upload: arwen

Post on 24-Feb-2016

55 views

Category:

Documents


1 download

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

Page 1: Inmeta Crayon AS

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

Page 2: Inmeta Crayon AS

.NET Code

• Resx – filetype• Codegen Resources.designer.cs• Translation is convention based on filename,

Resources.<cultureName>.resx for translated resources• Default resource file in project properties.

Page 3: Inmeta Crayon AS

.NET Deployment

• Default resources.resx embedded in assembly.• Translated resources compiled into satellite assemblies

<cultureName>\<assembly>.resources.dll

Page 4: Inmeta Crayon AS

.NET

• DEMO

Page 5: Inmeta Crayon AS

WinRT Code

• New filetype .resw (same XML specification as resx)• No codegen, no default resource file• Convention based on file structure and files must have

identical filename.

Page 6: Inmeta Crayon AS

WinRT Compile

• Resw files is compiled into pri files by makepri.exe • Resources per project is compiled into <AssemblyName>.pri

Page 7: Inmeta Crayon AS

WinRT Deploy

Application• ALL language resources for application and libraries is

merged into a common tree (ResourceMap) and placed in resources.pri

• Resouces.pri must be deployed with your application

Page 8: Inmeta Crayon AS

Package 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.

Page 9: Inmeta Crayon AS

Load resources by ResourceLoader

• Application var rl = new ResourceLoader(); // default is “Resources” var stringVal = rl.GetString(<resourceName>);

• In an assembly var rl = new ResourceLoader("<AssemblyName>/Resources"); var stringVal = rl.GetString(<resourceName>);

• In a custom resource tree var rl = new ResourceLoader("<AssemblyName>//<Custom>"); var stringVal = rl.GetString(<resourceName>);

Page 10: Inmeta Crayon AS

Load resources by ResourceManager

• Windows.ApplicationModel.Resources.Core.ResourceManager• Requires more knowledge of the ResourceMap• Can retrive other types than string (=> StorageFile)• Can enumerate through/inspect all possible values

Page 11: Inmeta Crayon AS

WinRT - resources

• DEMO

Page 12: Inmeta Crayon AS

Image localization in Xaml

• If 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 folder

• And referencing the image in XAML is the normal relative URL without the culture code as shown in the following example.

Page 13: Inmeta Crayon AS

Image localization in code

• Using 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.

Page 14: Inmeta Crayon AS

Contrast and scale conventions

• High 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)

Page 15: Inmeta Crayon AS

Image scaling conventions

Use 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

Page 16: Inmeta Crayon AS

WinRT – image localization

• DEMO

Page 17: Inmeta Crayon AS

.NET and WinRT side by side

• So you have business / framework code in NET that you want to share into WinRT projects?

• Code can be linked into other project• Then there’s the case of resource strings

• Copy .resx files to new folder structure and name .resw• Create 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

Page 18: Inmeta Crayon AS

NET and winRT

• Makepri.exe has better checks than .NET compiler• Allowed languages (not supprort for legacy languages)• Invalid language name causes duplicate name causes errors• Resources in localized languages only causes warnings

• Start wth default language and add languages one by one.

Page 19: Inmeta Crayon AS

Net and WinRT

• DEMO

Page 20: Inmeta Crayon AS

Summary

• Understand resources and assets is handled in WinRT• Understand how to localize and style your Windows Store App• Understand ResourceMAP and PRI files.• Share code between .NET and WinRT.

Page 22: Inmeta Crayon AS

Resources

• ResEx - the composite, translation friendly .NET Resource editor.

• ILSpy - the open-source .NET assembly browser and decompiler.

Page 23: Inmeta Crayon AS

Thank you

• Mail: [email protected]• Blog: http://jonnybekkum.wordpress.com