[ColorPicker]Support BGR and RGB decimal value formats (#22771)

* ColorPicker add both decimal value formats

* ColorPicker, custom format dialog, resizing columns
This commit is contained in:
Laszlo Nemeth 2022-12-15 10:33:17 +01:00 committed by GitHub
parent 5b4e678f14
commit 96ac6a6a12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 13 deletions

View File

@ -285,7 +285,8 @@ namespace ManagedCommon
{ "Xv", 'i' }, // X value int
{ "Yv", 'i' }, // Y value int
{ "Zv", 'i' }, // Z value int
{ "Dv", 'i' }, // Decimal value int
{ "Dr", 'i' }, // Decimal value (RGB) int
{ "Dv", 'i' }, // Decimal value (BGR) int
{ "Na", 's' }, // Color name string
};
@ -447,8 +448,10 @@ namespace ManagedCommon
var (_, _, z) = ConvertToCIEXYZColor(color);
z = Math.Round(z * 100, 4);
return z.ToString(CultureInfo.InvariantCulture);
case "Dv":
case "Dr":
return ((color.R * 65536) + (color.G * 256) + color.B).ToString(CultureInfo.InvariantCulture);
case "Dv":
return (color.R + (color.G * 256) + (color.B * 65536)).ToString(CultureInfo.InvariantCulture);
case "Na":
return ColorNameHelper.GetColorName(color);
default: return string.Empty;

View File

@ -1374,8 +1374,11 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
<data name="Help_Z_value.Text" xml:space="preserve">
<value>Z value</value>
</data>
<data name="Help_decimal_value.Text" xml:space="preserve">
<value>decimal value</value>
<data name="Help_decimal_value_RGB.Text" xml:space="preserve">
<value>decimal value (RGB)</value>
</data>
<data name="Help_decimal_value_BGR.Text" xml:space="preserve">
<value>decimal value (BGR)</value>
</data>
<data name="Help_color_name.Text" xml:space="preserve">
<value>color name</value>

View File

@ -261,14 +261,15 @@
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40px"/>
<ColumnDefinition Width="120px"/>
<ColumnDefinition Width="40px"/>
<ColumnDefinition Width="120px"/>
<ColumnDefinition Width="40px"/>
<ColumnDefinition Width="120px"/>
<ColumnDefinition Width="37px"/>
<ColumnDefinition Width="127px"/>
<ColumnDefinition Width="37px"/>
<ColumnDefinition Width="127px"/>
<ColumnDefinition Width="37px"/>
<ColumnDefinition Width="127px"/>
</Grid.ColumnDefinitions>
<TextBlock Text = "%Re" FontWeight="Bold"/>
<TextBlock x:Uid="Help_red" Grid.Column="1"/>
@ -321,9 +322,11 @@
<TextBlock Text = "%Zv" Grid.Row="8" FontWeight="Bold"/>
<TextBlock x:Uid="Help_Z_value" Grid.Row="8" Grid.Column="1"/>
<TextBlock Text = "%Dv" Grid.Row="8" Grid.Column="2" FontWeight="Bold"/>
<TextBlock x:Uid="Help_decimal_value" Grid.Row="8" Grid.Column="3"/>
<TextBlock Text = "%Na" Grid.Row="8" Grid.Column="4" FontWeight="Bold"/>
<TextBlock x:Uid="Help_color_name" Grid.Row="8" Grid.Column="5"/>
<TextBlock x:Uid="Help_decimal_value_BGR" Grid.Row="8" Grid.Column="3"/>
<TextBlock Text = "%Dr" Grid.Row="8" Grid.Column="4" FontWeight="Bold"/>
<TextBlock x:Uid="Help_decimal_value_RGB" Grid.Row="8" Grid.Column="5"/>
<TextBlock Text = "%Na" Grid.Row="9" FontWeight="Bold"/>
<TextBlock x:Uid="Help_color_name" Grid.Row="9" Grid.Column="1"/>
</Grid>
<TextBlock
Grid.Row="2"