Allow to add/remove multiple playlists from settings window
This commit is contained in:
@@ -80,7 +80,38 @@ c-0.781-0.781-0.788-2.047-0.007-2.828L51.438,14.43c1.754-1.755,1.753-4.61-0.001-
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
<Style x:Key="ButtonAdd" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="Green" Height="50" Width="50" CornerRadius="300">
|
||||
<Path Fill="#FFF4F4F5" HorizontalAlignment="Center" Height="35" Stroke="Black" Stretch="Fill" VerticalAlignment="Center" Width="30">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M23.531502,6.7801739 L23.553471,20.766701 7.225951,21.044638 7.1408542,25.087499 23.177883,25.087499 23.051064,42.665812 28.15887,42.751559 28.194953,25.087499 43.923114,25.087499 43.984694,20.800105 28.242605,20.852246 28.284472,6.737454 z"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="ButtonRemove" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Button}">
|
||||
<Border Background="Red" Height="50" Width="50" CornerRadius="300">
|
||||
<Path Fill="#FFF4F4F5" HorizontalAlignment="Center" Height="35" Stroke="Black" Stretch="Fill" VerticalAlignment="Center" Width="30">
|
||||
<Path.Data>
|
||||
<PathGeometry Figures="M7.225951,21.044638 L7.1408542,25.087499 43.923114,25.087499 43.984694,20.800105 z"/>
|
||||
</Path.Data>
|
||||
</Path>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
<Style x:Key="ButtonUp" TargetType="{x:Type Button}">
|
||||
<Setter Property="Template">
|
||||
@@ -248,17 +279,17 @@ c-0.781-0.781-0.788-2.047-0.007-2.828L51.438,14.43c1.754-1.755,1.753-4.61-0.001-
|
||||
Content="{TemplateBinding Property=ContentControl.Content}"
|
||||
/>
|
||||
</Border>
|
||||
|
||||
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
<LinearGradientBrush x:Key="YellowGradient" >
|
||||
<GradientStop Offset="0" Color="LightGray"/>
|
||||
<GradientStop Offset="1" Color="Gray"/>
|
||||
</LinearGradientBrush>
|
||||
|
||||
|
||||
<Style x:Key="{x:Type CheckBox}" TargetType="CheckBox">
|
||||
<Setter Property="SnapsToDevicePixels" Value="true"/>
|
||||
<Setter Property="Background" Value="{StaticResource YellowGradient}" />
|
||||
@@ -297,7 +328,7 @@ c-0.781-0.781-0.788-2.047-0.007-2.828L51.438,14.43c1.754-1.755,1.753-4.61-0.001-
|
||||
</Border>
|
||||
|
||||
</Border>
|
||||
<Path x:Name="CheckMark" SnapsToDevicePixels="False" Data="F1M1,14.489C1,14.489 4.963,10.525 4.963,10.525 4.963,10.525 11.328,16.89 11.328,16.89 11.328,16.89 27.034,1.183 27.034,1.183 27.034,1.183 31,5.146 31,5.146 31,5.146 11.328,24.817 11.328,24.817 11.328,24.817 1,14.489 1,14.489z" Fill="#FFFFFFFF" Height="26" Canvas.Left="0" Canvas.Top="0" Width="32"/>
|
||||
<Path x:Name="CheckMark" SnapsToDevicePixels="False" Data="F1M1,14.489C1,14.489 4.963,10.525 4.963,10.525 4.963,10.525 11.328,16.89 11.328,16.89 11.328,16.89 27.034,1.183 27.034,1.183 27.034,1.183 31,5.146 31,5.146 31,5.146 11.328,24.817 11.328,24.817 11.328,24.817 1,14.489 1,14.489z" Fill="#FFFFFFFF" Height="26" Canvas.Left="0" Canvas.Top="0" Width="32"/>
|
||||
</Grid>
|
||||
</BulletDecorator.Bullet>
|
||||
<ContentPresenter Margin="4,0,0,0" TextBlock.Foreground="{TemplateBinding Foreground}"
|
||||
|
||||
@@ -17,5 +17,11 @@ namespace TV_Player
|
||||
viewModel.OnKeyDownCommand.Execute(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnManipulationBoundaryFeedback(ManipulationBoundaryFeedbackEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,13 @@ namespace TV_Player
|
||||
}
|
||||
}
|
||||
|
||||
private void ListView_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
private void ListView_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
_isDragging = true;
|
||||
_mousePosition = e.GetPosition(null);
|
||||
}
|
||||
|
||||
private void ListView_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
private void ListView_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
@@ -66,8 +66,8 @@ namespace TV_Player
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ListView_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
_isDragging = false;
|
||||
|
||||
+40
-16
@@ -3,21 +3,45 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:tv_player="clr-namespace:TV_Player"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<StackPanel x:Name="groupsGrid" VerticalAlignment="Center">
|
||||
<!--<StackPanel x:Name="AddPlayList" Visibility="Collapsed">-->
|
||||
<Label Margin="10" Foreground="White" FontSize="25" FontWeight="Bold" FontFamily="Arial">Адрес плейлиста</Label>
|
||||
<TextBox Margin="10" Style="{StaticResource TextBox}" HorizontalAlignment="Stretch" Text="{Binding PlaylistURL}"></TextBox>
|
||||
<Label Margin="10" Foreground="White" FontSize="25" FontWeight="Bold" FontFamily="Arial">Название</Label>
|
||||
<TextBox Margin="10" Style="{StaticResource TextBox}" HorizontalAlignment="Stretch" Text="{Binding PlaylistName}"></TextBox>
|
||||
<Button Grid.Column="1" Height="70" Width="70" Margin="10,0,50,0" Style="{DynamicResource ButtonConfirm}" Command="{Binding BackCommand}" />
|
||||
<!--</StackPanel>-->
|
||||
<CheckBox Margin="10" Foreground="White" FontSize="25" IsChecked="{Binding StartFullScreen}">Откывать во весь экран</CheckBox>
|
||||
<CheckBox Margin="10" Foreground="White" FontSize="25" IsChecked="{Binding StartLastScreen}">Запоминать последний выбор</CheckBox>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Grid.Column="1" Height="70" Width="70" Margin="10,0,50,0" Style="{DynamicResource ButtonBack}" Command="{Binding BackCommand}" />
|
||||
<Button HorizontalAlignment="Center" Height="70" Width="70" Style="{DynamicResource ButtonConfirm}" Command="{Binding SaveCommand}" />
|
||||
mc:Ignorable="d">
|
||||
<Viewbox>
|
||||
<StackPanel x:Name="groupsGrid" VerticalAlignment="Center">
|
||||
<Button HorizontalAlignment="Center" Height="70" Width="70" Style="{DynamicResource ButtonAdd}" Click="OpenAddPlayList_Click" />
|
||||
<ListView Height="250" ItemsSource="{Binding Playlists}" Background="Transparent" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid HorizontalAlignment="Stretch" Height="80">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Foreground="White" VerticalAlignment="Center" FontSize="25" FontWeight="Bold" Text="{Binding Key}" />
|
||||
<TextBlock Grid.Column="1" Foreground="White" VerticalAlignment="Center" FontSize="25" FontWeight="Bold" Text="{Binding Value}" />
|
||||
<Button Grid.Column="2" Height="70" Width="70" Style="{DynamicResource ButtonRemove}" CommandParameter="{Binding}"
|
||||
Command="{Binding DataContext.PlaylistDeleteCommand, RelativeSource={RelativeSource AncestorType=UserControl}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
<StackPanel x:Name="AddPlayList" Visibility="Collapsed">
|
||||
<Label Margin="10" Foreground="White" FontSize="25" FontWeight="Bold" FontFamily="Arial">Адрес плейлиста</Label>
|
||||
<TextBox Margin="10" Style="{StaticResource TextBox}" HorizontalAlignment="Stretch" Text="{Binding PlaylistURL}"></TextBox>
|
||||
<Label Margin="10" Foreground="White" FontSize="25" FontWeight="Bold" FontFamily="Arial">Название</Label>
|
||||
<TextBox Margin="10" Style="{StaticResource TextBox}" HorizontalAlignment="Stretch" Text="{Binding PlaylistName}"></TextBox>
|
||||
<Button Grid.Column="1" Height="70" Width="70" Margin="10,0,50,0" Style="{DynamicResource ButtonConfirm}" Click="AddPlayList_Click" Command="{Binding AddPlaylistCommand}" />
|
||||
</StackPanel>
|
||||
<CheckBox Margin="10" Foreground="White" FontSize="25" IsChecked="{Binding StartFullScreen}">Откывать во весь экран</CheckBox>
|
||||
<CheckBox Margin="10" Foreground="White" FontSize="25" IsChecked="{Binding StartLastScreen}">Запоминать последний выбор</CheckBox>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Button Grid.Column="1" Height="70" Width="70" Margin="10,0,50,0" Style="{DynamicResource ButtonBack}" Command="{Binding BackCommand}" />
|
||||
<Button HorizontalAlignment="Center" Height="70" Width="70" Style="{DynamicResource ButtonConfirm}" Command="{Binding SaveCommand}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Viewbox>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
|
||||
namespace TV_Player
|
||||
{
|
||||
@@ -11,5 +12,9 @@ namespace TV_Player
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OpenAddPlayList_Click(object sender, System.Windows.RoutedEventArgs e) => AddPlayList.Visibility = Visibility.Visible;
|
||||
|
||||
private void AddPlayList_Click(object sender, RoutedEventArgs e) => AddPlayList.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace TV_Player.ViewModels
|
||||
{
|
||||
internal class SettingsViewModel : ObservableViewModelBase
|
||||
{
|
||||
private string _playlistName;
|
||||
public string PlaylistName
|
||||
{
|
||||
get => _playlistName;
|
||||
set => SetProperty(ref _playlistName, value);
|
||||
}
|
||||
|
||||
private string _playlistURL;
|
||||
public string PlaylistURL
|
||||
{
|
||||
@@ -12,6 +20,13 @@ namespace TV_Player.ViewModels
|
||||
set => SetProperty(ref _playlistURL, value);
|
||||
}
|
||||
|
||||
private ObservableCollection<KeyValuePair<string, string>> _playlists;
|
||||
public ObservableCollection<KeyValuePair<string, string>> Playlists
|
||||
{
|
||||
get => _playlists;
|
||||
set => SetProperty(ref _playlists, value);
|
||||
}
|
||||
|
||||
private bool _startFullScreen;
|
||||
public bool StartFullScreen
|
||||
{
|
||||
@@ -27,7 +42,9 @@ namespace TV_Player.ViewModels
|
||||
}
|
||||
|
||||
public ICommand SaveCommand { get; }
|
||||
public ICommand PlaylistDeleteCommand { get; }
|
||||
public ICommand BackCommand { get; }
|
||||
public ICommand AddPlaylistCommand { get; }
|
||||
|
||||
public SettingsViewModel()
|
||||
{
|
||||
@@ -35,12 +52,25 @@ namespace TV_Player.ViewModels
|
||||
|
||||
SaveCommand = new RelayCommand(OnSaveSettings);
|
||||
BackCommand = new RelayCommand(OnBackCommand);
|
||||
AddPlaylistCommand = new RelayCommand(OnAddPlaylistCommand);
|
||||
PlaylistDeleteCommand = new RelayCommand<KeyValuePair<string, string>>(OnPlaylistDeleteCommand);
|
||||
|
||||
StartFullScreen = SettingsModel.StartFullScreen;
|
||||
StartLastScreen = SettingsModel.StartFromLastScreen;
|
||||
// PlaylistURL = SettingsModel.PlaylistURL;
|
||||
Playlists = new ObservableCollection<KeyValuePair<string, string>>(SettingsModel.Playlists);
|
||||
}
|
||||
|
||||
private void OnAddPlaylistCommand()
|
||||
{
|
||||
Playlists.Add(new KeyValuePair<string, string>(PlaylistName, PlaylistURL));
|
||||
}
|
||||
|
||||
private void OnPlaylistDeleteCommand(KeyValuePair<string, string> pair)
|
||||
{
|
||||
Playlists.Remove(pair);
|
||||
}
|
||||
|
||||
|
||||
private void OnBackCommand()
|
||||
{
|
||||
TVPlayerViewModel.Instance.SelectScreen();
|
||||
@@ -50,10 +80,10 @@ namespace TV_Player.ViewModels
|
||||
{
|
||||
SettingsModel.StartFullScreen = StartFullScreen;
|
||||
SettingsModel.StartFromLastScreen = StartLastScreen;
|
||||
//SettingsModel.PlaylistURL = PlaylistURL;
|
||||
|
||||
SettingsModel.Playlists.Clear();
|
||||
SettingsModel.Playlists = Playlists.ToDictionary<string, string>();
|
||||
SettingsModel.SaveSetttings();
|
||||
TVPlayerViewModel.Instance.InitializeTVWithData();
|
||||
TVPlayerViewModel.Instance.InitializeTVWithData();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,8 @@ namespace TV_Player.ViewModels
|
||||
{
|
||||
if (SettingsModel.Playlists!=null && SettingsModel.Playlists.Any())
|
||||
{
|
||||
foreach(var playlist in SettingsModel.Playlists)
|
||||
PlayListsData.Clear();
|
||||
foreach (var playlist in SettingsModel.Playlists)
|
||||
{
|
||||
PlayListsData.Add(playlist.Key, new ProgramsData(playlist.Key,playlist.Value));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user