A winclient is using GUI controls (BaseForm, BaseTextBox, BaseComboBox) from a separate GUI project which is used in other projects as well
These controls change backgroundcolor to yellow-ish when they are focused and retains their old backgroundcolor when focus leaves. (onEnter and OnLeave events)
Now, this winclient will let the users choose their own focus color. I know I can directly set the “FocusColor” property on all the controls but that’s not what i want (there’s a lot of controls)
What’s the best approach? I thought maybe I could inject some kind of “CustomColorProvider” into the controls and rewrite the GUI project to fetch the focuscolor from a “StandardColorProvider”. But I don’t exactly how these controls should get their “CustomColorProvider” injected. (I’m not so experienced with DI) The controls are added via the designer and the creation of controls is by auto-generated code “partial designer class”
Or maybe I should just write new controls in this specific winclient which inherits from the GUI project and then override the methods where the focuscolor is set?
I have access and allowed to modify both the winclient and the GUI project.
As you mentioned, I would use the Decorator pattern, passing a different concrete decorator depending on how you want to extend the control. You can find an example here.
EDIT:
Declare an interface IControlExtender
Create a default implementation
Add a property to your GUI control
Create any new implementations, such as
And override the default as you need