Files
IPTVplayer/TV Player Avalonia/ViewModels/MainWindowViewModel.cs
T
Vladimir 1e8e444376 feat: Implement Playlists and Programs Management
- Added PlaylistsGroupViewModel to manage playlists and selection.
- Introduced ProgramsGroupViewModel for handling program groups and subscriptions.
- Created ProgramsListViewModel to manage individual program listings.
- Developed SettingsViewModel for user settings including playlist management.
- Implemented TVPlayerViewModel as the main view model coordinating screens and data.
- Added PlayerView for video playback with LibVLC integration.
- Created XAML views for PlaylistsGroup, ProgramsGroup, ProgramsList, and Settings.
- Added sample M3U playlist for testing.
- Documented WPF build instructions and project structure in WPF-BUILD.md.
- Configured global.json for .NET SDK versioning.
2026-03-22 12:11:24 +02:00

79 lines
2.1 KiB
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using CommunityToolkit.Mvvm.Input;
using System.Windows.Input;
namespace TV_Player.AvaloniaApp.ViewModels;
public class MainWindowViewModel : TV_Player.ObservableViewModelBase
{
private object? _currentViewModel;
public object? CurrentViewModel
{
get => _currentViewModel;
set => SetProperty(ref _currentViewModel, value);
}
private bool _isTopPanelVisible;
public bool IsTopPanelVisible
{
get => _isTopPanelVisible;
set => SetProperty(ref _isTopPanelVisible, value);
}
private string _topPanelTitle = string.Empty;
public string TopPanelTitle
{
get => _topPanelTitle;
set => SetProperty(ref _topPanelTitle, value);
}
private WindowState _currentWindowState = WindowState.Normal;
public WindowState CurrentWindowState
{
get => _currentWindowState;
set => SetProperty(ref _currentWindowState, value);
}
public ICommand FullscreenCommand { get; }
public ICommand CloseAppCommand { get; }
public ICommand BackCommand { get; }
public ICommand SettingsCommand { get; }
public Action? ButtonBackAction { get; set; }
public MainWindowViewModel()
{
BackCommand = new RelayCommand(TriggerBack);
FullscreenCommand = new RelayCommand(OnFullScreenButtonClick);
SettingsCommand = new RelayCommand(OnSettingsButtonClick);
CloseAppCommand = new RelayCommand(OnCloseAppButtonClick);
}
public void OnFullScreenButtonClick()
{
CurrentWindowState = CurrentWindowState == WindowState.FullScreen
? WindowState.Normal
: WindowState.FullScreen;
}
public void OnCloseAppButtonClick()
{
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.Shutdown();
}
}
private void OnSettingsButtonClick()
{
TVPlayerViewModel.Instance.ShowSettingsScreen();
}
public void TriggerBack()
{
ButtonBackAction?.Invoke();
}
}