private void OnNumericUpDownPropertyChanged(object sender, PropertyChangedEventArgs e)
{
bool updateLayout = false;
bool updatePaint = false;
switch (e.PropertyName)
{
case "Enabled":
UpdateEnabled(LastNumericUpDown);
break;
case "Visible":
UpdateVisible(LastNumericUpDown);
updateLayout = true;
break;
case "CustomControl":
updateLayout = true;
break;
}
if (updateLayout)
{
// If we are on the currently selected tab then...
if ((_ribbonNumericUpDown.RibbonTab != null) &&
(_ribbon.SelectedTab == _ribbonNumericUpDown.RibbonTab))
{
// ...layout so the visible change is made
OnNeedPaint(true);
}
}
if (updatePaint)
{
// If this button is actually defined as visible...
if (_ribbonNumericUpDown.Visible || _ribbon.InDesignMode)
{
// ...and on the currently selected tab then...
if ((_ribbonNumericUpDown.RibbonTab != null) &&
(_ribbon.SelectedTab == _ribbonNumericUpDown.RibbonTab))
{
// ...repaint it right now
OnNeedPaint(false, ClientRectangle);
}
}
}
}