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

This commit is contained in:
Elias Quinn
2025-06-18 09:13:53 +01:00
parent 40270573ab
commit 6e225465c1
44 changed files with 1506 additions and 1088 deletions

View File

@@ -1,6 +0,0 @@
namespace ShadowStream.Obejeckte;
public class Favorites
{
public List<object> SharedRefs = new List<object>();
}

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,18 @@
namespace ShadowStream.Obejeckte;
public class ObjListBP
{
public List<object> SharedRefs;
private string _name;
public ObjListBP(string name)
{
_name = name;
SharedRefs = new List<object>();
}
public ObjListBP()
{
SharedRefs = new List<object>();
}
}