protected void UpdateTargetState()
{
// By default the button is in the normal state
PaletteState newState = PaletteState.Normal;
// Only allow another state if the ribbon is enabled
if (_ribbon.Enabled)
{
// Are we showing with the fixed state?
if (_fixedPressed)
newState = PaletteState.Pressed;
else
{
// If being pressed
if (_mouseDown)
newState = PaletteState.Pressed;
else if (_mouseOver || _hasFocus)
newState = PaletteState.Tracking;
}
}
bool needPaint = false;
// Update all the targets
if ((_target1 != null) && (_target1.ElementState != newState))
{
_target1.ElementState = newState;
needPaint = true;
}
if ((_target2 != null) && (_target2.ElementState != newState))
{
_target2.ElementState = newState;
needPaint = true;
}
if ((_target3 != null) && (_target3.ElementState != newState))
{
_target3.ElementState = newState;
needPaint = true;
}
if (needPaint)
{
if ((_target1 != null) && !_target1.ClientRectangle.IsEmpty)
OnNeedPaint(false, _target1.ClientRectangle);
if ((_target2 != null) && !_target2.ClientRectangle.IsEmpty)
OnNeedPaint(false, _target2.ClientRectangle);
if ((_target3 != null) && !_target3.ClientRectangle.IsEmpty)
OnNeedPaint(false, _target3.ClientRectangle);
// Get the repaint to happen immediately
Application.DoEvents();
}
}