초기 커밋.
This commit is contained in:
99
Tornado3_2026Election/Domain/ChannelScheduleItem.cs
Normal file
99
Tornado3_2026Election/Domain/ChannelScheduleItem.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI;
|
||||
using Tornado3_2026Election.Common;
|
||||
|
||||
namespace Tornado3_2026Election.Domain;
|
||||
|
||||
public sealed class ChannelScheduleItem : ObservableObject
|
||||
{
|
||||
private ScheduleQueueItemState _state = ScheduleQueueItemState.Queued;
|
||||
private string _lastError = string.Empty;
|
||||
private DateTimeOffset? _lastPlayedAt;
|
||||
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public required string FormatId { get; init; }
|
||||
|
||||
public required string FormatName { get; init; }
|
||||
|
||||
public required string Description { get; init; }
|
||||
|
||||
public required BroadcastChannel Channel { get; init; }
|
||||
|
||||
public required bool RequiresImage { get; init; }
|
||||
|
||||
public required double DefaultCutDurationSeconds { get; init; }
|
||||
|
||||
public required int TotalCuts { get; init; }
|
||||
|
||||
public ScheduleQueueItemState State
|
||||
{
|
||||
get => _state;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _state, value))
|
||||
{
|
||||
OnPropertyChanged(nameof(StateLabel));
|
||||
OnPropertyChanged(nameof(StateBrush));
|
||||
OnPropertyChanged(nameof(CanDelete));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string LastError
|
||||
{
|
||||
get => _lastError;
|
||||
set => SetProperty(ref _lastError, value);
|
||||
}
|
||||
|
||||
public DateTimeOffset? LastPlayedAt
|
||||
{
|
||||
get => _lastPlayedAt;
|
||||
set => SetProperty(ref _lastPlayedAt, value);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public string StateLabel => State switch
|
||||
{
|
||||
ScheduleQueueItemState.Next => "다음",
|
||||
ScheduleQueueItemState.Sending => "준비",
|
||||
ScheduleQueueItemState.OnAir => "송출중",
|
||||
ScheduleQueueItemState.Completed => "완료",
|
||||
ScheduleQueueItemState.Error => "오류",
|
||||
_ => "대기"
|
||||
};
|
||||
|
||||
[JsonIgnore]
|
||||
public SolidColorBrush StateBrush => new(State switch
|
||||
{
|
||||
ScheduleQueueItemState.Next => ColorHelper.FromArgb(255, 255, 145, 77),
|
||||
ScheduleQueueItemState.Sending => ColorHelper.FromArgb(255, 255, 191, 0),
|
||||
ScheduleQueueItemState.OnAir => ColorHelper.FromArgb(255, 202, 52, 52),
|
||||
ScheduleQueueItemState.Completed => ColorHelper.FromArgb(255, 68, 104, 77),
|
||||
ScheduleQueueItemState.Error => ColorHelper.FromArgb(255, 110, 39, 39),
|
||||
_ => ColorHelper.FromArgb(255, 80, 90, 110)
|
||||
});
|
||||
|
||||
[JsonIgnore]
|
||||
public bool CanDelete => State is not ScheduleQueueItemState.OnAir and not ScheduleQueueItemState.Sending;
|
||||
|
||||
[JsonIgnore]
|
||||
public string LastPlayedLabel => LastPlayedAt?.ToString("HH:mm:ss") ?? "not played";
|
||||
|
||||
public static ChannelScheduleItem FromTemplate(FormatTemplateDefinition template)
|
||||
{
|
||||
return new ChannelScheduleItem
|
||||
{
|
||||
FormatId = template.Id,
|
||||
FormatName = template.Name,
|
||||
Description = template.Description,
|
||||
Channel = template.RecommendedChannel,
|
||||
RequiresImage = template.RequiresImage,
|
||||
DefaultCutDurationSeconds = template.Cuts.First().DurationSeconds,
|
||||
TotalCuts = template.Cuts.Count
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user