Ejemplo n.º 1
0
        private async void OnDuoTonePickColorButtonClick(object sender, RoutedEventArgs eventArgs)
        {
            Color             currentColor = ColorConvertors.HslToColor(((float)duoToneHueNumeric.Value, (float)duoToneSaturationNumeric.Value, 0.5f));
            SelectColorWindow dialog       = new SelectColorWindow(currentColor);
            Color             result       = await dialog.ShowDialog <Color>(this);

            var hslColor = ColorConvertors.ColorToHsl(result);

            duoToneHueNumeric.Value        = hslColor.H;
            duoToneSaturationNumeric.Value = hslColor.S;
        }
Ejemplo n.º 2
0
        private void ReloadColorHsl()
        {
            if (colorChanged)
            {
                return;
            }
            colorChanged = true;
            float h = (float)(colorHNumeric.Value % 360);
            float s = (float)colorSNumeric.Value;
            float l = (float)colorLNumeric.Value;

            CurrentColor         = ColorConvertors.HslToColor(h, s, l);
            colorRNumeric.Value  = CurrentColor.R;
            colorGNumeric.Value  = CurrentColor.G;
            colorBNumeric.Value  = CurrentColor.B;
            colorHexTextBox.Text = ColorConvertors.ColorToHex(CurrentColor);
            ReloadColorMain();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        private void ReloadColorRgb()
        {
            if (colorChanged)
            {
                return;
            }
            colorChanged = true;
            int r = (int)colorRNumeric.Value;
            int g = (int)colorGNumeric.Value;
            int b = (int)colorBNumeric.Value;

            CurrentColor = Color.FromArgb(r, g, b);
            var hsl = ColorConvertors.ColorToHsl(CurrentColor);

            colorHNumeric.Value  = hsl.H;
            colorSNumeric.Value  = hsl.S;
            colorLNumeric.Value  = hsl.L;
            colorHexTextBox.Text = ColorConvertors.ColorToHex(CurrentColor);
            ReloadColorMain();
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        private async void OnExportButtonClick(object sender, RoutedEventArgs eventArgs)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.DefaultExtension = "palette";
            saveFileDialog.Filters.Add(new FileDialogFilter()
            {
                Name = "Palette File", Extensions = { "palette", "txt" }
            });
            string path = await saveFileDialog.ShowAsync(this);

            if (path == null || path == "")
            {
                return;
            }
            path = path.Contains('.') ? path : path + ".palette";
            string result = string.Join(importExportSeparator, ColorPalette.Select(c => ColorConvertors.ColorToHex(c)));

            File.WriteAllText(path, result);
        }