Files
ersatztv/ErsatzTV/ViewModels/ProgramScheduleItemEditViewModel.cs
T
Jason DoveandGitHub 871a031467 rework television media (#26)
* rework television media

* refactor poster saving

* television and movie views are working again

* remove dead code

* use paper styling for all cards

* add show poster, plot to seasons page

* remove missing shows; cleanup interfaces

* fix split show display (same show in different folders/sources)

* add placeholder "add to schedule" button

* no more duplicate television shows, even with the same show split across sources

* stop releasing CLI for now

* use season number as season placeholder

* add television shows to collections

* add television seasons to collections

* add television episodes to collections

* add movies to collections

* remove movies, shows, seasons, episodes from collections

* fix page width and menus

* fix buffer size defaults

* fix chronological episode ordering

* allow deleting media collections

* don't get stuck building a playout with an empty collection

* schedule editing and playouts work again

* minor cleanup

* remove dead code

* fix bugs with viewing movies as they are loading

* add scanner tests; support nested movie folders

* update collections docs

* rearrange order of schedule items

* add show and season to schedule

* delete schedules that use legacy collections, reset all posters

* move cleanup to new migration

* load fallback metadata when nfo fails; don't require metadata in ui

* update readme and screenshots
2021-02-22 00:54:41 +00:00

100 lines
3.4 KiB
C#

using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using ErsatzTV.Annotations;
using ErsatzTV.Application.MediaCollections;
using ErsatzTV.Application.Television;
using ErsatzTV.Core.Domain;
namespace ErsatzTV.ViewModels
{
public class ProgramScheduleItemEditViewModel : INotifyPropertyChanged
{
private ProgramScheduleItemCollectionType _collectionType;
private int? _multipleCount;
private bool? _offlineTail;
private TimeSpan? _playoutDuration;
private TimeSpan? _startTime;
public int Id { get; set; }
public int Index { get; set; }
public StartType StartType { get; set; }
public TimeSpan? StartTime
{
get => StartType == StartType.Fixed ? _startTime : null;
set => _startTime = value;
}
public PlayoutMode PlayoutMode { get; set; }
public ProgramScheduleItemCollectionType CollectionType
{
get => _collectionType;
set
{
_collectionType = value;
switch (CollectionType)
{
case ProgramScheduleItemCollectionType.Collection:
TelevisionShow = null;
TelevisionSeason = null;
break;
case ProgramScheduleItemCollectionType.TelevisionShow:
MediaCollection = null;
TelevisionSeason = null;
break;
case ProgramScheduleItemCollectionType.TelevisionSeason:
MediaCollection = null;
TelevisionShow = null;
break;
}
OnPropertyChanged(nameof(MediaCollection));
OnPropertyChanged(nameof(TelevisionShow));
OnPropertyChanged(nameof(TelevisionSeason));
}
}
public MediaCollectionViewModel MediaCollection { get; set; }
public TelevisionShowViewModel TelevisionShow { get; set; }
public TelevisionSeasonViewModel TelevisionSeason { get; set; }
public string CollectionName => CollectionType switch
{
ProgramScheduleItemCollectionType.Collection => MediaCollection?.Name,
ProgramScheduleItemCollectionType.TelevisionShow => $"{TelevisionShow?.Title} ({TelevisionShow?.Year})",
ProgramScheduleItemCollectionType.TelevisionSeason =>
$"{TelevisionSeason?.Title} ({TelevisionSeason?.Plot})",
_ => string.Empty
};
public int? MultipleCount
{
get => PlayoutMode == PlayoutMode.Multiple ? _multipleCount : null;
set => _multipleCount = value;
}
public TimeSpan? PlayoutDuration
{
get => PlayoutMode == PlayoutMode.Duration ? _playoutDuration : null;
set => _playoutDuration = value;
}
public bool? OfflineTail
{
get => PlayoutMode == PlayoutMode.Duration ? _offlineTail : null;
set => _offlineTail = value;
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged(
[CallerMemberName]
string propertyName = null) =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}