private void ReloadColorHex() { if (colorChanged || !Regex.IsMatch(colorHexTextBox.Text, @"#?[0-9a-fA-F]{6}")) { return; } colorChanged = true; CurrentColor = ColorConvertors.HexToColor(colorHexTextBox.Text); colorRNumeric.Value = CurrentColor.R; colorGNumeric.Value = CurrentColor.G; colorBNumeric.Value = CurrentColor.B; var hsl = ColorConvertors.ColorToHsl(CurrentColor); colorHNumeric.Value = hsl.H; colorSNumeric.Value = hsl.S; colorLNumeric.Value = hsl.L; ReloadColorMain(); }
private async void OnImportButtonClick(object sender, RoutedEventArgs eventArgs) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.AllowMultiple = false; openFileDialog.Filters.Add(new FileDialogFilter() { Name = "Palette File", Extensions = { "palette", "txt" } }); string[] path = await openFileDialog.ShowAsync(this); if (path == null || path.Length < 1) { return; } string colors = File.ReadAllText(path[0]); ColorPalette = colors.Split(importExportSeparator).Where(s => !string.IsNullOrWhiteSpace(s)) .Select(s => ColorConvertors.HexToColor(s)).Distinct().ToList(); ReloadPaletteItems(); }