I'm developping a little application in WPF and I want to localize my resources.
I've always used resources files (.resx), but I heard about BAML that was suppose to change the way of manage localization in a WPF application.
I made my research and I found a way to translate my application using those files.
I wrote a blog post to show how I did it over here (french only, sorry). You can see references at the end of the post for english links.
The fact is, I really dislike this way of managing resources. I think it's way more complicated and I don't see the pros of using this method.
Am I wrong or did I misunderstand something about BAML ?
Thanks.
I think you've got a fairly good grasp on the concept, and yes, it is too complicated.
BAML is just compiled XAML. You're using an external tool to extract the resource, make changes, and embed your resources back. It's definately not streamlined, and hopefully this process is made easier in the future.
Even on the documentation of the process, you'll notice at the bottom someone has recommended using .resx instead of this process. If this is already a method you're using for localization, you probably won't find much advantage in taking the LocBaml route.
Related
I am trying to come up with the best way to localize an asp net mvc website dynamicly. As in the administrator of the website should be able to change any string, in any language, at any time without recompiling. I was beginning to think that using SQL would be a good idea, but that would seriously take a hit at performance.
My other idea was to store localization in xml files, but then read from them as needed. However, I dont remotely know where to begin. I have seen some guides on how to do this with resource files, but those are compiled and not editable on the fly.
I think this post may be useful for you
Although I've not used it personally take a look at this by Rick Strahl (A Microsoft MVP) http://www.west-wind.com/weblog/posts/2009/Apr/01/Updated-WestwindGlobalization-Data-Driven-Resource-Provider-for-ASPNET it may be a good fit for what you require.
It is available on NuGet here http://nuget.org/packages/Westwind.Globalization .
Also worth noting is this page covering support for MVC http://www.west-wind.com/westwindwebtoolkit/Docs/index.htm?page=_2r1166lmq.htm
I am trying to port an existing C#-WPF-Project as an iPad-App.
As far as I found out by now, the best way to go would be to use MonoTouch and reuse as much C#-Logic as possible.
As the original project is written with WPF for an actual TabletPC, my question is, if there is any way, to reuse the WPF-sources or at least minimize the part I have to write again.
If there are any good alternatives to MonoTouch, I would appreciate tips too :)
UPDATE: Your comments were helpful, but are not 100% what I was looking for. MonoCross looks nice, but as far as I understand, it just "hides" the iOS-specific part. What I would really love, would be a way to reuse the handwritten "special" WPF-Controls. (Or at least minimize the work/time to transfer them.) This would be awesome.
UPDATE 2: Maybe I should add, that I would also accept some "complicated" three-step-technique. For example, is there a way to translate the XAML-WPF-files to HTML5 (or something equally powerful) and then use Titanium or PhoneGap? The Languages and Frameworks shouldn't be the big problem, I just try to find a way to reuse as much as possible :)
Please see this previous question which is related and may be of interest on creating cross-platform iOS, Android and WP7 applications.
In response to your question, no it is not possible to re-use WPF Guis on iPad, IPhone, Android. Only Windows Phone will support silverlight views. To workaround this you must use a Model View controller architecture (as iOS, Android won't support databinding via MVVM) on all three and create separate views for each architecture.
While this may sound laborious, please note that if you correctly architecture your application so that key business logic and presentation logic is inside the Controller (or services) layers then you can re-use a large proportion of your code. This is the same limitation as if you create cross-platform code to dual deploy to Silverlight and WPF on Windows. The Xaml files often have to be specific to each framework, however often *.cs user controls and viewmodels / code logic can be shared.
UPDATE: Following your Update(2) in question.
Yes, you can use a third party server to translate XAML-WPF-files to HTML5 - the ComponentArt Dashboard Server. This claims to translate WPF/Silverlight applications written using strict MVVM to HTML5/JS for portability across multiple devices. I can't vouch for how effective this is and I do know it is expensive, however if you are seriously stuck and want to port WPF -> HTML5 then it is worth investigating this.
Best regards,
Yes, I've already heard of http://www.codeproject.com/KB/audio-video/avifilewrapper.aspx
...but I just can't get it to work with ASP.NET
I've perused the source about a hundred times looking for anything that might suggest it's incompatible with .NET 3.5 or not going to work with my other frameworks. Everything seems Kosher.
Any ideas?
Thanks!
Do you know what exceptions are being thrown? The AviFileWrapper you mentioned I believe depends on libraries provided by the windows API, and those libraries might not be available in your server, especially for ASP applications.
If you need a solution badly enough, you might consider writing a simple library yourself. The AVI format might be simple enough to implement it yourself, given that you might not need sound or compression.
Here is some documentation I found.
www.alexander-noe.com/video/documentation/avi.pdf
Good luck.
I am tired of flickering of GUI and every possible control, milions of articles about double-buffering, ControlStyle flags and so on that don't even work; look at this examples:
How to prevent a Windows Forms TextBox from flickering on resize?
After reading this question, other on SO, and many articles on the web i think there are 2 options, write own controls, or use alternative to the winforms. So my question is: what are good alternatives that can be easily used with C# and .NET on Windows, and maybe even on Linux and Mac (but this is not necessary)? However if i missing something with all that windows mess, i will be glad if you correct me.
One important thing, altough flickering and other problems are annoying, they not prevent job getting done, so alternatives priority is to be fully functional, otherwise, it's better to stick with ancient winforms.
What about these alternatives?
WPF
GTK+
Qt
WPF, would be your answer to Windows Forms if you are on the .NET platform.
Have you seen this SO question? It might help you with the flickering problems.
I have never experienced flickering in my winform programs with VS2008 in C#.NET. However, if you want an alternative, you could always call the native WIN API functions. It is much more complicated than using winforms though, so you would probably regret it. You will have to write a LOT of code to populate and retrieve data from your controls.
The reason .NET was developed was to make programming easier (and to lock millions of programmers into the Microsoft platform). I am very happy with it. If you have invested the time to learn the .NET platform, I think you would be better off sticking with it. Each development system has its own peculiarities, and you may have more trouble than you would have with .NET, and it might be harder to find someone to help you when you have a problem.
If you are not prepared to consider using WPF, you could go for the native Qt with C# bindings but I think WPF is by far your best bet. Consider your coding style - if you are already used to using bindings and commands, or event handlers, WPF is the closest conceptually.
I don't think it's a good idea to consider using C# to call a native library but if you go that way, please let us know how it works out!
WPF or Silverlight (for web+desktop projects)
I know that .NET apps are difficult to protect. I use RedGate Reflector and know that generally speaking you can get source code from many .NET dlls.
however my question is - is it actually feasible to decompile the whole application?
I mean - create a workable VS solution so the pirate can just press F5 and get the exactly same result as if the author on his machine?
Reflector have few plugins that allows to dump assembly into code:
http://www.denisbauer.com/home/reflectorfiledisassembler
http://filegenreflector.codeplex.com/
But I'm not sure that can create a project file.
For a small application, it is both possible AND feasible. You have to decompile the classes one by one and copy/paste the code into Visual Studio.
For a large application, while possible, it's not really feasible since the copy/paste process becomes extremely tedious.
It really depends on what kind of code you are writing. If you use a lot of the new features in C# 3 and above like lambda expressions, automatic properties, and yield, the decompiled source code is not runnable and requires quite a bit of work to get it to compile.
Even without those features though, I have usually experienced at least some problems compiling the decompiled source code of a full winforms application.
There are many obfuscators these days that protect your .NET applications from decompilation. One such obfuscator is http://www.red-gate.com/products/smartassembly/index.htm . They try to make your well structured .NET IL code into spegatti code (which still works) that decompilers cannot generate original code. It's not like 100% sure piraters cannot get the recompilable code but it will not be easy for them to decompile when using obfuscator.
I don't think there's anything that fully automates this for an app made up of multiple assemblies, but I can say that it's really not that hard to stitch the pieces together into a solution yourself. Perhaps a bit tedious for a large app, but if you really want to it's certainly doable.
Fortunately, I don't worry about it that much.
Yes, you simply Export from Reflector and get a complete runnable Project for your assembly.
I've done it a couple of times.
Usually, I have to migrate the project to my version of VS and some times it requires some minor fixes, but in general it works.