Skip to content

Commit

Permalink
Added the possibility to set a custom RGB separator (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jan 14, 2024
1 parent 91fefa4 commit 17b06f6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 36 deletions.
85 changes: 58 additions & 27 deletions ColorPicker/Pages/SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -333,33 +333,64 @@
</StackPanel>
</StackPanel>
</Expander.Header>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock
Margin="0 0 10 0"
VerticalAlignment="Center"
Text="{x:Static lang:Resources.DefaultColorType}" />
<ComboBox
x:Name="ColorTypeComboBox"
Margin="0 0 10 0"
Padding="5"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="{DynamicResource AccentColor}"
BorderThickness="2"
Foreground="{DynamicResource Foreground1}"
SelectionChanged="ColorTypeComboBox_SelectionChanged"
Style="{DynamicResource ComboBoxStyle1}">
<ComboBoxItem Content="{x:Static lang:Resources.RGB}" />
<ComboBoxItem Content="{x:Static lang:Resources.HEX}" />
<ComboBoxItem Content="{x:Static lang:Resources.HSV}" />
<ComboBoxItem Content="{x:Static lang:Resources.HSL}" />
<ComboBoxItem Content="{x:Static lang:Resources.CMYK}" />
<ComboBoxItem Content="{x:Static lang:Resources.XYZ}" />
<ComboBoxItem Content="{x:Static lang:Resources.YIQ}" />
<ComboBoxItem Content="{x:Static lang:Resources.YUV}" />
<ComboBoxItem Content="{x:Static lang:Resources.DEC}" />
</ComboBox>
<StackPanel>
<StackPanel Margin="10 5" Orientation="Horizontal">
<TextBlock
Margin="0 0 10 0"
VerticalAlignment="Center"
Text="{x:Static lang:Resources.DefaultColorType}" />
<ComboBox
x:Name="ColorTypeComboBox"
Margin="0 0 10 0"
Padding="5"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Background="Transparent"
BorderBrush="{DynamicResource AccentColor}"
BorderThickness="2"
Foreground="{DynamicResource Foreground1}"
SelectionChanged="ColorTypeComboBox_SelectionChanged"
Style="{DynamicResource ComboBoxStyle1}">
<ComboBoxItem Content="{x:Static lang:Resources.RGB}" />
<ComboBoxItem Content="{x:Static lang:Resources.HEX}" />
<ComboBoxItem Content="{x:Static lang:Resources.HSV}" />
<ComboBoxItem Content="{x:Static lang:Resources.HSL}" />
<ComboBoxItem Content="{x:Static lang:Resources.CMYK}" />
<ComboBoxItem Content="{x:Static lang:Resources.XYZ}" />
<ComboBoxItem Content="{x:Static lang:Resources.YIQ}" />
<ComboBoxItem Content="{x:Static lang:Resources.YUV}" />
<ComboBoxItem Content="{x:Static lang:Resources.DEC}" />
</ComboBox>
</StackPanel>
<StackPanel Margin="10 5" Orientation="Horizontal">
<TextBlock
Margin="0 0 10 0"
VerticalAlignment="Center"
Text="{x:Static lang:Resources.RgbSeparator}" />
<Border
Width="50"
HorizontalAlignment="Center"
Background="{DynamicResource CardBackground}"
CornerRadius="5">
<Border.Effect>
<DropShadowEffect
BlurRadius="15"
Opacity="0.2"
ShadowDepth="0"
Color="{DynamicResource Accent}" />
</Border.Effect>
<TextBox
x:Name="RgbSeparatorTxt"
Margin="3"
Padding="3"
Background="Transparent"
BorderThickness="0"
FontWeight="Bold"
Foreground="{DynamicResource DarkGray}"
TextAlignment="Center"
TextChanged="RgbSeparatorTxt_TextChanged" />
</Border>
</StackPanel>
</StackPanel>
</Expander>
<Expander
Expand Down
9 changes: 8 additions & 1 deletion ColorPicker/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ private async void InitUI()
// Load the color option section
Global.Settings.RgbSeparator ??= ";";
ColorTypeComboBox.SelectedIndex = (int)Global.Settings.DefaultColorType;
RgbSeparatorTxt.Text = Global.Settings.RgbSeparator;

// Load the default page ComboBox
PageComboBox.SelectedIndex = (int)Global.Settings.DefaultPage;
Expand Down Expand Up @@ -529,7 +530,13 @@ private async void RefreshModelsBtn_Click(object sender, RoutedEventArgs e)
ModelComboBox.SelectedItem = Global.Settings.Model;
}

private void ResetSynethiaLink_Click(object sender, RoutedEventArgs e)
private void RgbSeparatorTxt_TextChanged(object sender, TextChangedEventArgs e)
{
Global.Settings.RgbSeparator = RgbSeparatorTxt.Text;
XmlSerializerManager.SaveToXml(Global.Settings, Global.SettingsPath);
}

private void ResetSynethiaLink_Click(object sender, RoutedEventArgs e)
{
// Ask the user a confirmation
if (MessageBox.Show(Properties.Resources.SynethiaDeleteMsg, Properties.Resources.Settings, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
Expand Down
6 changes: 3 additions & 3 deletions ColorPicker/UserControls/ColorItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void InitUI()
Content = ColorInfo.ToString()
};

RgbTxt.Text = $"{ColorInfo.RGB.R}; {ColorInfo.RGB.G}; {ColorInfo.RGB.B}"; // Set text
RgbTxt.Text = $"{ColorInfo.RGB.R}{Global.Settings.RgbSeparator}{ColorInfo.RGB.G}{Global.Settings.RgbSeparator}{ColorInfo.RGB.B}"; // Set text
HEXTxt.Text = HexColor; // Set text
}

Expand All @@ -76,7 +76,7 @@ private void ColorBorder_MouseLeftButtonUp(object sender, System.Windows.Input.M
ColorTypes.YIQ => $"{ColorInfo.YIQ.Y}; {ColorInfo.YIQ.I}; {ColorInfo.YIQ.Q}",
ColorTypes.YUV => $"{ColorInfo.YUV.Y}; {ColorInfo.YUV.U}; {ColorInfo.YUV.V}",
ColorTypes.DEC => ColorInfo.DEC.Value.ToString(),
_ => $"{ColorInfo.RGB.R};{ColorInfo.RGB.G};{ColorInfo.RGB.B}"
_ => $"{ColorInfo.RGB.R}{Global.Settings.RgbSeparator}{ColorInfo.RGB.G}{Global.Settings.RgbSeparator}{ColorInfo.RGB.B}"
});
}

Expand All @@ -101,7 +101,7 @@ private void GoBtn_Click(object sender, RoutedEventArgs e)

private void CopyRGB_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText($"{ColorInfo.RGB.R}; {ColorInfo.RGB.G}; {ColorInfo.RGB.B}");
Clipboard.SetText($"{ColorInfo.RGB.R}{Global.Settings.RgbSeparator}{ColorInfo.RGB.G}{Global.Settings.RgbSeparator}{ColorInfo.RGB.B}");
}

private void CopyHEX_Click(object sender, RoutedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions ColorPicker/UserControls/GradientItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ private void InitUI()
linearGradientBrush.GradientStops.Add(new(color, Gradient.Stops[i].Stop));

// Text
if (i == 0) FromTxt.Text = $"{colorInfo.RGB.R}; {colorInfo.RGB.G}; {colorInfo.RGB.B}";
if (i == Gradient.Stops.Count - 1) ToTxt.Text = $"{colorInfo.RGB.R}; {colorInfo.RGB.G}; {colorInfo.RGB.B}";
if (i == 0) FromTxt.Text = $"{colorInfo.RGB.R}{Global.Settings.RgbSeparator}{colorInfo.RGB.G}{Global.Settings.RgbSeparator}{colorInfo.RGB.B}";
if (i == Gradient.Stops.Count - 1) ToTxt.Text = $"{colorInfo.RGB.R}{Global.Settings.RgbSeparator}{colorInfo.RGB.G}{Global.Settings.RgbSeparator}{colorInfo.RGB.B}";

}

Expand Down
4 changes: 2 additions & 2 deletions ColorPicker/UserControls/PaletteItem.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void InitUI()
ColorTypes.YIQ => $"{info.YIQ.Y}; {info.YIQ.I}; {info.YIQ.Q}",
ColorTypes.YUV => $"{info.YUV.Y}; {info.YUV.U}; {info.YUV.V}",
ColorTypes.DEC => info.DEC.Value.ToString(),
_ => $"{shades[j].R};{shades[j].G};{shades[j].B}"
_ => $"{shades[j].R}{Global.Settings.RgbSeparator}{shades[j].G}{Global.Settings.RgbSeparator}{shades[j].B}"
});
};

Expand All @@ -141,7 +141,7 @@ private void ColorBorder_MouseLeftButtonUp(object sender, System.Windows.Input.M
ColorTypes.YIQ => $"{ColorInfo.YIQ.Y}; {ColorInfo.YIQ.I}; {ColorInfo.YIQ.Q}",
ColorTypes.YUV => $"{ColorInfo.YUV.Y}; {ColorInfo.YUV.U}; {ColorInfo.YUV.V}",
ColorTypes.DEC => ColorInfo.DEC.Value.ToString(),
_ => $"{ColorInfo.RGB.R};{ColorInfo.RGB.G};{ColorInfo.RGB.B}"
_ => $"{ColorInfo.RGB.R}{Global.Settings.RgbSeparator}{ColorInfo.RGB.G}{Global.Settings.RgbSeparator}{ColorInfo.RGB.B}"
});
}

Expand Down
2 changes: 1 addition & 1 deletion ColorPicker/Windows/ColorDetailsWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void InitUI()
CopyYuvBtn.Foreground = BackgroundSolidBrush;

// Details
RgbTxt.Text = $"{ColorInfo.RGB.R}; {ColorInfo.RGB.G}; {ColorInfo.RGB.B}";
RgbTxt.Text = $"{ColorInfo.RGB.R}{Global.Settings.RgbSeparator}{ColorInfo.RGB.G}{Global.Settings.RgbSeparator}{ColorInfo.RGB.B}";
HexTxt.Text = $"#{ColorInfo.HEX.Value}";
HsvTxt.Text = $"{ColorInfo.HSV.H}, {ColorInfo.HSV.S}, {ColorInfo.HSV.V}";
HslTxt.Text = $"{ColorInfo.HSL.H}, {ColorInfo.HSL.S}, {ColorInfo.HSL.L}";
Expand Down

0 comments on commit 17b06f6

Please sign in to comment.