private void QueryCommandStatus(INiCommandBarControl command) { NiCommandStatus status; ErrorUtil.ThrowOnFailure(_commandManager.QueryStatus(command.Id, out status)); if ((status & NiCommandStatus.Supported) != 0) { command.IsEnabled = (status & NiCommandStatus.Enabled) != 0; command.IsVisible = (status & NiCommandStatus.Invisible) == 0; var button = command as INiCommandBarButton; if (button != null) { button.IsLatched = (status & NiCommandStatus.Latched) != 0; } } var comboBox = command as NiCommandBarComboBox; if (comboBox != null && comboBox.IsVisible) { object result; if (ErrorUtil.ThrowOnFailure(_commandManager.Exec(command.Id, null, out result))) { comboBox.SelectedValue = (string)result; } else { comboBox.SelectedValue = null; } } }
public HResult FindCommandBarControl(Guid id, out INiCommandBarControl command) { command = null; try { object obj; if (_objects.TryGetValue(id, out obj)) { command = obj as INiCommandBarControl; } return(command == null ? HResult.False : HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
private void QueryCommandStatus(INiCommandBarControl command) { NiCommandStatus status; ErrorUtil.ThrowOnFailure(_commandManager.QueryStatus(command.Id, out status)); if ((status & NiCommandStatus.Supported) != 0) { command.IsEnabled = (status & NiCommandStatus.Enabled) != 0; command.IsVisible = (status & NiCommandStatus.Invisible) == 0; var button = command as INiCommandBarButton; if (button != null) button.IsLatched = (status & NiCommandStatus.Latched) != 0; } var comboBox = command as NiCommandBarComboBox; if (comboBox != null && comboBox.IsVisible) { object result; if (ErrorUtil.ThrowOnFailure(_commandManager.Exec(command.Id, null, out result))) comboBox.SelectedValue = (string)result; else comboBox.SelectedValue = null; } }
public HResult FindCommandBarControl(Guid id, out INiCommandBarControl command) { command = null; try { object obj; if (_objects.TryGetValue(id, out obj)) command = obj as INiCommandBarControl; return command == null ? HResult.False : HResult.OK; } catch (Exception ex) { return ErrorUtil.GetHResult(ex); } }