I'm attempting (not very well at the moment) to get my project's Ribbon icons to correctly update based on the current theme in AutoCAD...light vs dark. I understand how this is done when using a CUIx to define the commands and ribbons items. However, we create our ribbon in code and I do not want to have to do something like this:
//in my Initialization code
public static bool darkTheme = (Application.GetVariable("COLORTHEME") == 0);
//then set that as needed in a SystemeVariableChanged event handler.
//all images are in the same Resource file
//And then in my ribbon button code this:
rb.Image = darkTheme ? MyApp.flattenobjects_small.ToBitmapImageFromPng() : MyApp.flattenobjects_small_light.ToBitmapImageFromPng();
rb.LargeImage = darkTheme ? MyApp.flattenobjects.ToBitmapImageFromPng() : MyApp.flattenobjects_light.ToBitmapImageFromPng();
On the surface this looks workable, except there are 200+ buttons with more being added. I would far prefer to do something like so:
//have 2 resource files, MyAppDark.resx and MyAppLight.resx, where the icons have the same names, but are the different icons.
//have a MyApp variable which can be set to the correct one to reference in the SystemeVariableChanged event handler
if(Application.GetVariable("COLORTHEME") == 0
MyApp = MyAppDark;
else
MyApp = MyAppLight;
//then my ribbon buttons can simply be:
rb.Image = MyApp.flattenobjects_small.ToBitmapImageFromPng();
rb.LargeImage = MyApp.flattenobjects.ToBitmapImageFromPng();
Where I'm stumped is at what I need to initialize MyApp as...can I simply do this?:
public static object MyApp = MyAppDark;
If so, I'm at a loss as to how to do so, because that doesn't work...