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:
@@ -1,6 +0,0 @@
|
||||
namespace ShadowStream.Obejeckte;
|
||||
|
||||
public class Favorites
|
||||
{
|
||||
public List<object> SharedRefs = new List<object>();
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
18
ShadowStream/Modules/Obejeckte/ObjListBP.cs
Normal file
18
ShadowStream/Modules/Obejeckte/ObjListBP.cs
Normal 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>();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user