views:

1129

answers:

5

I created a pretty fancy winforms app for my company. We had a graphic designer create the GUI, which was a pain to implement, all graphical buttons, lots of layered backgrounds and logos, animations, etc.

But now my company wants to resell it under different brands. But since I mostly coded it well, I told my higher ups I could have a totally rebranded version done in under a week. Basically all I would do is change a bunch of settings in an xml settings file, swap out the graphics with a new set, and build.

Problem is if they want 5 or 6 different brands, I'd have 5 different builds to support (I really should be supporting 1, with diff templates)

The problem is its not easy (as far as I know) to swap out the images in a winforms app. I have all the graphical resources in a single folder, but once each file is entered into its respective image list or container in visual studio, the only way to get it to update is to remove it and re-add it, changing the source folder doesnt cause the embedded image to refresh. This would be incredibly tedious for each build, there has got to be an easier way.

Add On:
So after some further investigation, I am leaning torwards some sort of resx file editor. However the ones I have seen so far are more focused on translating strings to various languages, and are either very weak, or can not at all edit binary resources like bitmaps/png's. Though if you open a resx file in an xml viewer (I use notepad 2 with .resx set to use xml sytax highlighting) MS is kind enough to tell you exactly how each type is compiled (mostly variations of base 64)

A: 

I think you should be thinking about creating user controls for the dynamically replaceable areas of the form. At runtime, you could swap out one assembly out for another.

rp
Thats a horrible idea. EVERYTHING is graphical. And I want to keep code in a singel place. Creating new assemblies for each build would make me worse off than I am now.
Neil N
I thought you meant a header image. I'm suggesting you create a separate user control, with images as embedded resources, and then dynamically load the appropriate control at runtime. Each brand would have its own header assembly. If you have images frittered about, this isn't the way to go.
rp
+8  A: 

I think your goal should be having "brandable" resource files; you're essentially localizing your application, except you just have a few different versions of English.

You can use ResGen.exe and ResourceManager to load an external resources file, so you could use 5 different "resources" files but keep your code base the same.

This post may also help... http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/b388c700-0e07-452b-a19e-ce02775f78a6/

Edit: BTW, I will second the comment that if you're going through a great deal of effort on this, consider WPF... Most of those "graphical" elements could possibly be done natively especially if it's gradients and stuff, not to mention the easy templating.

routeNpingme
WPF aside, I'm not sure this is what I'm looking for, wouldnt I still have to add each image individually to the alternate resource file? I'm looking to have the graphics guy modify all the images in a folder, then swap that folder for my current one before building.
Neil N
A: 

What I would do is just load all the graphics of the disk at start up from a folder and create any imagelists needed as appropriate, instead of doing this in the designer. If you are worried that someone would steal the graphics, then I would create a simple file format (possibly encrypted) for my graphics and a small simple app for you or the designer to use to convert into this format from regular files. Then it's just a question of swapping out this folder between different brands.

Casper
A: 

If most of your forms are similar (i.e. same logo, same buttons on the bottom, etc.) you can use visual inheritance on WinForms to define a set of "Base Forms" from which your actual forms inherit.

If you develop a set of "Base Forms" for each of your brands, each set in a separate assembly you can plug-in the needed work to generate a new brand is reduced to generate a new set of Base Forms.

Hope it helps

amartin
A: 

It's to late now, but WPF would have been a better choose then winforms, as it is less hard to skin.

However have a look at what devexpress does for winforms, as their controls have a skinning system. It is not too hard to swap a devexpress standard winform control control for a standard winform control.

Ian Ringrose