diff --git a/ShadowStream/Modules/Obejeckte/Favorites.cs b/ShadowStream/Modules/Obejeckte/Favorites.cs deleted file mode 100644 index 80cc2a6..0000000 --- a/ShadowStream/Modules/Obejeckte/Favorites.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace ShadowStream.Obejeckte; - -public class Favorites -{ - public List SharedRefs = new List(); -} \ No newline at end of file diff --git a/ShadowStream/Modules/Obejeckte/Item.cs b/ShadowStream/Modules/Obejeckte/Item.cs index 80baf41..aa3649a 100644 --- a/ShadowStream/Modules/Obejeckte/Item.cs +++ b/ShadowStream/Modules/Obejeckte/Item.cs @@ -1,80 +1,91 @@ -using System.IO; +using System; +using System.ComponentModel; using System.Windows; -using System.Windows.Media.Imaging; using System.Windows.Controls; using System.Windows.Media; +using System.Windows.Media.Imaging; -namespace ShadowStream.Obejeckte; -//Quinn -public class Item +namespace ShadowStream.Obejeckte { - //public data - Label name; - string path; - string type; - BitmapImage image; - Button playButton; - bool isFoto; - - //initilise the item - public Item(string path, string type, BitmapImage image, bool isFoto, RoutedEventHandler clickHandler = null) + // Quinn + public class Item : INotifyPropertyChanged { - this.path = path; - this.type = type; - this.name = new Label() + //playlist + + #region playlist + private bool _isAdded; + public bool IsAdded { - Name = "name", - Content = System.IO.Path.GetFileName(path), - HorizontalAlignment = HorizontalAlignment.Center, - Foreground = Brushes.White - }; - this.image = image; - this.playButton = new Button + get => _isAdded; + set + { + if (_isAdded != value) + { + _isAdded = value; + OnPropertyChanged(nameof(IsAdded)); + } + } + } + + public event PropertyChangedEventHandler PropertyChanged; + protected void OnPropertyChanged(string propName) + => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); + + + #endregion + + + + // Original private fields + Label name; + string path; + string type; + BitmapImage image; + Button playButton; + bool isFoto; + + // Constructor initializes your original fields + public Item(string path, string type, BitmapImage image, bool isFoto, RoutedEventHandler clickHandler = null) { - Content = isFoto ? "Show" : "Play", - HorizontalAlignment = HorizontalAlignment.Center, - Tag = path+"||"+type // Store path or any identifier - }; + this.path = path; + this.type = type; + this.name = new Label() + { + Name = "name", + Content = System.IO.Path.GetFileName(path), + HorizontalAlignment = HorizontalAlignment.Center, + Foreground = Brushes.White + }; + this.image = image; + this.playButton = new Button + { + Content = isFoto ? "Show" : "Play", + HorizontalAlignment = HorizontalAlignment.Center, + Tag = path + "||" + type // Store path or any identifier + }; - if (clickHandler != null) - playButton.Click += clickHandler; + if (clickHandler != null) + playButton.Click += clickHandler; - this.isFoto = isFoto; + this.isFoto = isFoto; + + Console.WriteLine(path); + } + + // Old methods needed by main window + public string getLink() => path; + public string getFormat() => type; + public string getName() => name.Content.ToString(); + public BitmapImage getImage() => image; + public string getType() => type; + public Button getPlayButton() => playButton; + + // new variables for data binding + public string Path => path; + public string Type => type; + public string Name => name.Content.ToString(); + public BitmapImage Image => image; + public bool IsFoto => isFoto; - Console.WriteLine(path); } - - - - //return individual data - public string getLink() - { - return path; - } - - public string getFormat() - { - return type; - } - - public string getName() - { - return name.Content.ToString(); - } - - public BitmapImage getImage() - { - return image; - } - - public string getType() - { - return type; - } - - public Button getPlayButton() - { - return playButton; - } - -} \ No newline at end of file +} diff --git a/ShadowStream/Modules/Obejeckte/ObjListBP.cs b/ShadowStream/Modules/Obejeckte/ObjListBP.cs new file mode 100644 index 0000000..09ffe91 --- /dev/null +++ b/ShadowStream/Modules/Obejeckte/ObjListBP.cs @@ -0,0 +1,18 @@ +namespace ShadowStream.Obejeckte; + +public class ObjListBP +{ + public List SharedRefs; + + private string _name; + + public ObjListBP(string name) + { + _name = name; + SharedRefs = new List(); + } + public ObjListBP() + { + SharedRefs = new List(); + } +} \ No newline at end of file diff --git a/ShadowStream/Views/MainWindow.xaml b/ShadowStream/Views/MainWindow.xaml index 5b074b0..8f3ae04 100644 --- a/ShadowStream/Views/MainWindow.xaml +++ b/ShadowStream/Views/MainWindow.xaml @@ -146,10 +146,11 @@