private void OnButtonPropertyChanged(object sender, PropertyChangedEventArgs e) { bool updateLayout = false; bool updatePaint = false; switch (e.PropertyName) { case "SelectedColor": case "SelectedRect": case "EmptyBorderColor": _viewMediumSmallImage.SelectedColorRectChanged(); updatePaint = true; break; case "Visible": updateLayout = true; break; case "TextLine": _viewMediumSmallText1.MakeDirty(); updateLayout = true; break; case "ButtonType": UpdateDropDownState(); updateLayout = true; break; case "Checked": UpdateCheckedState(); updatePaint = true; break; case "Enabled": UpdateEnabledState(); updatePaint = true; break; case "ImageSmall": _viewMediumSmallImage.SelectedColorRectChanged(); updatePaint = true; break; case "ItemSizeMinimum": case "ItemSizeMaximum": case "ItemSizeCurrent": UpdateItemSizeState(); updateLayout = true; break; case "KryptonCommand": _viewMediumSmallText1.MakeDirty(); _viewMediumSmallImage.SelectedColorRectChanged(); UpdateEnabledState(); UpdateCheckedState(); updateLayout = true; break; } if (updateLayout) { // If we are on the currently selected tab then... if ((_ribbonColorButton.RibbonTab != null) && (_ribbon.SelectedTab == _ribbonColorButton.RibbonTab)) { // ...layout so the visible change is made OnNeedPaint(true); } } if (updatePaint) { // If this button is actually defined as visible... if (_ribbonColorButton.Visible || _ribbon.InDesignMode) { // ...and on the currently selected tab then... if ((_ribbonColorButton.RibbonTab != null) && (_ribbon.SelectedTab == _ribbonColorButton.RibbonTab)) { // ...repaint it right now OnNeedPaint(false, ClientRectangle); } } } }