Skip to content

Commit

Permalink
Added the possibility to set the angle for analogous color harmonies (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Jan 14, 2024
1 parent 17b06f6 commit 12df8af
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 5 deletions.
79 changes: 75 additions & 4 deletions ColorPicker/Pages/HarmoniesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,30 @@
Cursor="Hand"
MouseLeftButtonUp="ComplementaryBorder_MouseLeftButtonUp" />
</StackPanel>
<TextBlock
Margin="5"
FontWeight="Bold"
Text="{x:Static lang:Resources.Analogous}" />
<StackPanel Orientation="Horizontal">
<TextBlock
Margin="5"
FontWeight="Bold"
Text="{x:Static lang:Resources.Analogous}" />
<Button
x:Name="AnalogousSettingsBtn"
Grid.Column="3"
Padding="5"
VerticalAlignment="Center"
Background="{DynamicResource Background3}"
Click="AnalogousSettingsBtn_Click"
Content="&#xF6AA;"
FontFamily="..\Fonts\#FluentSystemIcons-Regular"
Foreground="{DynamicResource Foreground1}"
Style="{DynamicResource DefaultButton}">
<Button.ToolTip>
<ToolTip
Background="{DynamicResource Background1}"
Content="{x:Static lang:Resources.Settings}"
Foreground="{DynamicResource Foreground1}" />
</Button.ToolTip>
</Button>
</StackPanel>
<WrapPanel
x:Name="AnalogousPanel"
Margin="10"
Expand All @@ -494,5 +514,56 @@
Margin="10"
Orientation="Horizontal" />
</StackPanel>
<Popup
x:Name="AnalogousPopup"
AllowsTransparency="True"
Placement="Top"
PlacementTarget="{Binding ElementName=AnalogousSettingsBtn}"
StaysOpen="False">
<Border
Margin="10"
Padding="5"
Background="{DynamicResource CardBackground}"
CornerRadius="10">
<Border.Effect>
<DropShadowEffect
BlurRadius="15"
Opacity="0.2"
ShadowDepth="0"
Color="{DynamicResource Accent}" />
</Border.Effect>
<StackPanel Orientation="Horizontal">
<TextBlock
Margin="0 0 10 0"
VerticalAlignment="Center"
Text="{x:Static lang:Resources.Angle}" />
<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="AngleTxt"
Margin="3"
Padding="3"
Background="Transparent"
BorderThickness="0"
FontWeight="Bold"
Foreground="{DynamicResource DarkGray}"
PreviewTextInput="AngleTxt_PreviewTextInput"
Text="15"
TextAlignment="Center"
TextChanged="AngleTxt_TextChanged" />
</Border>
</StackPanel>
</Border>
</Popup>
</Grid>
</Page>
23 changes: 22 additions & 1 deletion ColorPicker/Pages/HarmoniesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
using ColorPicker.Windows;
using Synethia;
using System;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
Expand Down Expand Up @@ -107,7 +108,7 @@ internal void InitHarmonies()

// Analogous
AnalogousPanel.Children.Clear();
var analogousColors = Global.GenerateAnalogousColors(color, 6, 15);
var analogousColors = Global.GenerateAnalogousColors(color, 6, int.Parse(AngleTxt.Text));
for (int i = 0; i < analogousColors.Length; i++)
{
CornerRadius radius = i == 0 ? new(10, 0, 0, 10) : new(0);
Expand Down Expand Up @@ -455,5 +456,25 @@ private void BookmarkBtn_Click(object sender, RoutedEventArgs e)
BookmarkBtn.Content = "\uF1F8";
BookmarkToolTip.Content = Properties.Resources.RemoveBookmark;
}

private void AnalogousSettingsBtn_Click(object sender, RoutedEventArgs e)
{
AnalogousPopup.IsOpen = true;
}

private void AngleTxt_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
Regex regex = new("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}

private void AngleTxt_TextChanged(object sender, TextChangedEventArgs e)
{
try
{
InitHarmonies();
}
catch { }
}
}
}
9 changes: 9 additions & 0 deletions ColorPicker/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.en-US.resx
Original file line number Diff line number Diff line change
Expand Up @@ -639,4 +639,7 @@
<data name="RgbSeparator" xml:space="preserve">
<value>RGB Separator</value>
</data>
<data name="Angle" xml:space="preserve">
<value>Angle</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.fr-FR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,7 @@
<data name="RgbSeparator" xml:space="preserve">
<value>Séparateur RGB</value>
</data>
<data name="Angle" xml:space="preserve">
<value>Angle</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,7 @@
<data name="RgbSeparator" xml:space="preserve">
<value>RGB Separator</value>
</data>
<data name="Angle" xml:space="preserve">
<value>Angle</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ColorPicker/Properties/Resources.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -647,4 +647,7 @@
<data name="RgbSeparator" xml:space="preserve">
<value>RGB 分色器</value>
</data>
<data name="Angle" xml:space="preserve">
<value>角度</value>
</data>
</root>

0 comments on commit 12df8af

Please sign in to comment.