Browse Source

Added favourite palettes

Krzysztof Krysiński 3 years ago
parent
commit
eda01cfafa

BIN
PixiEditor/Images/Star-filled.png


BIN
PixiEditor/Images/Star.png


+ 6 - 1
PixiEditor/Models/DataHolders/Palettes/FilteringSettings.cs

@@ -10,11 +10,14 @@ namespace PixiEditor.Models.DataHolders.Palettes
         public int ColorsCount { get; set; }
         public int ColorsCount { get; set; }
         public string Name { get; set; }
         public string Name { get; set; }
 
 
-        public FilteringSettings(ColorsNumberMode colorsNumberMode, int colorsCount, string name)
+        public bool ShowOnlyFavourites { get; set; }
+
+        public FilteringSettings(ColorsNumberMode colorsNumberMode, int colorsCount, string name, bool showOnlyFavourites)
         {
         {
             ColorsNumberMode = colorsNumberMode;
             ColorsNumberMode = colorsNumberMode;
             ColorsCount = colorsCount;
             ColorsCount = colorsCount;
             Name = name;
             Name = name;
+            ShowOnlyFavourites = showOnlyFavourites;
         }
         }
 
 
         public bool Filter(Palette palette)
         public bool Filter(Palette palette)
@@ -22,6 +25,8 @@ namespace PixiEditor.Models.DataHolders.Palettes
             // Lexical comparison
             // Lexical comparison
             bool result = string.IsNullOrWhiteSpace(Name) || palette.Title.Contains(Name, StringComparison.OrdinalIgnoreCase);
             bool result = string.IsNullOrWhiteSpace(Name) || palette.Title.Contains(Name, StringComparison.OrdinalIgnoreCase);
 
 
