Skip to content

Commit

Permalink
Added the possibility to bookmark a color in Harmonies page (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpeyr committed Dec 10, 2023
1 parent 286977c commit 28d8c9e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 11 deletions.
20 changes: 19 additions & 1 deletion ColorPicker/Pages/HarmoniesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,25 @@
</Grid>
</Border>
</StackPanel>

<Button
x:Name="BookmarkBtn"
Grid.Column="3"
Padding="5"
VerticalAlignment="Top"
Background="{Binding Source={StaticResource Background3}}"
Click="BookmarkBtn_Click"
Content="&#xF1F6;"
FontFamily="..\Fonts\#FluentSystemIcons-Regular"
Foreground="{Binding Source={StaticResource Foreground1}}"
Style="{DynamicResource DefaultButton}">
<Button.ToolTip>
<ToolTip
x:Name="BookmarkToolTip"
Background="{Binding Source={StaticResource Background1}}"
Content="{x:Static lang:Resources.AddBookmark}"
Foreground="{Binding Source={StaticResource Foreground1}}" />
</Button.ToolTip>
</Button>
</Grid>
</Border>
<StackPanel Grid.Row="2">
Expand Down
45 changes: 35 additions & 10 deletions ColorPicker/Pages/HarmoniesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE

namespace ColorPicker.Pages
{
/// <summary>
/// Interaction logic for HarmoniesPage.xaml
/// </summary>
public partial class HarmoniesPage : Page
{
/// <summary>
/// Interaction logic for HarmoniesPage.xaml
/// </summary>
public partial class HarmoniesPage : Page
{
bool code = Global.Settings.UseSynethia ? false : true; // checks if the code as already been implemented
public HarmoniesPage()
{
InitializeComponent();
InitUI();
{
InitializeComponent();
InitUI();
Loaded += (o, e) => SynethiaManager.InjectSynethiaCode(this, Global.SynethiaConfig.PagesInfo, 7, ref code); // injects the code in the page
}

private void InitUI()
{
private void InitUI()
{
TitleTxt.Text = $"{Properties.Resources.Creation} > {Properties.Resources.Harmonies}";
try
{
Expand Down Expand Up @@ -179,6 +179,16 @@ internal void InitHarmonies()

MonochromaticPanel.Children.Add(border);
}

// Load the bookmark icon
if (!Global.Bookmarks.ColorBookmarks.Contains($"#{ColorInfo.HEX.Value}"))
{
BookmarkBtn.Content = "\uF1F6";
BookmarkToolTip.Content = Properties.Resources.AddBookmark;
return;
}
BookmarkBtn.Content = "\uF1F8";
BookmarkToolTip.Content = Properties.Resources.RemoveBookmark;
}

internal ColorInfo ColorInfo { get; set; }
Expand Down Expand Up @@ -439,5 +449,20 @@ private void ComplementaryBorder_MouseLeftButtonUp(object sender, MouseButtonEve
{
new ColorDetailsWindow((SolidColorBrush)((Border)sender).Background).Show();
}

private void BookmarkBtn_Click(object sender, RoutedEventArgs e)
{
if (Global.Bookmarks.ColorBookmarks.Contains($"#{ColorInfo.HEX.Value}"))
{
Global.Bookmarks.ColorBookmarks.Remove($"#{ColorInfo.HEX.Value}");
BookmarkBtn.Content = "\uF1F6";
BookmarkToolTip.Content = Properties.Resources.AddBookmark;

return;
}
Global.Bookmarks.ColorBookmarks.Add($"#{ColorInfo.HEX.Value}"); // Add to color bookmarks
BookmarkBtn.Content = "\uF1F8";
BookmarkToolTip.Content = Properties.Resources.RemoveBookmark;
}
}
}

0 comments on commit 28d8c9e

Please sign in to comment.