From 6e225465c1b6c116ca9bd40253c81c45f51e8820 Mon Sep 17 00:00:00 2001 From: Elias Quinn Date: Wed, 18 Jun 2025 09:13:53 +0100 Subject: [PATCH] implementation of playlist logic(favorits or costum) item class is mvvm and normal due to it double usage. playlist are a filterd data grid with check box --- ShadowStream/Modules/Obejeckte/Favorites.cs | 6 - ShadowStream/Modules/Obejeckte/Item.cs | 147 +-- ShadowStream/Modules/Obejeckte/ObjListBP.cs | 18 + ShadowStream/Views/MainWindow.xaml | 5 +- ShadowStream/Views/MainWindow.xaml.cs | 145 ++- ShadowStream/Views/PlaylistEditor.xaml | 57 ++ ShadowStream/Views/PlaylistEditor.xaml.cs | 89 ++ .../bin/Debug/net8.0-windows/ShadowStream.dll | Bin 76288 -> 84480 bytes .../bin/Debug/net8.0-windows/ShadowStream.exe | Bin 138752 -> 138752 bytes .../bin/Debug/net8.0-windows/ShadowStream.pdb | Bin 28640 -> 30816 bytes .../Debug/net8.0-windows/Temp Data/Music.json | 916 ++++++++--------- .../net8.0-windows/Temp Data/Muvies.json | 16 +- .../net8.0-windows/Temp Data/Series.json | 962 +++++++++--------- .../net8.0-windows/file finder test.dll | Bin 17920 -> 17920 bytes .../net8.0-windows/file finder test.exe | Bin 138752 -> 138752 bytes .../net8.0-windows/file finder test.pdb | Bin 14440 -> 14440 bytes .../ShadowStream.AssemblyInfo.cs | 2 +- .../ShadowStream.AssemblyInfoInputs.cache | 2 +- ...hadowStream.csproj.AssemblyReference.cache | Bin 3460 -> 3460 bytes ...hadowStream.csproj.CoreCompileInputs.cache | 2 +- .../ShadowStream.csproj.FileListAbsolute.txt | 2 + .../obj/Debug/net8.0-windows/ShadowStream.dll | Bin 76288 -> 84480 bytes .../net8.0-windows/ShadowStream.g.resources | Bin 12277 -> 15379 bytes .../obj/Debug/net8.0-windows/ShadowStream.pdb | Bin 28640 -> 30816 bytes .../ShadowStream.sourcelink.json | 2 +- .../ShadowStream_MarkupCompile.cache | 6 +- .../net8.0-windows/Views/MainWindow.baml | Bin 7264 -> 7291 bytes .../net8.0-windows/Views/MainWindow.g.cs | 44 +- .../net8.0-windows/Views/PlaylistEditor.baml | Bin 0 -> 3007 bytes .../net8.0-windows/Views/PlaylistEditor.g.cs | 167 +++ .../obj/Debug/net8.0-windows/apphost.exe | Bin 138752 -> 138752 bytes .../Debug/net8.0-windows/ref/ShadowStream.dll | Bin 27648 -> 28672 bytes .../net8.0-windows/refint/ShadowStream.dll | Bin 27648 -> 28672 bytes .../bin/Debug/net8.0/file finder test.dll | Bin 17920 -> 17920 bytes .../bin/Debug/net8.0/file finder test.exe | Bin 138752 -> 138752 bytes .../bin/Debug/net8.0/file finder test.pdb | Bin 14440 -> 14440 bytes .../obj/Debug/net8.0/apphost.exe | Bin 138752 -> 138752 bytes .../net8.0/file finder test.AssemblyInfo.cs | 2 +- ...file finder test.AssemblyInfoInputs.cache | 2 +- .../obj/Debug/net8.0/file finder test.dll | Bin 17920 -> 17920 bytes .../obj/Debug/net8.0/file finder test.pdb | Bin 14440 -> 14440 bytes .../net8.0/file finder test.sourcelink.json | 2 +- .../Debug/net8.0/ref/file finder test.dll | Bin 8704 -> 8704 bytes .../Debug/net8.0/refint/file finder test.dll | Bin 8704 -> 8704 bytes 44 files changed, 1506 insertions(+), 1088 deletions(-) delete mode 100644 ShadowStream/Modules/Obejeckte/Favorites.cs create mode 100644 ShadowStream/Modules/Obejeckte/ObjListBP.cs create mode 100644 ShadowStream/Views/PlaylistEditor.xaml create mode 100644 ShadowStream/Views/PlaylistEditor.xaml.cs create mode 100644 ShadowStream/obj/Debug/net8.0-windows/Views/PlaylistEditor.baml create mode 100644 ShadowStream/obj/Debug/net8.0-windows/Views/PlaylistEditor.g.cs 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 @@