Hi folks,
I’m using the Xarial’s framework in my project.
How is it possible to control the button checking state via external setting options file (json file for example)?
In my code I’ve declared a global boolean variable and its value is set by reading the json file. Then the button checking state is equal to the global variable (triggerred by the CommandStateResolve event):
private bool FlatPatternAutoFixIsChecked;
public override void OnConnect()
{
CommandGroup = CommandManager.AddCommandGroup<CommandsBar_e>();
CommandGroup.CommandClick += OnButtonClick;
CommandManager.AddContextMenu<CommandsContextMenu_e>().CommandClick += OnButtonClickContextMenu;
CommandGroup.CommandStateResolve += OnCommandStateResolve;
Sw = new MySolidworksLib(MySolidworksLib.StartOptions_e.OnlySwApp);
Sw.SwApp.FileOpenPostNotify += OnFileOpenPostNotify;
Sw.SwApp.ActiveModelDocChangeNotify += ActiveModelDocChangeNotify;
FlatPatternAutoFixIsChecked = (bool)GetOptions("FlatPatternAutoFix");
}
private void OnCommandStateResolve(CommandsBar_e spec, CommandState state)
{
if (spec == CommandsBar_e.FlatPatternAutoFix)
{
state.Enabled = true;
state.Checked = FlatPatternAutoFixIsChecked;
}
}
It only works as expected in debug runtime.