public void SetColor(IColorSource colorSource) { try { EnsureBlinkIsOpen(); } catch (InvalidOperationException) { main.Errors.Add("Could not open Blink1 - not connected."); return; } var rgb = colorSource.GetRgb(); try { var success = blink.SetColor(rgb.Red, rgb.Green, rgb.Blue); if (!success) { main.Errors.Add("Error when writing color to Blink1."); } } catch (InvalidOperationException) { main.Errors.Add( "Could not set color - Blink1 is not connected."); } }
public void SetColor(IColorSource colorSource) { App.Current.Dispatcher.Invoke(() => { var rgb = colorSource.GetRgb(); textBlock.Foreground = new SolidColorBrush(Color.FromRgb( (byte)rgb.Red, (byte)rgb.Green, (byte)rgb.Blue)); }, DispatcherPriority.ContextIdle); }