Skip to content

Commit

Permalink
Added the possibility to get complementary color (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Oct 31, 2023
1 parent 1a5f447 commit 766c613
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ColorPicker/Pages/HarmoniesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,9 @@
Margin="10"
HorizontalAlignment="Left"
d:Background="White"
CornerRadius="10" />
CornerRadius="10"
Cursor="Hand"
MouseLeftButtonUp="ComplementaryBorder_MouseLeftButtonUp" />
</StackPanel>
</Grid>
</Page>
19 changes: 16 additions & 3 deletions ColorPicker/Pages/HarmoniesPage.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 ColorHelper;
using ColorPicker.Classes;
using ColorPicker.Enums;
using ColorPicker.Windows;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -83,10 +84,14 @@ private void InitUI()
internal void InitHarmonies()
{
ColorInfo = new ColorInfo(ConvertToRgb());
ColorBorder.Background = new SolidColorBrush { Color = Color.FromRgb(ColorInfo.RGB.R, ColorInfo.RGB.G, ColorInfo.RGB.B) };
ColorBorder.Effect = new DropShadowEffect() { BlurRadius = 15, ShadowDepth = 0, Color = Color.FromRgb(ColorInfo.RGB.R, ColorInfo.RGB.G, ColorInfo.RGB.B) };

var color = Color.FromRgb(ColorInfo.RGB.R, ColorInfo.RGB.G, ColorInfo.RGB.B);
ColorBorder.Background = new SolidColorBrush { Color = color };
ColorBorder.Effect = new DropShadowEffect() { BlurRadius = 15, ShadowDepth = 0, Color = color };

// Complementary
var complementary = Global.GetComplementaryColor(color);
ComplementaryBorder.Background = new SolidColorBrush { Color = complementary };
ComplementaryBorder.Effect = new DropShadowEffect() { BlurRadius = 15, ShadowDepth = 0, Color = complementary };
}

internal ColorInfo ColorInfo { get; set; }
Expand Down Expand Up @@ -341,5 +346,13 @@ internal void ColorBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs
catch { }
RgbBtn_Click(SelectedColorBtn, null);
}

private void ComplementaryBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
new ColorDetailsWindow(new()
{
Color = Color.FromRgb(ColorInfo.RGB.R, ColorInfo.RGB.G, ColorInfo.RGB.B)
}).Show();
}
}
}

0 comments on commit 766c613

Please sign in to comment.