private void updatePauseButton() { bool isEnabled, isPressed; switch (playerState) { case PlayerStateEnum.Idle: isEnabled = false; isPressed = false; break; case PlayerStateEnum.Playing: isEnabled = true; isPressed = false; break; case PlayerStateEnum.Paused: isEnabled = true; isPressed = true; break; case PlayerStateEnum.Error: isEnabled = true; isPressed = false; break; default: throw new NotSupportedException(); } if (PauseButton.IsEnabled != isEnabled || PauseButton.IsPressed != isPressed) { PauseButton.IsEnabled = isEnabled; PauseButton.IsPressed = isPressed; PauseButton.InvalidateVisual(); } }