public Brush ColorToBrush(Color c) // color = "#E7E44D" { var color = c.ToString(); color = color.Replace("#", ""); if (color.Length == 6) { return new SolidColorBrush(ColorHelper.FromArgb(255, byte.Parse(color.Substring(0, 2), NumberStyles.HexNumber), byte.Parse(color.Substring(2, 2), NumberStyles.HexNumber), byte.Parse(color.Substring(4, 2), NumberStyles.HexNumber))); } else { return null; } }
private void Slider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e) { //http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/1cb9c5b9-3ef6-4c88-b747-ae222c38c922/ byte R, G, B, A; A = Convert.ToByte(ASlider.Value); R = Convert.ToByte(RSlider.Value); G = Convert.ToByte(GSlider.Value); B = Convert.ToByte(BSlider.Value); Color myColor = new Color(); myColor = Color.FromArgb(A, R, G, B); showColor.Fill = new SolidColorBrush(myColor); //set the settings App.HanasuAppSettings.PreferredChromeBackgroundColor = myColor.ToString(); }
private static ObservableCollection<Dialogue> AssignColorsToSpeakers(ObservableCollection<Dialogue> dialogues) { List<string> Characters = new List<string>(); Characters = dialogues.Where(x => x.LineType == Constants.LineType.Dialogue).Select(x => x.Name).Distinct().ToList(); Color color = new Color(); color.R = 0; color.G = 40; color.B = 0; foreach (string speaker in Characters) { foreach (var t in dialogues.Where(x => x.Name == speaker)) t.BgColor = "#" + color.ToString().Substring(3); color.G += 10; } return dialogues; }
private void SetColor(Color newColor, Manager manager) { try { manager.BlyncLight.StatusColor = newColor; DeviceCommunication.SendEvent(deviceClient, "Color=" + newColor.ToString()); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Error: " + ex.Message); } }