Ui changes - show ProgramGuide

This commit is contained in:
Vova
2024-05-05 19:02:25 +03:00
parent 12289c52f8
commit d179d294a5
7 changed files with 79 additions and 17 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ namespace TV_Player
public string Title { get => _title; set => SetProperty(ref _title, value); }
public DateTime StartTime { get; set; }
public DateTime StopTime { get; set; }
public DateTime EndTime { get; set; }
public int DurationValue { get => _durationValue; set => SetProperty(ref _durationValue, value); }
}
@@ -75,7 +75,7 @@ namespace TV_Player
var id = reader.GetAttribute("channel");
var channel = epgChannels.FirstOrDefault(x => x.Id == id);
program.StartTime = DateTime.ParseExact(reader.GetAttribute("start"), "yyyyMMddHHmmss zzz", null);
program.StopTime = DateTime.ParseExact(reader.GetAttribute("stop"), "yyyyMMddHHmmss zzz", null);
program.EndTime = DateTime.ParseExact(reader.GetAttribute("stop"), "yyyyMMddHHmmss zzz", null);
reader.Read();
program.Title = reader.ReadElementContentAsString();
+1 -1
View File
@@ -66,7 +66,7 @@ namespace TV_Player
}
}
private void OnCloseAppButtonClick()
public void OnCloseAppButtonClick()
{
Environment.Exit(0);
}
+33 -3
View File
@@ -1,4 +1,5 @@
using CommunityToolkit.Mvvm.Input;
using System;
using System.Reactive.Linq;
using System.Windows.Input;
using TV_Player.ViewModels;
@@ -54,12 +55,28 @@ namespace TV_Player
get => _endProgram;
set => SetProperty(ref _endProgram, value);
}
private bool _programGuideVisible;
public bool ProgramGuideVisible
{
get => _programGuideVisible;
set => SetProperty(ref _programGuideVisible, value);
}
List<ProgramInfo> _programsOnCurrentChannel;
public List<ProgramInfo> Programs
{
get => _programsOnCurrentChannel;
set => SetProperty(ref _programsOnCurrentChannel, value);
}
private List<M3UInfo> _programs;
public ICommand BackCommand { get; }
public ICommand FullscreenCommand { get; }
public ICommand NextCommand { get; }
public ICommand PreviousCommand { get; }
public ICommand ShowProgramListCommand { get; }
public ICommand CloseAppCommand { get; }
private ProgramGuide _currentGuide;
private ProgramInfo _currentProgramInfo;
@@ -77,6 +94,9 @@ namespace TV_Player
NextCommand = new RelayCommand(NextProgram);
PreviousCommand = new RelayCommand(PreviousProgram);
FullscreenCommand = new RelayCommand(TVPlayerViewModel.Instance.FullScreenToggle);
CloseAppCommand = new RelayCommand(TVPlayerViewModel.Instance.CloseAppCommand);
ShowProgramListCommand = new RelayCommand(ShowProgramList);
ProgramGuideVisible = false;
_programSubscriber = TVPlayerViewModel.Instance.PlaylistData.AllPrograms.Subscribe(x =>
{
@@ -101,6 +121,7 @@ namespace TV_Player
try
{
_currentGuide = x.FirstOrDefault(p => p.Id == _currentProgram.TvgID);
UpdateScreenInfo();
_timer = Observable.Interval(TimeSpan.FromMinutes(1)).Subscribe(x =>
@@ -121,6 +142,7 @@ namespace TV_Player
_programGuideDisposable?.Dispose();
UpdateUI();
}
private void NextProgram()
{
_currentProgramIndex += 1;
@@ -130,11 +152,19 @@ namespace TV_Player
_programGuideDisposable?.Dispose();
UpdateUI();
}
private void ShowProgramList()
{
ProgramGuideVisible = true;
}
private void UpdateScreenInfo()
{
try
{
_currentProgramInfo = _currentGuide.Programs.FirstOrDefault(d => d.StartTime <= DateTime.Now && d.StopTime >= DateTime.Now);
_currentProgramInfo = _currentGuide.Programs.FirstOrDefault(d => d.StartTime <= DateTime.Now && d.EndTime >= DateTime.Now);
Programs = _currentGuide.Programs.Skip(_currentGuide.Programs.FindIndex(x=>x.Title==_currentProgramInfo.Title)).Take(7).ToList();
if (_currentProgramInfo == null)
{
IsProgramInfoVisible = false;
@@ -144,9 +174,9 @@ namespace TV_Player
IsProgramInfoVisible = true;
ProgramGuideText = _currentProgramInfo.Title;
StartProgram = _currentProgramInfo.StartTime.ToShortTimeString();
EndProgram = _currentProgramInfo.StopTime.ToShortTimeString();
EndProgram = _currentProgramInfo.EndTime.ToShortTimeString();
var programMinutes = (_currentProgramInfo.StopTime - _currentProgramInfo.StartTime).TotalMinutes;
var programMinutes = (_currentProgramInfo.EndTime - _currentProgramInfo.StartTime).TotalMinutes;
DurationValue = (int)((DateTime.Now - _currentProgramInfo.StartTime).TotalMinutes / programMinutes * 100);
}
@@ -117,6 +117,11 @@ namespace TV_Player.ViewModels
_mainViewModel.OnFullSctreenButtonClick();
}
public void CloseAppCommand()
{
_mainViewModel.OnCloseAppButtonClick();
}
public void SetBackButtonAction(Action action)
{
_mainViewModel.ButtonBackAction = action;