92 lines
2.6 KiB
C#
92 lines
2.6 KiB
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace ShadowStream.Obejeckte
|
|
{
|
|
// Quinn
|
|
public class Item : INotifyPropertyChanged
|
|
{
|
|
//playlist
|
|
|
|
#region playlist
|
|
private bool _isAdded;
|
|
public bool IsAdded
|
|
{
|
|
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)
|
|
{
|
|
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;
|
|
|
|
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;
|
|
|
|
}
|
|
}
|