This commit is contained in:
Vova
2024-01-21 13:18:48 +02:00
parent 4c374069f2
commit e36554eeab
8 changed files with 61 additions and 32 deletions
+8 -7
View File
@@ -19,17 +19,18 @@ namespace TV_Player
set => SetProperty(ref _isTopPanelVisible, value);
}
private string _topPaneTitle;
public string TopPanelTitle
{
get => _topPaneTitle;
set => SetProperty(ref _topPaneTitle, value);
}
public Action ButtonBackAction { get; set; }
public ICommand BackCommand { get; }
public MainViewModel()
{
var vm = new ProgramsGroupViewModel();
var control = new ProgramsGroupGrid();
control.DataContext = vm;
Control = control;
{
BackCommand = new RelayCommand(OnButtonBackClick);
}
private void OnButtonBackClick()
+9 -1
View File
@@ -16,6 +16,13 @@ namespace TV_Player
set => SetProperty(ref _currentProgram, value);
}
private string _topPaneTitle;
public string TopPanelTitle
{
get => _topPaneTitle;
set => SetProperty(ref _topPaneTitle, value);
}
public M3UInfo SelectedItem { get; set; }
public ICommand BackCommand { get; }
@@ -23,7 +30,8 @@ namespace TV_Player
{
_currentProgram = selectedProgram;
BackCommand = new RelayCommand(OnButtonBackClick);
TVPlayerViewModel.Instance.TopPanelVisible(false);
TVPlayerViewModel.Instance.TopPanelVisible(false, selectedProgram.Name);
TopPanelTitle = selectedProgram.Name;
}
private void OnButtonBackClick()
@@ -21,7 +21,7 @@ namespace TV_Player
ItemSelectedCommand = new RelayCommand(OnItemSelected);
ProgramsData.Instance.GroupsInformation.Subscribe(x=>Programs = x);
//TVPlayerViewModel.Instance.TopPanelVisible(true);
TVPlayerViewModel.Instance.TopPanelVisible(true, "Groups");
}
private void OnItemSelected()
@@ -18,7 +18,7 @@ namespace TV_Player
public ProgramsListViewModel(GroupInfo groupInfo)
{
TVPlayerViewModel.Instance.TopPanelVisible(true);
TVPlayerViewModel.Instance.TopPanelVisible(true, groupInfo.Name);
ItemSelectedCommand = new RelayCommand(OnItemSelected);
ProgramsData.Instance.AllPrograms.Subscribe(x => Programs = x.Where(p => p.GroupTitle == groupInfo.Name).ToList());
+22 -11
View File
@@ -1,21 +1,19 @@
using CommunityToolkit.Mvvm.Input;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Controls;
namespace TV_Player.ViewModels
{
public class TVPlayerViewModel
{
private readonly MainViewModel _mainViewModel;
public Action ButtonBackAction { get; set; }
private static TVPlayerViewModel _instance;
public Action ButtonBackAction { get; set; }
private static TVPlayerViewModel? _instance;
public static TVPlayerViewModel Instance
{
get
{
if(_instance==null)
if (_instance == null)
_instance = new TVPlayerViewModel();
return _instance;
}
@@ -24,16 +22,29 @@ namespace TV_Player.ViewModels
public TVPlayerViewModel()
{
_mainViewModel = new MainViewModel();
var mainWindow=new MainWindow();
var mainWindow = new MainWindow();
mainWindow.DataContext = _mainViewModel;
mainWindow.Show();
_instance = this;
ShowInitialScreen();
}
public void TopPanelVisible(bool value)
private void ShowInitialScreen()
{
var vm = new ProgramsGroupViewModel();
var control = new ProgramsGroupGrid();
control.DataContext = vm;
SetPageContext(control, vm);
}
public void TopPanelVisible(bool value, string title)
{
_mainViewModel.IsTopPanelVisible = value;
_mainViewModel.TopPanelTitle = title;
}
public void SetBackButtonAction(Action action)