How to retrieve a localized text/caption for standard push button? - windows

I want to add "Yes" and "No" buttons to my window. It's a bit similar to standard MessageBox, so I would like to use localized strings in these buttons. I.e. "Yes" and "No" should be written in OS's current language.
How can I do this?

No easy answer. You can try getting a translation glossary from Microsoft, or use thier online translation tool (more on both here).
Other "hacks" involve reading the string resources of user32.dll - but this will only work for localized version of the OS (i.e., not if you're using MUI, which sits on top an EN-US version).
I like the online translation or glossary approach as it proofs the app from any future API changes.

Related

MvvmCross localization: switch at runtime

Is there a way to change the current language to another one at runtime ?
For example: be able to switch when a button is clicked or when starting the app, get the user language and switch.
How to tell the plugin to check the user language at startup ?
Thanks in advance for your help.
Is there a way to change the current language to another one at runtime ?
yes, call builder.LoadResources(whichLanguage) on your MvxTextProviderBuilder.cs
For example: be able to switch when a button is clicked
The UI framework isn't really setup to perform switching live. When you switch between languages then the new JSON resource files will all be loaded OK - but existing displayed text will not be updated. This is a bit like most mobile operating systems - if you want to switch language you often need to reboot!
If you wanted to add dynamic switching then you'd have to find a way to tell the UI to completely refresh all text - I suspect this wouldn't be hard to do, but it might require some manual coding on every page/View which has already been created and displayed :/
or when starting the app, get the user language and switch.
This is a much more straight-forward way to do i18n. It's normally OK because MvvmCross mainly targets phones - and phones are normally single user devices which don't switch languages very often.
You could, for example, use some variable (e.g. System.Globalization.CultureInfo.CurrentUICulture) to work out the best language to display.
Or you detect on load whether the user has picked a language yet - if they have, then show HomeViewModel - if they haven't then show a LanguagePickerViewModel - this is what we did in StarWarsKinect - the StartNavigationObject is a perfect place for this sort of logic!
How to tell the plugin to check the user language at startup ?
Currently, you'll have to code this logic as part of your app startup.
I'd definitely be open to providing an improved plugin on this - perhaps with a demo!
If you are looking at i18n, then one alternative implementation to consider is Vernacular - the team at Rdio have a very good offering for Mono and MS platforms - https://github.com/rdio/vernacular

How to approach implementing a layout editor using Cocoa

I want to build an OS X application, in which one of the requirements is for the user to be able to generate PDF output according to a layout that they, the user, will create. Typical items on the page would be things like a corporate logo (a JPEG or PNG), an address (a block of text) and a narrative (another block of text).
I'd like the user to be able to move and resize the items using the mouse to drag handles around on-screen.
Is there an Interface Builder object that will let me do that, or some third-party library that exists for this purpose?
Try GCDrawKit if you're looking for a drop-in solution. It's still in beta (and has been for ages) but you might find it useful.
You seem to be looking for an all-encompassing, self-contained "Pages" control or some sort of reporting suite. That's asking a bit much.
There is nothing in the Cocoa frameworks that gives you this. Unfortunately, there's no Cocoa equivalent of Crystal Reports either. You'll have to roll your own.
I suggest using standard CSS / HTML templates with WebKit. The only drawback is WebKit doesn't yet support CSS pagination, so there's no concept of "8.5"x11" page 1...15" but it's the closest you'll come without writing your own Pages application (NOT an easy project by any stretch of the imagination).

Windows Visual Themes: Gallery of Parts and States?

Microsoft Windows lets programmers draw GUI elements using the look and feel of the current theme using functions like DrawThemeBackground and DrawThemeText. The elements are specified by Class, Part, and State, as described at the Parts and States page at MSDN.
Unfortunately, the page is not very informative (at all!). So the question is: is there somewhere a reference of all these parts and states, preferably with images of the elements (in the default Windows Vista/7 theme)?
I have created a small Windows application, programmed with the table at Parts and States. This application lets the programmer browse and explore all parts and states, using the current OS theme.
(High-Res)
It can be downloaded at
https://privat.rejbrand.se/UxExplore.exe
The (Delphi, Win32 API) source, which is too long to be posted here (due to hundreds of constants) is found at
https://privat.rejbrand.se/UxExplore.zip
https://privat.rejbrand.se/UxExploreMain.html
https://privat.rejbrand.se/UxExploreConsts.html
You're looking for this.
Mike Lische, who wrote the first Theme support for Delphi (which was later absorbed by Borland) has a very good Theme Explorer demo application:
It's not been updated to support new Windows 7 common controls, but its parts/states explorer is very pretty.
And if i may say, Andreas, a design you might want to copy for yours :)
Much more comprehensive theme explorer: mCtrl Theme Explorer

Using Message Boxes in Windows 7 style

After reading the MSDN article about proper user interface here:
http://msdn.microsoft.com/en-us/library/aa974176.aspx
I want to modify the message boxes I use in my applications to reflect those guidelines (for example, have the Main Instructions in a larger font, better named Buttons, etc...).
My question is, is there an API that allows you to easily build those kind of message boxes (a la user32\MessageBox()), or do you actually have to build your own message boxes which follow the guidelines?
Mostly you just get that (try it and see!) when you use MessageBox or whatever wrapper applies in the language you're using (you didn't say.) There is also Task Based Dialog which goes well beyond the yes/no/cancel world of message box. There is a Win32 API for that if you're in C++, and the Windows API Code Pack has a wrapper if you're in C# or VB.NET.

Is there a catalog of all UI widgets and their names, platforms and languages?

I was looking at the Firefox Add-ons Manager UI (pictured below) and really liked the expandable list used to show settings or properties for each add-on.
Firefox Add-ons Manager http://uploads.tech-buzz.net/Firefox3Beta3ComingonMonday_859/get_addons.png
I liked it enough to want to include something similar in one of my applications. The problem is, I don't know, exactly what the control is called (it doesn't seem to be "expandable list"), nor do I know if there is an implementation available for use in my own application (so I wouldn't have to reinvent the wheel.)
This isn't the first time that I've seen some cool piece of UI and wanted to incorporate it into something I'm working on, but have had no idea if I would have to design it from scratch. So I generally end up reworking my UI to use standard UI widgets to save time.
This got me thinking, is there some place that has a catalog of a bunch of UI widgets with names and what platforms/languages they are implemented for/in?
UPDATE
Turns out this control is called a Rich List Box, and it seems to only be implemented in XUL.
To answer your question, no, there isn't a universal catalog anywhere, though MSDN is as good a place as any to find definitions of most common UI elements.
The specific widget you ask about is generally called an accordian (wikipedia)

Resources