I am working on a winforms project containing some forms and controls. Each one is translated in 4 languages. There is one form called “PropertiesForm” which is a nightmare to maintain : it has a tab container with 6 tab pages, and more than one hundred controls in it, with dirty code trying (and often failing) to keep the whole thing coherent.
Since I am in charge of this project, I have tried to avoid doing big modifications to this form, but it’s not doable anymore. Making big changes will be difficult and slow, and is likely to cause stability issues. So, what is the best way to restore a clean and understandable code ?
My idea is to make at least one control for each tab page, and synchronizing them in the form. My problem is that I don’t know any simple way to do that with visual studio. Is there any automatic way to keep the translations and events handlers in the new controls since copy-paste makes them disappear ? Is there any tool or add-in designed for this task ?
What should be the method to clean the structure without breaking everything ?
As far as I know, there is no a such tool, and I don’t see after what principle it should exist.
I’d simply create 6 user controls, cut the controls from each tab page in the respective control and paste it into the newly created controls. After that fix all the errors by dispatching functions with errors in respective UserContols. However, if tabs controls are linked one with other from different tabs, you may encounter some “problems”.
An other approach is to logically separate the user controls (date/time controls, text controls, busineess-object-depending controls).
However, I am afraid that the event handlers and other stuff you will need to fix by yourself.