This reverts commit 022dde4754
.
This commit is contained in:
parent
022dde4754
commit
0dae5d0402
|
@ -44,14 +44,6 @@ namespace ColorPicker.Helpers
|
||||||
return (cyan, magenta, yellow, blackKey);
|
return (cyan, magenta, yellow, blackKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Convert a given <see cref="Color"/> to a float color styling(0.1f, 0.1f, 0.1f)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
|
||||||
/// <returns>The int / 255d for each value to get value between 0 and 1</returns>
|
|
||||||
internal static (double red, double green, double blue) ConvertToDouble(Color color)
|
|
||||||
=> (color.R / 255d, color.G / 255d, color.B / 255d);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a given <see cref="Color"/> to a HSB color (hue, saturation, brightness)
|
/// Convert a given <see cref="Color"/> to a HSB color (hue, saturation, brightness)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -46,8 +46,6 @@ namespace ColorPicker.Helpers
|
||||||
ColorRepresentationType.RGB => ColorToRGB(color),
|
ColorRepresentationType.RGB => ColorToRGB(color),
|
||||||
ColorRepresentationType.CIELAB => ColorToCIELAB(color),
|
ColorRepresentationType.CIELAB => ColorToCIELAB(color),
|
||||||
ColorRepresentationType.CIEXYZ => ColorToCIEXYZ(color),
|
ColorRepresentationType.CIEXYZ => ColorToCIEXYZ(color),
|
||||||
ColorRepresentationType.RGBfloat => ColorToFloat(color),
|
|
||||||
ColorRepresentationType.Decimal => ColorToDecimal(color),
|
|
||||||
|
|
||||||
// Fall-back value, when "_userSettings.CopiedColorRepresentation.Value" is incorrect
|
// Fall-back value, when "_userSettings.CopiedColorRepresentation.Value" is incorrect
|
||||||
_ => ColorToHex(color),
|
_ => ColorToHex(color),
|
||||||
|
@ -101,29 +99,6 @@ namespace ColorPicker.Helpers
|
||||||
+ $", {brightness.ToString(CultureInfo.InvariantCulture)}%)";
|
+ $", {brightness.ToString(CultureInfo.InvariantCulture)}%)";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return a <see cref="string"/> representation float color styling(0.1f, 0.1f, 0.1f)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
|
||||||
/// <returns>a string value (0.1f, 0.1f, 0.1f)</returns>
|
|
||||||
private static string ColorToFloat(Color color)
|
|
||||||
{
|
|
||||||
var (red, green, blue) = ColorHelper.ConvertToDouble(color);
|
|
||||||
var precison = 2;
|
|
||||||
|
|
||||||
return $"({Math.Round(red, precison)}f, {Math.Round(green, precison)}f, {Math.Round(blue, precison)}f, 1)";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return a <see cref="string"/> representation decimal color value
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="color">The <see cref="Color"/> to convert</param>
|
|
||||||
/// <returns>a string value number</returns>
|
|
||||||
private static string ColorToDecimal(Color color)
|
|
||||||
{
|
|
||||||
return $"{color.R + (color.G * 256) + (color.B * 65536)}";
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return a <see cref="string"/> representation of a HSI color
|
/// Return a <see cref="string"/> representation of a HSI color
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -216,18 +216,6 @@ namespace ColorPicker.ViewModels
|
||||||
FormatName = ColorRepresentationType.CIEXYZ.ToString(),
|
FormatName = ColorRepresentationType.CIEXYZ.ToString(),
|
||||||
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.CIEXYZ); },
|
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.CIEXYZ); },
|
||||||
});
|
});
|
||||||
_allColorRepresentations.Add(
|
|
||||||
new ColorFormatModel()
|
|
||||||
{
|
|
||||||
FormatName = ColorRepresentationType.RGBfloat.ToString(),
|
|
||||||
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.RGBfloat); },
|
|
||||||
});
|
|
||||||
_allColorRepresentations.Add(
|
|
||||||
new ColorFormatModel()
|
|
||||||
{
|
|
||||||
FormatName = ColorRepresentationType.Decimal.ToString(),
|
|
||||||
Convert = (Color color) => { return ColorRepresentationHelper.GetStringRepresentationFromMediaColor(color, ColorRepresentationType.Decimal); },
|
|
||||||
});
|
|
||||||
|
|
||||||
_userSettings.VisibleColorFormats.CollectionChanged += VisibleColorFormats_CollectionChanged;
|
_userSettings.VisibleColorFormats.CollectionChanged += VisibleColorFormats_CollectionChanged;
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,6 @@ namespace Microsoft.ColorPicker.UnitTests
|
||||||
[DataRow(ColorRepresentationType.RGB, "rgb(0, 0, 0)")]
|
[DataRow(ColorRepresentationType.RGB, "rgb(0, 0, 0)")]
|
||||||
[DataRow(ColorRepresentationType.CIELAB, "CIELab(0, 0, 0)")]
|
[DataRow(ColorRepresentationType.CIELAB, "CIELab(0, 0, 0)")]
|
||||||
[DataRow(ColorRepresentationType.CIEXYZ, "xyz(0, 0, 0)")]
|
[DataRow(ColorRepresentationType.CIEXYZ, "xyz(0, 0, 0)")]
|
||||||
[DataRow(ColorRepresentationType.RGBfloat, "(0.00f, 0.00f, 0.00f, 1)")]
|
|
||||||
[DataRow(ColorRepresentationType.Decimal, "0")]
|
|
||||||
|
|
||||||
public void GetStringRepresentationTest(ColorRepresentationType type, string expected)
|
public void GetStringRepresentationTest(ColorRepresentationType type, string expected)
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,17 +65,5 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Enumerations
|
||||||
/// Color presentation as CIEXYZ color space (X[0..95], Y[0..100], Z[0..109]
|
/// Color presentation as CIEXYZ color space (X[0..95], Y[0..100], Z[0..109]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
CIEXYZ = 10,
|
CIEXYZ = 10,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Color presentation as RGB float (red[0..1], green[0..1], blue[0..1])
|
|
||||||
/// </summary>
|
|
||||||
RGBfloat = 11,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Color presentation as integer decimal value 0-16777215
|
|
||||||
/// </summary>
|
|
||||||
#pragma warning disable CA1720 // Identifier contains type name
|
|
||||||
Decimal = 12,
|
|
||||||
#pragma warning restore CA1720 // Identifier contains type name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||||
{ ColorRepresentationType.RGB, "RGB - rgb(100, 50, 75)" },
|
{ ColorRepresentationType.RGB, "RGB - rgb(100, 50, 75)" },
|
||||||
{ ColorRepresentationType.CIELAB, "CIE LAB - CIELab(76, 21, 80)" },
|
{ ColorRepresentationType.CIELAB, "CIE LAB - CIELab(76, 21, 80)" },
|
||||||
{ ColorRepresentationType.CIEXYZ, "CIE XYZ - xyz(56, 50, 7)" },
|
{ ColorRepresentationType.CIEXYZ, "CIE XYZ - xyz(56, 50, 7)" },
|
||||||
{ ColorRepresentationType.RGBfloat, "(1.0f, 0.7f, 0.00f)" },
|
|
||||||
{ ColorRepresentationType.Decimal, "16755200" },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||||
|
@ -200,8 +198,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||||
var ncolFormatName = ColorRepresentationType.NCol.ToString();
|
var ncolFormatName = ColorRepresentationType.NCol.ToString();
|
||||||
var cielabFormatName = ColorRepresentationType.CIELAB.ToString();
|
var cielabFormatName = ColorRepresentationType.CIELAB.ToString();
|
||||||
var ciexyzFormatName = ColorRepresentationType.CIEXYZ.ToString();
|
var ciexyzFormatName = ColorRepresentationType.CIEXYZ.ToString();
|
||||||
var rgbFloatFormatName = ColorRepresentationType.RGBfloat.ToString();
|
|
||||||
var decimalFormatName = ColorRepresentationType.Decimal.ToString();
|
|
||||||
|
|
||||||
formatsUnordered.Add(new ColorFormatModel(hexFormatName, "ef68ff", visibleFormats.ContainsKey(hexFormatName) && visibleFormats[hexFormatName]));
|
formatsUnordered.Add(new ColorFormatModel(hexFormatName, "ef68ff", visibleFormats.ContainsKey(hexFormatName) && visibleFormats[hexFormatName]));
|
||||||
formatsUnordered.Add(new ColorFormatModel(rgbFormatName, "rgb(239, 104, 255)", visibleFormats.ContainsKey(rgbFormatName) && visibleFormats[rgbFormatName]));
|
formatsUnordered.Add(new ColorFormatModel(rgbFormatName, "rgb(239, 104, 255)", visibleFormats.ContainsKey(rgbFormatName) && visibleFormats[rgbFormatName]));
|
||||||
|
@ -214,8 +210,6 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||||
formatsUnordered.Add(new ColorFormatModel(ncolFormatName, "R10, 50%, 75%", visibleFormats.ContainsKey(ncolFormatName) && visibleFormats[ncolFormatName]));
|
formatsUnordered.Add(new ColorFormatModel(ncolFormatName, "R10, 50%, 75%", visibleFormats.ContainsKey(ncolFormatName) && visibleFormats[ncolFormatName]));
|
||||||
formatsUnordered.Add(new ColorFormatModel(cielabFormatName, "CIELab(66, 72, -52)", visibleFormats.ContainsKey(cielabFormatName) && visibleFormats[cielabFormatName]));
|
formatsUnordered.Add(new ColorFormatModel(cielabFormatName, "CIELab(66, 72, -52)", visibleFormats.ContainsKey(cielabFormatName) && visibleFormats[cielabFormatName]));
|
||||||
formatsUnordered.Add(new ColorFormatModel(ciexyzFormatName, "xyz(59, 35, 98)", visibleFormats.ContainsKey(ciexyzFormatName) && visibleFormats[ciexyzFormatName]));
|
formatsUnordered.Add(new ColorFormatModel(ciexyzFormatName, "xyz(59, 35, 98)", visibleFormats.ContainsKey(ciexyzFormatName) && visibleFormats[ciexyzFormatName]));
|
||||||
formatsUnordered.Add(new ColorFormatModel(rgbFloatFormatName, "(0.94f, 0.41f, 1.00f, 1)", visibleFormats.ContainsKey(rgbFloatFormatName) && visibleFormats[rgbFloatFormatName]));
|
|
||||||
formatsUnordered.Add(new ColorFormatModel(decimalFormatName, "15689983", visibleFormats.ContainsKey(decimalFormatName) && visibleFormats[decimalFormatName]));
|
|
||||||
|
|
||||||
foreach (var storedColorFormat in _colorPickerSettings.Properties.VisibleColorFormats)
|
foreach (var storedColorFormat in _colorPickerSettings.Properties.VisibleColorFormats)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue