Skip to content

Commit

Permalink
Added RGB separator system (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jan 14, 2024
1 parent ea9cc51 commit 1439731
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ColorPicker/Classes/ColorInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ColorInfo(RGB rgb)

public override string ToString()
{
return $"{Properties.Resources.RGB}: {RGB.R};{RGB.G};{RGB.B}\n" +
return $"{Properties.Resources.RGB}: {RGB.R}{Global.Settings.RgbSeparator}{RGB.G}{Global.Settings.RgbSeparator}{RGB.B}\n" +
$"{Properties.Resources.HEX}: {(HEX.Value.StartsWith("#") ? "" : "#")}{HEX.Value}\n" +
$"{Properties.Resources.HSV}: {HSV.H},{HSV.S},{HSV.V}\n" +
$"{Properties.Resources.HSL}: {HSL.H},{HSL.S},{HSL.L}\n" +
Expand Down
2 changes: 2 additions & 0 deletions ColorPicker/Classes/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Settings()
ApiKey = "";
Model = "gpt-3.5-turbo";
SupportedModels = new[] { "gpt-3.5-turbo", "gpt-4" };
RgbSeparator = ";";
}

public Themes Theme { get; set; }
Expand All @@ -67,5 +68,6 @@ public Settings()
public string? ApiKey { get; set; }
public string? Model { get; set; }
public string[]? SupportedModels { get; set; }
public string? RgbSeparator { get; set; }
}
}
2 changes: 1 addition & 1 deletion ColorPicker/Pages/AiGenPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ internal void LoadDetails()
EmptyPlaceholder.Visibility = Visibility.Collapsed;

// Load the details section
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
2 changes: 1 addition & 1 deletion ColorPicker/Pages/ChromaticWheelPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void LoadDetails(ColorInfo colorInfo)
ColorBorder.Effect = new DropShadowEffect() { BlurRadius = 15, ShadowDepth = 0, Color = Color.FromRgb(colorInfo.RGB.R, colorInfo.RGB.G, colorInfo.RGB.B) };

ColorInfo = colorInfo;
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
4 changes: 2 additions & 2 deletions ColorPicker/Pages/ConverterPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private RGB ConvertToRgb()
internal void LoadDetails(bool setColor = false)
{
if (!setColor) ColorInfo = new ColorInfo(ConvertToRgb());
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 Expand Up @@ -384,7 +384,7 @@ private void Txt1_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
}
else
{
var split = text.Split(";");
var split = text.Split(new string[] { ";", Global.Settings.RgbSeparator ?? ";" }, StringSplitOptions.None);
Txt1.Text = split[0];
Txt2.Text = split[1];
Txt3.Text = split[2];
Expand Down
3 changes: 2 additions & 1 deletion ColorPicker/Pages/GradientPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using ColorPicker.Enums;
using ColorPicker.Windows;
using Synethia;
using System;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -398,7 +399,7 @@ private void Txt1_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
}
else
{
var split = text.Split(";");
var split = text.Split(new string[] { ";", Global.Settings.RgbSeparator ?? ";" }, StringSplitOptions.None);
Txt1.Text = split[0];
Txt2.Text = split[1];
Txt3.Text = split[2];
Expand Down
3 changes: 2 additions & 1 deletion ColorPicker/Pages/HarmoniesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using ColorPicker.Enums;
using ColorPicker.Windows;
using Synethia;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
Expand Down Expand Up @@ -411,7 +412,7 @@ private void Txt1_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
}
else
{
var split = text.Split(";");
var split = text.Split(new string[] { ";", Global.Settings.RgbSeparator ?? ";" }, StringSplitOptions.None);
Txt1.Text = split[0];
Txt2.Text = split[1];
Txt3.Text = split[2];
Expand Down
5 changes: 3 additions & 2 deletions ColorPicker/Pages/PalettePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using ColorPicker.Enums;
using ColorPicker.Windows;
using Synethia;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
Expand Down Expand Up @@ -315,7 +316,7 @@ internal void InitPaletteUI(bool setColor = false)
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 Down Expand Up @@ -383,7 +384,7 @@ private void Txt1_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
}
else
{
var split = text.Split(";");
var split = text.Split(new string[] { ";", Global.Settings.RgbSeparator ?? ";" }, StringSplitOptions.None);
Txt1.Text = split[0];
Txt2.Text = split[1];
Txt3.Text = split[2];
Expand Down
2 changes: 1 addition & 1 deletion ColorPicker/Pages/SelectorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ internal void LoadDetails()
2 => new ColorInfo(ColorHelper.ColorConverter.HslToRgb(new((int)RedSlider.Value, (byte)GreenSlider.Value, (byte)BlueSlider.Value))),
_ => new ColorInfo(new((byte)RedSlider.Value, (byte)GreenSlider.Value, (byte)BlueSlider.Value))
};
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
3 changes: 2 additions & 1 deletion ColorPicker/Pages/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private async void InitUI()
_ => SystemBorder
}, null);

// Load the default color type
// Load the color option section
Global.Settings.RgbSeparator ??= ";";
ColorTypeComboBox.SelectedIndex = (int)Global.Settings.DefaultColorType;

// Load the default page ComboBox
Expand Down
2 changes: 1 addition & 1 deletion ColorPicker/Pages/TextPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ private void Txt1_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
}
else
{
var split = text.Split(";");
var split = text.Split(new string[] { ";", Global.Settings.RgbSeparator ?? ";" }, StringSplitOptions.None);
Txt1.Text = split[0];
Txt2.Text = split[1];
Txt3.Text = split[2];
Expand Down

0 comments on commit 1439731

Please sign in to comment.