Posted 28 May 2019, 3:09 am EST
Hi C1,
we call C1ThemeController.ApplyTheme to apply a theme to a form. The parameter “applyThemeToSubTree” allows us to prevent theming of a subcontrol.
A sample might be a panel which has a certain back color - this can be e.g. an explanation of colors used in a C1FlexGrid. The back color of this panel must not be changed to the theme color.
But we also have rather complex forms, where a form contains (dynamically created) subsubsub UserControl instances, and only those nested subcontrols know about non-themeable controls. So I don’t want to add code to the root form which has to check for non-themeable controls on sub controls.
My suggestion is that you add an interface “ICanApplyTheme” with a method “bool CanApplyTheme(Control subcontrol)”: if this interface is defined on a user control, C1ThemeController calls this method for all child controls of the UserControl. So the UserControl can prevent theming of specific sub controls.
As multiple (and nested) controls in the control tree of a form can implement this interface, it would have to stack: if a control implements “ICanApplyTheme”, and another subcontrol of this control also implements the interface, for all subcontrols of the inner “ICanApplyTheme” control the “CanApplyTheme” of this inner “ICanApplyTheme” implementation the “CanApplyTheme” method shall be called, but not the method of the outer parent control.
Hope I could make my requirement clear ;-).I could create a sample to show my requirement, but without implementation of the ThemeController logic, it would not make much sense.
What do you think about this idea?
Best regards
Wolfgang