private void GetCurrentColor() { byte[] Colours = SkinIniParser.GetRgbColours(BackgroundColour); TextBoxColourR.Text = Colours[0].ToString(); TextBoxColourG.Text = Colours[1].ToString(); TextBoxColourB.Text = Colours[2].ToString(); TextBoxColourHEX.Text = BackgroundColour.ToString().Remove(1, 2); RectangleColour.Fill = new SolidColorBrush(Color.FromRgb(Colours[0], Colours[1], Colours[2])); }
private void TextBoxColour_TextChanged(object sender, TextChangedEventArgs e) { if (((TextBox)sender).Name.Contains("HEX")) { if (TextBoxColourHEX.Text.Length == 7) { try { string HexColour = TextBoxColourHEX.Text.Insert(1, "FF"); byte[] Colours = SkinIniParser.GetRgbColours(HexColour); TextBoxColourR.Text = Colours[0].ToString(); TextBoxColourG.Text = Colours[1].ToString(); TextBoxColourB.Text = Colours[2].ToString(); RectangleColour.Fill = new SolidColorBrush(Color.FromRgb(Colours[0], Colours[1], Colours[2])); return; } catch (FormatException) { return; } } return; } byte R, G, B; var Sender = sender as TextBox; if (Sender.Text != "" && int.Parse(Sender.Text) > 256) { Sender.Background = Brushes.Red; return; } Sender.Background = Brushes.White; R = SkinIniParser.GetSingleChannel(TextBoxColourR.Text); G = SkinIniParser.GetSingleChannel(TextBoxColourG.Text); B = SkinIniParser.GetSingleChannel(TextBoxColourB.Text); RectangleColour.Fill = new SolidColorBrush(Color.FromRgb(R, G, B)); TextBoxColourHEX.Text = RectangleColour.Fill.ToString().Remove(1, 2); }