+            result = (ShowOnlyFavourites && palette.IsFavourite) || !ShowOnlyFavourites;
+
             switch (ColorsNumberMode)
             switch (ColorsNumberMode)
             {
             {
                 case ColorsNumberMode.Any:
                 case ColorsNumberMode.Any:

+ 2 - 0
PixiEditor/Models/DataHolders/Palettes/Palette.cs

@@ -11,6 +11,8 @@ namespace PixiEditor.Models.DataHolders.Palettes
         public List<string> Colors { get; set; }
         public List<string> Colors { get; set; }
         public string FileName { get; set; }
         public string FileName { get; set; }
 
 
+        public bool IsFavourite { get; set; }
+
         public Palette(string title, List<string> colors, string fileName)
         public Palette(string title, List<string> colors, string fileName)
         {
         {
             Title = title;
             Title = title;

+ 12 - 5
PixiEditor/Models/DataProviders/LocalPalettesFetcher.cs

@@ -7,6 +7,7 @@ using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using PixiEditor.Models.UserPreferences;
 
 
 namespace PixiEditor.Models.DataProviders
 namespace PixiEditor.Models.DataProviders
 {
 {
@@ -60,11 +61,17 @@ namespace PixiEditor.Models.DataProviders
                 var foundParser = AvailableParsers.First(x => x.SupportedFileExtensions.Contains(extension));
                 var foundParser = AvailableParsers.First(x => x.SupportedFileExtensions.Contains(extension));
                 {
                 {
                     PaletteFileData fileData = await foundParser.Parse(file);
                     PaletteFileData fileData = await foundParser.Parse(file);
-                    result.Add(
-                        new Palette(
-                            fileData.Title,
-                            new List<string>(fileData.GetHexColors()),
-                            Path.GetFileName(file)));
+                    var palette = new Palette(
+                        fileData.Title,
+                        new List<string>(fileData.GetHexColors()),
+                        Path.GetFileName(file));
+                    List<string> favouritePalettes = IPreferences.Current.GetLocalPreference<List<string>>(PreferencesConstants.FavouritePalettes);
+                    if (favouritePalettes != null)
+                    {
+                        palette.IsFavourite = favouritePalettes.Contains(palette.Title);
+                    }
+
+                    result.Add(palette);
                 }
                 }
             }
             }
 
 

+ 6 - 0
PixiEditor/Models/UserPreferences/PreferencesConstants.cs

@@ -0,0 +1,6 @@
+namespace PixiEditor.Models.UserPreferences;
+
+public static class PreferencesConstants
+{
+    public const string FavouritePalettes = "FavouritePalettes";
+}

+ 16 - 6
PixiEditor/Models/UserPreferences/PreferencesSettings.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.IO;
 using System.IO;
 using Newtonsoft.Json;
 using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using PixiEditor.ViewModels;
 using PixiEditor.ViewModels;
 
 
 namespace PixiEditor.Models.UserPreferences
 namespace PixiEditor.Models.UserPreferences
@@ -136,9 +137,7 @@ namespace PixiEditor.Models.UserPreferences
 
 
             try
             try
             {
             {
-                return Preferences.ContainsKey(name)
-                        ? (T)Convert.ChangeType(Preferences[name], typeof(T))
-                        : fallbackValue;
+                return GetValue(Preferences, name, fallbackValue);
             }
             }
             catch (InvalidCastException)
             catch (InvalidCastException)
             {
             {
@@ -163,9 +162,7 @@ namespace PixiEditor.Models.UserPreferences
 
 
             try
             try
             {
             {
-                return LocalPreferences.ContainsKey(name)
-                    ? (T)Convert.ChangeType(LocalPreferences[name], typeof(T))
-                    : fallbackValue;
+                return GetValue(LocalPreferences, name, fallbackValue);
             }
             }
             catch (InvalidCastException)
             catch (InvalidCastException)
             {
             {
@@ -176,6 +173,19 @@ namespace PixiEditor.Models.UserPreferences
             }
             }
         }
         }
 
 
+        private T? GetValue<T>(Dictionary<string, object> dict, string name, T? fallbackValue)
+        {
+            if (!dict.ContainsKey(name)) return fallbackValue;
+            var preference = dict[name];
+            if(typeof(T) == preference.GetType()) return (T)preference;
+            if (preference.GetType() == typeof(JArray))
+            {
+                return ((JArray)preference).ToObject<T>();
+            }
+
+            return (T)Convert.ChangeType(dict[name], typeof(T));
+        }
+
 #nullable disable
 #nullable disable
 
 
         private static string GetPathToSettings(Environment.SpecialFolder folder, string fileName)
         private static string GetPathToSettings(Environment.SpecialFolder folder, string fileName)

+ 4 - 0
PixiEditor/PixiEditor.csproj

@@ -259,6 +259,10 @@
 		<Resource Include="Images\Plus-square.png" />
 		<Resource Include="Images\Plus-square.png" />
 		<None Remove="Images\Save.png" />
 		<None Remove="Images\Save.png" />
 		<Resource Include="Images\Save.png" />
 		<Resource Include="Images\Save.png" />
+		<None Remove="Images\Star.png" />
+		<Resource Include="Images\Star.png" />
+		<None Remove="Images\Star-filled.png" />
+		<Resource Include="Images\Star-filled.png" />
 	</ItemGroup>
 	</ItemGroup>
 	<ItemGroup>
 	<ItemGroup>
 		<None Include="..\LICENSE">
 		<None Include="..\LICENSE">

+ 1 - 1
PixiEditor/Styles/DarkCheckboxStyle.xaml

@@ -11,7 +11,7 @@
                 <ControlTemplate TargetType="CheckBox">
                 <ControlTemplate TargetType="CheckBox">
                     <BulletDecorator Background="Transparent">
                     <BulletDecorator Background="Transparent">
                         <BulletDecorator.Bullet>
                         <BulletDecorator.Bullet>
-                            <Border x:Name="Border" Width="18" Height="18" CornerRadius="2" Background="#FF1B1B1B"
+                            <Border x:Name="Border" Width="24" Height="24" CornerRadius="2.5" Background="#FF1B1B1B"
                                     BorderThickness="1">
                                     BorderThickness="1">
                                 <Path Width="9" Height="9" x:Name="CheckMark" SnapsToDevicePixels="False" Stroke="{StaticResource UIElementBlue}" StrokeThickness="1.5" Data="M 0 4 L 3 8 8 0" />
                                 <Path Width="9" Height="9" x:Name="CheckMark" SnapsToDevicePixels="False" Stroke="{StaticResource UIElementBlue}" StrokeThickness="1.5" Data="M 0 4 L 3 8 8 0" />
                             </Border>
                             </Border>

+ 2 - 2
PixiEditor/Styles/ThemeStyle.xaml

@@ -131,6 +131,7 @@
     <Style TargetType="Button" x:Key="ImageButtonStyle">
     <Style TargetType="Button" x:Key="ImageButtonStyle">
         <Setter Property="OverridesDefaultStyle" Value="True" />
         <Setter Property="OverridesDefaultStyle" Value="True" />
         <Setter Property="Focusable" Value="False" />
         <Setter Property="Focusable" Value="False" />
+        <Setter Property="Cursor" Value="Hand" />
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="Button">
                 <ControlTemplate TargetType="Button">
@@ -152,8 +153,7 @@
            BasedOn="{StaticResource BaseDarkButton}">
            BasedOn="{StaticResource BaseDarkButton}">
         <Setter Property="TextBlock.FontFamily" Value="Segoe MDL2 Assets"/>
         <Setter Property="TextBlock.FontFamily" Value="Segoe MDL2 Assets"/>
         <Setter Property="TextBlock.FontSize" Value="15"/>
         <Setter Property="TextBlock.FontSize" Value="15"/>
-        <Setter Property="Focusable" Value="False" />
-        <Setter Property="TextBlock.Width" Value="30"/>
+        <Setter Property="Width" Value="30"/>
 
 
         <Style.Triggers>
         <Style.Triggers>
             <Trigger Property="IsEnabled" Value="True">
             <Trigger Property="IsEnabled" Value="True">

+ 5 - 2
PixiEditor/Views/Dialogs/PalettesBrowser.xaml

@@ -7,7 +7,7 @@
              mc:Ignorable="d" 
              mc:Ignorable="d" 
              xmlns:gif="http://wpfanimatedgif.codeplex.com" xmlns:usercontrols="clr-namespace:PixiEditor.Views.UserControls" xmlns:views="clr-namespace:PixiEditor.Views"
              xmlns:gif="http://wpfanimatedgif.codeplex.com" xmlns:usercontrols="clr-namespace:PixiEditor.Views.UserControls" xmlns:views="clr-namespace:PixiEditor.Views"
              xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
              xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
-             Title="Palettes Browser" WindowStartupLocation="CenterScreen" MinWidth="200" Height="600" Width="825" WindowStyle="None"
+             Title="Palettes Browser" WindowStartupLocation="CenterScreen" MinWidth="200" Height="600" Width="850" WindowStyle="None"
              Name="palettesBrowser">
              Name="palettesBrowser">
     <Window.Resources>
     <Window.Resources>
         <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
         <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
@@ -72,7 +72,7 @@
                                        Text="{Binding ElementName=palettesBrowser, Path=NameFilter,
                                        Text="{Binding ElementName=palettesBrowser, Path=NameFilter,
                                        Delay=100, UpdateSourceTrigger=PropertyChanged}"
                                        Delay=100, UpdateSourceTrigger=PropertyChanged}"
                                        VerticalAlignment="Center"
                                        VerticalAlignment="Center"
-                                       Style="{StaticResource DarkTextBoxStyle}" Width="200" />
+                                       Style="{StaticResource DarkTextBoxStyle}" Width="150" />
 
 
                 <Label Margin="10 0 0 0" Content="Colors:" Style="{StaticResource BaseLabel}" VerticalAlignment="Center" FontSize="16"/>
                 <Label Margin="10 0 0 0" Content="Colors:" Style="{StaticResource BaseLabel}" VerticalAlignment="Center" FontSize="16"/>
                 <ComboBox Name="colorsComboBox" FontSize="16" VerticalAlignment="Center" SelectionChanged="ColorsComboBox_SelectionChanged">
                 <ComboBox Name="colorsComboBox" FontSize="16" VerticalAlignment="Center" SelectionChanged="ColorsComboBox_SelectionChanged">
@@ -84,6 +84,8 @@
                 <views:NumberInput Width="50" FontSize="16" VerticalAlignment="Center" Margin="10 0 0 0"
                 <views:NumberInput Width="50" FontSize="16" VerticalAlignment="Center" Margin="10 0 0 0"
                                    FocusNext="True"
                                    FocusNext="True"
                                    Value="{Binding ElementName=palettesBrowser, Path=ColorsNumber, Mode=TwoWay}"/>
                                    Value="{Binding ElementName=palettesBrowser, Path=ColorsNumber, Mode=TwoWay}"/>
+                <CheckBox Margin="10 0 0 0" VerticalAlignment="Center" FontSize="16"
+                          IsChecked="{Binding ElementName=palettesBrowser, Path=ShowOnlyFavourites}">Favourites</CheckBox>
             </StackPanel>
             </StackPanel>
             <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 0 10 0">
             <StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 0 10 0">
                 <Button ToolTip="Add from current palette" Click="AddFromPalette_OnClick" Cursor="Hand" Margin="10 0" Style="{StaticResource ImageButtonStyle}" Width="24" Height="24">
                 <Button ToolTip="Add from current palette" Click="AddFromPalette_OnClick" Cursor="Hand" Margin="10 0" Style="{StaticResource ImageButtonStyle}" Width="24" Height="24">
@@ -106,6 +108,7 @@
                         <DataTemplate>
                         <DataTemplate>
                             <local:PaletteItem Palette="{Binding}"
                             <local:PaletteItem Palette="{Binding}"
                                                OnRename="PaletteItem_OnRename"
                                                OnRename="PaletteItem_OnRename"
+                                               ToggleFavouriteCommand="{Binding ElementName=palettesBrowser, Path=ToggleFavouriteCommand}"
                                                DeletePaletteCommand="{Binding DeletePaletteCommand, ElementName=palettesBrowser}"
                                                DeletePaletteCommand="{Binding DeletePaletteCommand, ElementName=palettesBrowser}"
                                                ImportPaletteCommand="{Binding ImportPaletteCommand, ElementName=palettesBrowser}"/>
                                                ImportPaletteCommand="{Binding ImportPaletteCommand, ElementName=palettesBrowser}"/>
                         </DataTemplate>
                         </DataTemplate>

+ 53 - 8
PixiEditor/Views/Dialogs/PalettesBrowser.xaml.cs

@@ -4,6 +4,7 @@ using PixiEditor.Models.DataProviders;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Events;
 using PixiEditor.Models.Events;
 using System;
 using System;
+using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
@@ -17,6 +18,7 @@ using PixiEditor.Views.UserControls.Palettes;
 using SkiaSharp;
 using SkiaSharp;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
 using PixiEditor.Models.Dialogs;
 using PixiEditor.Models.Dialogs;
+using PixiEditor.Models.UserPreferences;
 
 
 namespace PixiEditor.Views.Dialogs
 namespace PixiEditor.Views.Dialogs
 {
 {
@@ -119,14 +121,25 @@ namespace PixiEditor.Views.Dialogs
             set { SetValue(NameFilterProperty, value); }
             set { SetValue(NameFilterProperty, value); }
         }
         }
 
 
-        public RelayCommand AddFromPaletteCommand;
+        public static readonly DependencyProperty ShowOnlyFavouritesProperty = DependencyProperty.Register(
+            "ShowOnlyFavourites", typeof(bool), typeof(PalettesBrowser),
+            new PropertyMetadata(false, OnShowOnlyFavouritesChanged));
+
+        public bool ShowOnlyFavourites
+        {
+            get { return (bool)GetValue(ShowOnlyFavouritesProperty); }
+            set { SetValue(ShowOnlyFavouritesProperty, value); }
+        }
+
+        public RelayCommand<Palette> ToggleFavouriteCommand { get; set; }
 
 
         public string SortingType { get; set; } = "Default";
         public string SortingType { get; set; } = "Default";
         public ColorsNumberMode ColorsNumberMode { get; set; } = ColorsNumberMode.Any;
         public ColorsNumberMode ColorsNumberMode { get; set; } = ColorsNumberMode.Any;
 
 
         private FilteringSettings _filteringSettings;
         private FilteringSettings _filteringSettings;
 
 
-        public FilteringSettings Filtering => _filteringSettings ??= new FilteringSettings(ColorsNumberMode, ColorsNumber, NameFilter);
+        public FilteringSettings Filtering => _filteringSettings ??=
+            new FilteringSettings(ColorsNumberMode, ColorsNumber, NameFilter, ShowOnlyFavourites);
 
 
         private char[] _separators = new char[] { ' ', ',' };
         private char[] _separators = new char[] { ' ', ',' };
 
 
@@ -138,12 +151,30 @@ namespace PixiEditor.Views.Dialogs
         {
         {
             InitializeComponent();
             InitializeComponent();
             Instance = this;
             Instance = this;
-            DeletePaletteCommand = new RelayCommand<Palette>(DeletePalettte);
-            AddFromPaletteCommand = new RelayCommand(AddFromPalette);
+            DeletePaletteCommand = new RelayCommand<Palette>(DeletePalette);
+            ToggleFavouriteCommand = new RelayCommand<Palette>(ToggleFavourite);
             Closed += (s, e) => Instance = null;
             Closed += (s, e) => Instance = null;
         }
         }
 
 
-        private async void DeletePalettte(Palette palette)
+        private async void ToggleFavourite(Palette palette)
+        {
+            palette.IsFavourite = !palette.IsFavourite;
+            var favouritePalettes = IPreferences.Current.GetLocalPreference(PreferencesConstants.FavouritePalettes, new List<string>());
+
+            if (palette.IsFavourite)
+            {
+                favouritePalettes.Add(palette.Title);
+            }
+            else
+            {
+                favouritePalettes.Remove(palette.Title);
+            }
+
+            IPreferences.Current.UpdateLocalPreference(PreferencesConstants.FavouritePalettes, favouritePalettes);
+            await UpdatePaletteList();
+        }
+
+        private async void DeletePalette(Palette palette)
         {
         {
             if (palette == null) return;
             if (palette == null) return;
 
 
@@ -153,6 +184,7 @@ namespace PixiEditor.Views.Dialogs
                 if (ConfirmationDialog.Show("Are you sure you want to delete this palette? This cannot be undone.", "Warning!") == ConfirmationType.Yes)
                 if (ConfirmationDialog.Show("Are you sure you want to delete this palette? This cannot be undone.", "Warning!") == ConfirmationType.Yes)
                 {
                 {
                     File.Delete(filePath);
                     File.Delete(filePath);
+                    RemoveFavouritePalette(palette);
 
 
                     LocalPalettesFetcher paletteListDataSource = (LocalPalettesFetcher)PaletteListDataSources.First(x => x is LocalPalettesFetcher);
                     LocalPalettesFetcher paletteListDataSource = (LocalPalettesFetcher)PaletteListDataSources.First(x => x is LocalPalettesFetcher);
                     await paletteListDataSource.RefreshCache();
                     await paletteListDataSource.RefreshCache();
@@ -161,14 +193,27 @@ namespace PixiEditor.Views.Dialogs
             }
             }
         }
         }
 
 
+        private static void RemoveFavouritePalette(Palette palette)
+        {
+            var favouritePalettes =
+                IPreferences.Current.GetLocalPreference<List<string>>(PreferencesConstants.FavouritePalettes);
+            if (favouritePalettes != null && favouritePalettes.Contains(palette.Title))
+            {
+                favouritePalettes.Remove(palette.Title);
+                IPreferences.Current.UpdateLocalPreference(PreferencesConstants.FavouritePalettes, favouritePalettes);
+            }
+        }
+
         private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
         private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
         {
         {
             e.CanExecute = true;
             e.CanExecute = true;
         }
         }
 
 
-        private void AddFromPalette(object obj)
+        private async static void OnShowOnlyFavouritesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
         {
         {
-            
+            PalettesBrowser browser = (PalettesBrowser)d;
+            browser.Filtering.ShowOnlyFavourites = (bool)e.NewValue;
+            await browser.UpdatePaletteList();
         }
         }
 
 
         private void CommandBinding_Executed_Close(object sender, ExecutedRoutedEventArgs e)
         private void CommandBinding_Executed_Close(object sender, ExecutedRoutedEventArgs e)
@@ -292,7 +337,7 @@ namespace PixiEditor.Views.Dialogs
                 switch (_sortingType)
                 switch (_sortingType)
                 {
                 {
                     case Models.DataHolders.Palettes.SortingType.Default:
                     case Models.DataHolders.Palettes.SortingType.Default:
-                        sorted = PaletteList.Palettes.OrderBy(x => PaletteList.Palettes.IndexOf(x));
+                        sorted = PaletteList.Palettes.OrderByDescending(x => x.IsFavourite).ThenBy(x => PaletteList.Palettes.IndexOf(x));
                         break;
                         break;
                     case Models.DataHolders.Palettes.SortingType.Alphabetical:
                     case Models.DataHolders.Palettes.SortingType.Alphabetical:
                         sorted = PaletteList.Palettes.OrderBy(x => x.Title);
                         sorted = PaletteList.Palettes.OrderBy(x => x.Title);

+ 25 - 2
PixiEditor/Views/UserControls/Palettes/PaletteItem.xaml

@@ -12,7 +12,7 @@
     <Grid Background="{StaticResource AccentColor}">
     <Grid Background="{StaticResource AccentColor}">
         <Grid.ColumnDefinitions>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="100*"/>
             <ColumnDefinition Width="100*"/>
-            <ColumnDefinition Width="75"/>
+            <ColumnDefinition Width="95"/>
         </Grid.ColumnDefinitions>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition Height="60"/>
             <RowDefinition Height="60"/>
@@ -27,7 +27,6 @@
                 </Button>
                 </Button>
             </StackPanel>
             </StackPanel>
             <TextBlock Margin="0 5 0 0">
             <TextBlock Margin="0 5 0 0">
-            <!--<controls:PrependTextBlock PrependColor="Gray" Prepend="Author: " Text="{Binding Palette.User.Name, ElementName=paletteItem}" Foreground="White"/>-->
             </TextBlock>
             </TextBlock>
         </StackPanel>
         </StackPanel>
         <ItemsControl Margin="0 -20 0 10" Grid.Row="1" Grid.Column="0" ItemsSource="{Binding ElementName=paletteItem, Path=Palette.Colors}">
         <ItemsControl Margin="0 -20 0 10" Grid.Row="1" Grid.Column="0" ItemsSource="{Binding ElementName=paletteItem, Path=Palette.Colors}">
@@ -52,6 +51,30 @@
                     <ImageBrush ImageSource="/Images/Download.png"/>
                     <ImageBrush ImageSource="/Images/Download.png"/>
                 </Button.Background>
                 </Button.Background>
             </Button>
             </Button>
+            <Button Margin="2 0 -2 0" Width="24" Height="24" HorizontalAlignment="Right"
+                    Command="{Binding ElementName=paletteItem, Path=ToggleFavouriteCommand}"
+                    CommandParameter="{Binding ElementName=paletteItem, Path=Palette}">
+                <Button.Style>
+                    <Style BasedOn="{StaticResource ImageButtonStyle}" TargetType="Button">
+                        <Style.Triggers>
+                            <DataTrigger Binding="{Binding ElementName=paletteItem, Path=Palette.IsFavourite}" Value="False">
+                                <Setter Property="Background">
+                                    <Setter.Value>
+                                        <ImageBrush ImageSource="/Images/Star.png"/>
+                                    </Setter.Value>
+                                </Setter>
+                            </DataTrigger>
+                            <DataTrigger Binding="{Binding ElementName=paletteItem, Path=Palette.IsFavourite}" Value="True">
+                                <Setter Property="Background">
+                                    <Setter.Value>
+                                        <ImageBrush ImageSource="/Images/Star-filled.png"/>
+                                    </Setter.Value>
+                                </Setter>
+                            </DataTrigger>
+                        </Style.Triggers>
+                    </Style>
+                </Button.Style>
+            </Button>
             <Border Width="28" Height="28" CornerRadius="2.5"
             <Border Width="28" Height="28" CornerRadius="2.5"
                     Margin="5 0 0 0" Padding="2">
                     Margin="5 0 0 0" Padding="2">
                 <Border.Style>
                 <Border.Style>

+ 7 - 1
PixiEditor/Views/UserControls/Palettes/PaletteItem.xaml.cs

@@ -41,8 +41,14 @@ namespace PixiEditor.Views.UserControls.Palettes
         public static readonly DependencyProperty DeletePaletteCommandProperty =
         public static readonly DependencyProperty DeletePaletteCommandProperty =
             DependencyProperty.Register("DeletePaletteCommand", typeof(ICommand), typeof(PaletteItem));
             DependencyProperty.Register("DeletePaletteCommand", typeof(ICommand), typeof(PaletteItem));
 
 
+        public static readonly DependencyProperty ToggleFavouriteCommandProperty = DependencyProperty.Register(
+            "ToggleFavouriteCommand", typeof(ICommand), typeof(PaletteItem), new PropertyMetadata(default(ICommand)));
 
 
-
+        public ICommand ToggleFavouriteCommand
+        {
+            get { return (ICommand)GetValue(ToggleFavouriteCommandProperty); }
+            set { SetValue(ToggleFavouriteCommandProperty, value); }
+        }
 
 
         public event EventHandler<EditableTextBlock.TextChangedEventArgs> OnRename;
         public event EventHandler<EditableTextBlock.TextChangedEventArgs> OnRename;