diff --git a/TV Player WPF/MainWindow.xaml b/TV Player WPF/MainWindow.xaml index 86713db..bba0fc8 100644 --- a/TV Player WPF/MainWindow.xaml +++ b/TV Player WPF/MainWindow.xaml @@ -5,7 +5,8 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TV_Player" mc:Ignorable="d" WindowStyle="None" WindowState="{Binding CurrentWindowState}" - Title="TV" Height="450" Width="800"> + Title="TV" Height="450" Width="800" + KeyDown="UserControl_KeyDown"> diff --git a/TV Player WPF/MainWindow.xaml.cs b/TV Player WPF/MainWindow.xaml.cs index c412cfd..d319b3a 100644 --- a/TV Player WPF/MainWindow.xaml.cs +++ b/TV Player WPF/MainWindow.xaml.cs @@ -1,4 +1,5 @@ using System.Windows; +using System.Windows.Input; namespace TV_Player { @@ -8,5 +9,13 @@ namespace TV_Player { InitializeComponent(); } + + private void UserControl_KeyDown(object sender, KeyEventArgs e) + { + if (DataContext is MainViewModel viewModel) + { + viewModel.OnKeyDownCommand.Execute(e); + } + } } } \ No newline at end of file diff --git a/TV Player WPF/PlaylistWorker/M3UParser.cs b/TV Player WPF/PlaylistWorker/M3UParser.cs index b36d0b4..0cb1371 100644 --- a/TV Player WPF/PlaylistWorker/M3UParser.cs +++ b/TV Player WPF/PlaylistWorker/M3UParser.cs @@ -31,11 +31,11 @@ namespace TV_Player public static class M3UParser { - public static async Task DownloadGuideFromWebAsync(string url) + public static async Task DownloadGuideFromWebAsync(string name, string url) { - var fileName = "guide.xml"; + var fileName = name+"_guide.xml"; string programDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); - string filePath = Path.Combine(programDataPath, "TV_Player", fileName); + string filePath = Path.Combine(programDataPath, "TVPlayer", fileName); if (File.Exists(filePath)) @@ -247,8 +247,8 @@ namespace TV_Player private static bool TryParseM3ULine(string m3uLine, out M3UInfo? info) { info = null; - //string pattern = @"#EXTINF:\d+ CUID=""(?.*?)"" number=""(?.*?)"" tvg-id=""(?.*?)"" tvg-name=""(?.*?)"".*?tvg-logo=""(?.*?)"" group-title=""(?.*?)""[^,]*,(?.*)[^\r](?.*)$"; - string pattern = @"#EXTINF:(-?\d+)\s+?(?:timeshift=""(?.*?)""\s+)?(?:catchup-days=""(?.*?)""\s+)?(?:catchup-type=""(?.*?)""\s+)?(?:CUID=""(?.*?)""\s+)?(?:number=""(?.*?)""\s+)?(?:tvg-id=""(?.*?)""\s+)?(?:tvg-name=""(?.*?)""\s+)?(?:group-title=""(?.*?)""\s+)?(?:tvg-logo=""(?.*?)"")?,(?.*?)\s*\r?\n(?.*)"; + string pattern = @"#EXTINF:(-?\d+)\s+?(?:timeshift=""(?.*?)""\s+)?(?:catchup-days=""(?.*?)""\s+)?(?:catchup-type=""(?.*?)""\s+)?(?:CUID=""(?.*?)""\s+)?(?:number=""(?.*?)""\s+)?(?:tvg-id=""(?.*?)""\s+)?(?:tvg-name=""(?.*?)""\s+)?(?:group-title=""(?.*?)""\s+)?(?:tvg-logo=""(?.*?)""\s*)?(?:group-title=""(?.*?)"")?(?:,(?.*?)\s*\r?\n(?.*))"; + //string pattern = @"#EXTINF:(-?\d+)\s+?(?:timeshift=""(?.*?)""\s+)?(?:catchup-days=""(?.*?)""\s+)?(?:catchup-type=""(?.*?)""\s+)?(?:CUID=""(?.*?)""\s+)?(?:number=""(?.*?)""\s+)?(?:tvg-id=""(?.*?)""\s+)?(?:tvg-name=""(?.*?)""\s+)?(?:group-title=""(?.*?)""\s+)?(?:tvg-logo=""(?.*?)"")?,(?.*?)\s*\r?\n(?.*)"; Regex regex = new Regex(pattern, RegexOptions.IgnoreCase); Match match = regex.Match(m3uLine); diff --git a/TV Player WPF/PlaylistsGroup.xaml b/TV Player WPF/PlaylistsGroup.xaml new file mode 100644 index 0000000..6e2e17f --- /dev/null +++ b/TV Player WPF/PlaylistsGroup.xaml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + diff --git a/TV Player WPF/PlaylistsGroup.xaml.cs b/TV Player WPF/PlaylistsGroup.xaml.cs new file mode 100644 index 0000000..0708304 --- /dev/null +++ b/TV Player WPF/PlaylistsGroup.xaml.cs @@ -0,0 +1,23 @@ +using System.Windows.Controls; + +namespace TV_Player +{ + /// + /// Interaction logic for ProgramsGroupGrid.xaml + /// + public partial class PlaylistsGroup : UserControl + { + public PlaylistsGroup() + { + InitializeComponent(); + } + + private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (DataContext is PlaylistsGroupViewModel viewModel) + { + viewModel.ItemSelectedCommand.Execute(null); + } + } + } +} diff --git a/TV Player WPF/Settings.xaml b/TV Player WPF/Settings.xaml index 531433b..c5d8432 100644 --- a/TV Player WPF/Settings.xaml +++ b/TV Player WPF/Settings.xaml @@ -6,14 +6,18 @@ mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> + + + +