navigation menu & design

This commit is contained in:
Vova
2024-01-21 12:14:48 +02:00
parent 61eb987642
commit 4c374069f2
16 changed files with 207 additions and 86 deletions
+5 -2
View File
@@ -1,9 +1,12 @@
<Application x:Class="TV_Player.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TV_Player"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Assets/GroupButtonStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
@@ -0,0 +1,64 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:TV_Player">
<Style x:Key="GroupButton" TargetType="{x:Type controls:GroupButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:GroupButton}">
<Grid x:Name="ButtonBorder" Height="70" Width="150" >
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="0.4*"/>
</Grid.RowDefinitions>
<Rectangle RadiusX="15" RadiusY="15" x:Name="Border" StrokeThickness="3" Stroke="Yellow" Stretch="Fill" Grid.RowSpan="2" Fill="#FF1F1E1E"/>
<TextBlock x:Name="groupName" Text="{TemplateBinding GroupName}" FontSize="15" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Row="1" FontSize="10" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" LineStackingStrategy="BlockLineHeight" LineHeight="10">
<Run Text="{TemplateBinding ProgramsCount}"/>
<Run>Programs</Run>
</TextBlock>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonBack" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="Yellow" Height="50" Width="50" CornerRadius="300">
<Viewbox Margin="0,6,5,5">
<Path VerticalAlignment="Center" HorizontalAlignment="Center" Fill="Gray" Data="M48.252,69.253c-2.271,0-4.405-0.884-6.011-2.489L17.736,42.258c-1.646-1.645-2.546-3.921-2.479-6.255
c-0.068-2.337,0.833-4.614,2.479-6.261L42.242,5.236c1.605-1.605,3.739-2.489,6.01-2.489c2.271,0,4.405,0.884,6.01,2.489
c3.314,3.314,3.314,8.707,0,12.021L35.519,36l18.743,18.742c3.314,3.314,3.314,8.707,0,12.021
C52.656,68.369,50.522,69.253,48.252,69.253z M48.252,6.747c-1.202,0-2.332,0.468-3.182,1.317L21.038,32.57
c-0.891,0.893-0.833,2.084-0.833,3.355c0,0.051,0,0.101,0,0.151c0,1.271-0.058,2.461,0.833,3.353l24.269,24.506
c0.85,0.85,1.862,1.317,3.063,1.317c1.203,0,2.273-0.468,3.123-1.317c1.755-1.755,1.725-4.61-0.03-6.365L31.292,37.414
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-6.365C50.587,7.215,49.454,6.747,48.252,6.747z" Stretch="Fill" Width="50"/>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ButtonGear" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="Yellow" Height="50" Width="50" CornerRadius="300">
<Viewbox Height="45" Width="45">
<Grid>
<Path Fill="Gray" Data="M491.584,192.579l-55.918-6.914c-0.919-2.351-1.884-4.682-2.892-6.993l34.648-44.428 c7.227-9.267,6.412-22.464-1.899-30.773l-57.028-56.996c-8.308-8.304-21.502-9.114-30.763-1.893L333.32,79.216 c-2.312-1.008-4.644-1.974-6.994-2.894l-6.915-55.904c-1.443-11.66-11.348-20.415-23.097-20.415h-80.637 c-11.748,0-21.656,8.755-23.097,20.416l-6.914,55.904c-2.349,0.919-4.681,1.884-6.988,2.89l-44.415-34.642 c-9.261-7.222-22.458-6.414-30.768,1.894l-57.021,57.009c-8.31,8.307-9.123,21.506-1.896,30.771l34.644,44.417 c-1.012,2.312-1.978,4.647-2.9,7.002l-55.906,6.914C8.757,194.022,0,203.927,0,215.676v80.64c0,11.75,8.758,21.658,20.421,23.097 l55.901,6.903c0.919,2.352,1.884,4.686,2.894,6.994l-34.641,44.417c-7.224,9.264-6.411,22.46,1.894,30.767l57.021,57.031 c8.307,8.31,21.507,9.121,30.773,1.896l44.417-34.648c2.306,1.007,4.638,1.974,6.987,2.891l6.914,55.921 c1.441,11.66,11.348,20.416,23.097,20.416h80.637c11.748,0,21.655-8.755,23.097-20.416l6.915-55.92 c2.351-0.92,4.682-1.885,6.993-2.892l44.425,34.65c9.266,7.225,22.463,6.414,30.771-1.898l57.015-57.031 c8.307-8.308,9.117-21.504,1.893-30.768l-34.641-44.409c1.012-2.313,1.978-4.647,2.898-7.002l55.901-6.903 c11.661-1.44,20.421-11.348,20.421-23.097v-80.64C512,203.927,503.243,194.022,491.584,192.579z M465.455,275.74l-49.864,6.158 c-9.151,1.131-16.772,7.556-19.431,16.386c-2.813,9.337-6.56,18.387-11.138,26.903c-4.367,8.124-3.525,18.063,2.147,25.335 l30.898,39.613l-27.924,27.932l-39.621-30.905c-7.269-5.668-17.202-6.513-25.327-2.15c-8.513,4.572-17.565,8.319-26.905,11.134 c-8.827,2.661-15.25,10.279-16.381,19.427l-6.169,49.883h-39.492l-6.167-49.883c-1.131-9.146-7.551-16.763-16.375-19.425 c-9.367-2.825-18.417-6.571-26.899-11.132c-8.122-4.369-18.061-3.527-25.336,2.147l-39.615,30.902L93.929,390.13l30.897-39.618 c5.671-7.273,6.513-17.206,2.147-25.328c-4.568-8.501-8.315-17.554-11.137-26.911c-2.662-8.825-10.282-15.247-19.43-16.376 l-49.861-6.156v-39.492l49.866-6.167c9.146-1.131,16.763-7.551,19.423-16.375c2.824-9.356,6.572-18.406,11.143-26.9 c4.374-8.124,3.533-18.067-2.143-25.342l-30.903-39.62l27.924-27.918l39.62,30.902c7.273,5.672,17.209,6.513,25.335,2.146 c8.493-4.565,17.541-8.31,26.896-11.132c8.825-2.662,15.247-10.279,16.378-19.427l6.166-49.867h39.494l6.169,49.869 c1.133,9.148,7.557,16.767,16.384,19.427c9.328,2.811,18.379,6.557,26.902,11.135c8.122,4.364,18.055,3.522,25.325-2.149 l39.616-30.894l27.927,27.912l-30.897,39.618c-5.666,7.267-6.513,17.191-2.158,25.311c4.58,8.54,8.328,17.599,11.138,26.923 c2.661,8.825,10.279,15.248,19.427,16.381l49.878,6.169V275.74z"/>
<Path Fill="Gray" Data="M255.997,155.153c-55.606,0-100.845,45.244-100.845,100.856c0,55.603,45.239,100.839,100.845,100.839 c55.609,0,100.852-45.236,100.852-100.839C356.849,200.397,311.606,155.153,255.997,155.153z M255.997,310.303 c-29.941,0-54.3-24.356-54.3-54.294c0-29.947,24.359-54.311,54.3-54.311c29.944,0,54.306,24.363,54.306,54.311 C310.303,285.947,285.941,310.303,255.997,310.303z"/>
</Grid>
</Viewbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
@@ -0,0 +1,26 @@
using System.Windows;
using System.Windows.Data;
namespace TV_Player
{
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is Boolean && (bool)value)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is Visibility && (Visibility)value == Visibility.Visible)
{
return true;
}
return false;
}
}
}
-22
View File
@@ -1,22 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace TV_Player
{
public class EnumToBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value.Equals(parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value.Equals(true) ? parameter : Binding.DoNothing;
}
}
}
+37
View File
@@ -0,0 +1,37 @@
using System.Windows;
using System.Windows.Controls;
namespace TV_Player
{
/// <summary>
/// Interaction logic for GroupButton.xaml
/// </summary>
public partial class GroupButton : UserControl
{
public static readonly DependencyProperty GroupNameProperty =
DependencyProperty.Register(
"GroupName", // Name of the property
typeof(string), // Type of the property
typeof(GroupButton), // Type of the owner class
new PropertyMetadata(string.Empty) // Default value
);
public string GroupName
{
get { return (string)GetValue(GroupNameProperty); }
set { SetValue(GroupNameProperty, value); }
}
public static readonly DependencyProperty ProgramsCountProperty =
DependencyProperty.Register(
"ProgramsCount", // Name of the property
typeof(string), // Type of the property
typeof(GroupButton), // Type of the owner class
new PropertyMetadata(string.Empty) // Default value
);
public string ProgramsCount
{
get { return (string)GetValue(ProgramsCountProperty); }
set { SetValue(ProgramsCountProperty, value); }
}
}
}
-26
View File
@@ -1,26 +0,0 @@
<UserControl x:Class="TV_Player.GroupButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
d:DesignHeight="100" d:DesignWidth="200">
<Viewbox Grid.Row="1">
<Grid x:Name="ButtonBorder" Height="70" Width="150" >
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="0.4*"/>
</Grid.RowDefinitions>
<Rectangle RadiusX="15" RadiusY="15" x:Name="Border" StrokeThickness="3" Stroke="Yellow" Stretch="Fill" Grid.RowSpan="2" Fill="#FF1F1E1E"/>
<TextBlock x:Name="groupName" Text="Group name" FontSize="15" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Row="1" FontSize="10" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" LineStackingStrategy="BlockLineHeight" LineHeight="10">
<Run x:Name="programsFound"/>
<Run>Programs</Run>
</TextBlock>
</Grid>
</Grid>
</Viewbox>
</UserControl>
-17
View File
@@ -1,17 +0,0 @@
using System.Windows.Controls;
namespace TV_Player
{
/// <summary>
/// Interaction logic for GroupButton.xaml
/// </summary>
public partial class GroupButton : UserControl
{
public GroupButton(string groupName,int programsFound)
{
InitializeComponent();
this.groupName.Text = groupName;
this.programsFound.Text = programsFound.ToString();
}
}
}
+13 -1
View File
@@ -6,6 +6,9 @@
xmlns:local="clr-namespace:TV_Player"
mc:Ignorable="d"
Title="TV" Height="450" Width="800">
<Window.Resources>
<local:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverterKey"/>
</Window.Resources>
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
@@ -13,6 +16,15 @@
<Grid.Background>
<ImageBrush ImageSource="Assets/bkground.jpg" />
</Grid.Background>
<ContentControl Name="ControlContainer" Content="{Binding Control}" />
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Visibility="{Binding IsTopPanelVisible,Converter={StaticResource BooleanToVisibilityConverterKey}}" >
<Button Height="50" Width="50" Margin="10,0,0,0" Style="{DynamicResource ButtonGear}" />
<Button Height="50" Width="50" Margin="10,0,0,0" Style="{DynamicResource ButtonBack}" Command="{Binding BackCommand}" />
</StackPanel>
<ContentControl Grid.Row="1" Name="ControlContainer" Content="{Binding Control}" />
</Grid>
</Window>
+10 -7
View File
@@ -2,20 +2,23 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:local="clr-namespace:TV_Player"
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">
<Grid x:Name="groupsGrid">
<ScrollViewer>
<ListBox ItemsSource="{Binding Programs}"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem}"
<ListBox ItemsSource="{Binding Programs}" Background="Transparent"
SelectionMode="Single"
SelectedItem="{Binding SelectedItem}"
SelectionChanged="ListBox_SelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="4" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
<tv_player:GroupButton Style="{DynamicResource GroupButton}" GroupName="{Binding Name}" ProgramsCount="{Binding Count}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
+1 -1
View File
@@ -19,7 +19,7 @@
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Content="Back" HorizontalAlignment="Stretch" Command="{Binding BackCommand}" />
<Button Height="50" Width="50" Margin="10,0,0,0" Style="{DynamicResource ButtonBack}" Command="{Binding BackCommand}" />
<Button Grid.Column="1" Content="Pause" HorizontalAlignment="Stretch" Click="PauseButton_Click" />
</Grid>
</StackPanel>
+6 -6
View File
@@ -18,15 +18,15 @@ namespace TV_Player
typeof(VideoPlayer), // Type of the owner class
new PropertyMetadata(string.Empty) // Default value
);
LibVLC _libVLC;
MediaPlayer _mediaPlayer;
public string SourceUrl
{
get { return (string)GetValue(SourceUrlProperty); }
set { SetValue(SourceUrlProperty, value);}
set { SetValue(SourceUrlProperty, value); }
}
private LibVLC _libVLC;
private MediaPlayer _mediaPlayer;
public VideoPlayer()
{
InitializeComponent();
@@ -74,7 +74,7 @@ namespace TV_Player
VideoView.MediaPlayer.Play(media);
}
}
private void MyUserControl_MouseDown(object sender, MouseButtonEventArgs e)
{
+18 -1
View File
@@ -1,4 +1,6 @@
using System.Windows.Controls;
using CommunityToolkit.Mvvm.Input;
using System.Windows.Controls;
using System.Windows.Input;
namespace TV_Player
{
@@ -11,6 +13,15 @@ namespace TV_Player
set => SetProperty(ref _control, value);
}
private bool _isTopPanelVisible;
public bool IsTopPanelVisible{
get => _isTopPanelVisible;
set => SetProperty(ref _isTopPanelVisible, value);
}
public Action ButtonBackAction { get; set; }
public ICommand BackCommand { get; }
public MainViewModel()
{
var vm = new ProgramsGroupViewModel();
@@ -18,6 +29,12 @@ namespace TV_Player
var control = new ProgramsGroupGrid();
control.DataContext = vm;
Control = control;
BackCommand = new RelayCommand(OnButtonBackClick);
}
private void OnButtonBackClick()
{
ButtonBackAction?.Invoke();
}
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ namespace TV_Player
{
_currentProgram = selectedProgram;
BackCommand = new RelayCommand(OnButtonBackClick);
TVPlayerViewModel.Instance.TopPanelVisible(false);
}
private void OnButtonBackClick()
@@ -20,6 +20,8 @@ namespace TV_Player
{
ItemSelectedCommand = new RelayCommand(OnItemSelected);
ProgramsData.Instance.GroupsInformation.Subscribe(x=>Programs = x);
//TVPlayerViewModel.Instance.TopPanelVisible(true);
}
private void OnItemSelected()
@@ -18,8 +18,16 @@ namespace TV_Player
public ProgramsListViewModel(GroupInfo groupInfo)
{
TVPlayerViewModel.Instance.TopPanelVisible(true);
ItemSelectedCommand = new RelayCommand(OnItemSelected);
ProgramsData.Instance.AllPrograms.Subscribe(x=>Programs = x.Where(p=>p.GroupTitle== groupInfo.Name).ToList());
ProgramsData.Instance.AllPrograms.Subscribe(x => Programs = x.Where(p => p.GroupTitle == groupInfo.Name).ToList());
TVPlayerViewModel.Instance.SetBackButtonAction(new Action(() =>
{
var programGroupViewModel = new ProgramsGroupViewModel();
var conrtrol = new ProgramsGroupGrid();
TVPlayerViewModel.Instance.SetPageContext(conrtrol, programGroupViewModel);
}));
}
private void OnItemSelected()
+15 -1
View File
@@ -1,10 +1,14 @@
using System.Windows.Controls;
using CommunityToolkit.Mvvm.Input;
using System.Windows.Controls;
using System.Windows.Input;
namespace TV_Player.ViewModels
{
public class TVPlayerViewModel
{
private readonly MainViewModel _mainViewModel;
public Action ButtonBackAction { get; set; }
private static TVPlayerViewModel _instance;
public static TVPlayerViewModel Instance
@@ -25,6 +29,16 @@ namespace TV_Player.ViewModels
mainWindow.Show();
_instance = this;
}
public void TopPanelVisible(bool value)
{
_mainViewModel.IsTopPanelVisible = value;
}
public void SetBackButtonAction(Action action)
{
_mainViewModel.ButtonBackAction = action;
}
public void SetPageContext(ContentControl control, object viewModel)