private void OnVisibleClick(object sender, EventArgs e)
{
// Cast to the correct type
DesignerVerb verb = sender as DesignerVerb;
// Find out if this is the first or second header verb
bool header1 = (verb == _visible1);
// The new visible value should be the opposite of the current value
bool newVisible = !(header1 ? _headerGroup.HeaderVisiblePrimary : _headerGroup.HeaderVisibleSecondary);
// Assign the new text to the correct header text
if (header1)
_text1 = (newVisible ? "Hide primary header" : "Show primary header");
else
_text2 = (newVisible ? "Hide secondary header" : "Show secondary header");
if (header1)
_headerGroup.HeaderVisiblePrimary = newVisible;
else
_headerGroup.HeaderVisibleSecondary = newVisible;
// Get the user interface service associated with actions
DesignerActionUIService service = GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
// If we managed to get it then request it update to reflect new action setting
if (service != null)
service.Refresh(_headerGroup);
}