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
+26 -1
View File
@@ -26,10 +26,32 @@
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<Button Height="50" Width="70" Margin="10,0,0,0" Style="{DynamicResource ButtonBack}" Command="{Binding BackCommand}" />
<TextBlock Grid.Column="1" FontSize="20" Foreground="White" Text="{Binding TopPanelTitle}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button Grid.Column="4" Height="70" Width="50" Margin="10,0,0,0" Style="{DynamicResource ButtonFullScreen}" Command="{Binding FullscreenCommand}" />
<Button Grid.Column="2" Height="70" Width="50" Margin="10,0,0,0" Style="{DynamicResource ButtonFullScreen}" Command="{Binding FullscreenCommand}" />
<Button Grid.Column="3" Height="70" Width="70" Margin="10,0,0,0" Style="{DynamicResource ButtonClose}" Command="{Binding CloseAppCommand}" />
</Grid>
<Grid Grid.Row="1" Width="400" HorizontalAlignment="Left" Background="#B0000000"
Visibility="{Binding ProgramGuideVisible,Converter={StaticResource BooleanToVisibilityConverterKey}}">
<ItemsControl Name="SidebarListView" ItemsSource="{Binding Programs}"
Background="Transparent"
BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Title}" HorizontalAlignment="Stretch" TextWrapping="Wrap" FontSize="15" Foreground="White" TextAlignment="Left" Margin="1,0,1,2"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding StartTime ,StringFormat={}{0:HH:mm}}" FontSize="12" TextAlignment="Center" Foreground="White" HorizontalAlignment="Center" TextWrapping="Wrap" Margin="1,0,1,2"/>
<TextBlock Text="{Binding EndTime ,StringFormat={}{0:HH:mm}}" FontSize="12" TextAlignment="Center" Foreground="White" HorizontalAlignment="Center" TextWrapping="Wrap" Margin="10,0,1,2"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Grid.Row="2" Background="#B0000000">
<Grid.ColumnDefinitions>
@@ -53,6 +75,9 @@
<ProgressBar Height="10" Foreground="Yellow" Name="progressBar" Value="{Binding DurationValue}" Maximum="100" VerticalAlignment="Center" HorizontalAlignment="Center" Width="400"/>
<TextBlock FontSize="15" Foreground="White" Text="{Binding EndProgram}" HorizontalAlignment="Center" />
</StackPanel>
<Grid.InputBindings>
<MouseBinding MouseAction="LeftClick" Command="{Binding ShowProgramListCommand}"/>
</Grid.InputBindings>
</Grid>
</Grid>
</Grid>
+10 -8
View File
@@ -17,16 +17,16 @@ namespace TV_Player
private LibVLC _libVLC;
private MediaPlayer _mediaPlayer;
private PlayerViewModel _viewModel;
private DispatcherTimer _overlayAutoHideTimer;
//private DispatcherTimer _overlayAutoHideTimer;
public VideoPlayer()
{
InitializeComponent();
_overlayAutoHideTimer = new DispatcherTimer();
_overlayAutoHideTimer.Interval = TimeSpan.FromSeconds(3);
_overlayAutoHideTimer.Tick += _overlayAutoHideTimer_Tick;
_overlayAutoHideTimer.Start();
//_overlayAutoHideTimer = new DispatcherTimer();
//_overlayAutoHideTimer.Interval = TimeSpan.FromSeconds(3);
//_overlayAutoHideTimer.Tick += _overlayAutoHideTimer_Tick;
//_overlayAutoHideTimer.Start();
_libVLC = new LibVLC(enableDebugLogs: true);
_mediaPlayer = new MediaPlayer(_libVLC);
@@ -58,6 +58,7 @@ namespace TV_Player
private void VideoView_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
ToggleOverlay();
}
@@ -88,7 +89,8 @@ namespace TV_Player
private void ToggleOverlay()
{
if (overlayPanel.Visibility == Visibility.Visible)
{
{
_viewModel.ProgramGuideVisible = false;
HideOverlay();
}
else
@@ -104,12 +106,12 @@ namespace TV_Player
public void ShowOverlay()
{
_overlayAutoHideTimer.Start();
//_overlayAutoHideTimer.Start();
overlayPanel.Visibility = Visibility.Visible;
}
public void HideOverlay()
{
_overlayAutoHideTimer.Stop();
// _overlayAutoHideTimer.Stop();
overlayPanel.Visibility = Visibility.Collapsed;
}
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
+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;
+2 -2
View File
@@ -12,7 +12,7 @@ namespace TV_Player.MAUI
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); }
}
@@ -74,7 +74,7 @@ namespace TV_Player.MAUI
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();