Skip to content

Commit

Permalink
Mouse overlay and current time stretched vertically
Browse files Browse the repository at this point in the history
mouse overlay hidden on MouseLeave
no epg data display added
FIX: timeline no visible
"no epg" after last epg item
improved epg navigation
scrolling epg text for better readability
  • Loading branch information
empty88 committed Jun 1, 2024
1 parent 11ca8a8 commit 6a4e4a3
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 35 deletions.
3 changes: 3 additions & 0 deletions SatIPTV.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<OutputPath>bin\x64\Debug\</OutputPath>
<PlatformTarget>x64</PlatformTarget>
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</NoWarn>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<NoWarn>41999,42016,42017,42018,42019,42020,42021,42022,42032,42036</NoWarn>
Expand Down Expand Up @@ -159,6 +161,7 @@
<Compile Include="ViewModels\EditChannelListViewModel.vb" />
<Compile Include="ViewModels\MainViewModel.vb" />
<Compile Include="ViewModels\Models\ChannelViewModel.vb" />
<Compile Include="ViewModels\Models\NonEpgInfoViewModel.vb" />
<Compile Include="ViewModels\Models\EpgInfoViewModel.vb" />
<Compile Include="ViewModels\Models\SatIpServerViewModel.vb" />
<Compile Include="ViewModels\Models\TimelineElement.vb" />
Expand Down
24 changes: 16 additions & 8 deletions ViewModels/MainViewModel.vb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
Imports System.Collections.ObjectModel
Imports System.ComponentModel
Imports System.Configuration
Imports System.IO
Imports System.Threading
Imports System.Windows.Forms
Imports LibVLCSharp.Shared
Imports Prism
Imports Prism.Commands
Imports SatIPTV.Classes
Imports SatIPTV.Helper
Expand Down Expand Up @@ -169,7 +167,7 @@ Namespace ViewModels
End Set
End Property

Public Property TimelineElements As List(Of TimelineElement)
Public Property TimelineElements As ObservableCollection(Of TimelineElement)

Public Property EditChannelListCommand As DelegateCommand
Public Property MuteCommand As DelegateCommand
Expand All @@ -182,7 +180,7 @@ Namespace ViewModels
Public Sub New()
MediaPlayer = New MediaPlayer(_libVLC)
ChannelList = New ObservableCollection(Of ChannelViewModel)
TimelineElements = New List(Of TimelineElement)
TimelineElements = New ObservableCollection(Of TimelineElement)
CurrentVolume = 100
Mute = False

Expand Down Expand Up @@ -350,10 +348,20 @@ Namespace ViewModels

For Each channel In ChannelList
Dim firstEpg = channel.EpgInfos.FirstOrDefault()
If firstEpg Is Nothing OrElse firstEpg.StartTime.Equals("0") Then Continue For
Dim lastEpg = channel.EpgInfos.LastOrDefault()
Dim differenceStart As Long
Dim differenceEnd As Long = 0
If firstEpg Is Nothing Then
differenceStart = latestEpg.EndTime - earliestEpg.StartTime
Else
differenceStart = firstEpg.StartTime - earliestEpg.StartTime
End If
If lastEpg IsNot Nothing Then differenceEnd = latestEpg.EndTime - lastEpg.EndTime

Dim difference As Long = firstEpg.StartTime - earliestEpg.StartTime
Application.Current.Dispatcher.Invoke(Sub() channel.EpgInfos.Insert(0, New EpgInfoViewModel(difference)))
Application.Current.Dispatcher.Invoke(Sub()
If Not differenceStart.Equals(0) Then channel.EpgInfos.Insert(0, New NonEpgInfoViewModel(differenceStart))
channel.EpgInfos.Add(New NonEpgInfoViewModel(differenceEnd))
End Sub)
Next
If earliestEpg Is Nothing Then Return False
_epgStartTime = earliestEpg.GetLocalStartTime()
Expand Down Expand Up @@ -391,7 +399,7 @@ Namespace ViewModels
If My.Settings.UseTvHeadend Then
epgs = NetworkHelper.GetAllEpgFromTvHeadend(chArr(1))
Application.Current.Dispatcher.Invoke(Sub()
channelVm.EpgInfos.AddRange(epgs.Select(Function(x) New EpgInfoViewModel(x, channelVm)))
channelVm.EpgInfos.AddRange(epgs?.Select(Function(x) New EpgInfoViewModel(x, channelVm)))
If Not channelVm.EpgInfos.Count.Equals(0) Then channelVm.CurrentProgram = channelVm.EpgInfos.FirstOrDefault().EpgInfo
End Sub)
End If
Expand Down
4 changes: 2 additions & 2 deletions ViewModels/Models/ChannelViewModel.vb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ Namespace ViewModels.Models
End Set
End Property

Public Property EpgInfos As ObservableCollection(Of EpgInfoViewModel)
Public Property EpgInfos As ObservableCollection(Of Object)

Public Property StreamUrl As String

Public Property ServerIp As IPAddress

Public Sub New()
Me.EpgInfos = New ObservableCollection(Of EpgInfoViewModel)
Me.EpgInfos = New ObservableCollection(Of Object)
End Sub

Public Sub New(displayName As String, streamUrl As String)
Expand Down
44 changes: 44 additions & 0 deletions ViewModels/Models/NonEpgInfoViewModel.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Imports System.Collections.ObjectModel
Imports Newtonsoft.Json
Imports SatIPTV.Helper
Imports SatIPTV.ViewModels

Namespace ViewModels.Models
Public Class NonEpgInfoViewModel
Inherits ViewModelBase

Public Property StartTime As String

Public Property EndTime As String

Public ReadOnly Property Duration As Integer
Get
Return (GetLocalEndTime() - GetLocalStartTime()).TotalSeconds
End Get
End Property

Public ReadOnly Property Width As Integer
Get
Return Duration / 10
End Get
End Property

Public Property Title As String

Public Sub New(duration As Long)
Me.StartTime = 0
Me.EndTime = duration
Me.Title = "Keine EPG-Daten vorhanden"
End Sub

Public Function GetLocalStartTime() As Date
Dim startTime As New DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)
Return startTime.AddSeconds(Me.StartTime).ToLocalTime()
End Function

Public Function GetLocalEndTime() As Date
Dim endtime As New DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)
Return endtime.AddSeconds(Me.EndTime).ToLocalTime()
End Function
End Class
End Namespace
42 changes: 31 additions & 11 deletions Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SatIPTV" xmlns:wpf="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
xmlns:vm="clr-namespace:SatIPTV.ViewModels"
xmlns:vmm="clr-namespace:SatIPTV.ViewModels.Models"
xmlns:Behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:materialIcons="clr-namespace:Material.Icons.WPF;assembly=Material.Icons.WPF"
Expand Down Expand Up @@ -59,6 +60,11 @@
</Style>
</Style.Resources>
</Style>
<Style TargetType="{x:Type Border}" x:Key="NonEpgItemStyle">
<Style.Setters>
<Setter Property="Width" Value="{Binding Width}" />
</Style.Setters>
</Style>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -273,20 +279,24 @@
</ItemsControl.ItemsPanel>
</ItemsControl>

<ScrollViewer x:Name="EpgProgramScrollView" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" Grid.Column="1">
<ScrollViewer x:Name="EpgProgramScrollView" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Disabled" Grid.Column="1"
PreviewMouseLeftButtonDown="EpgProgramScrollView_PreviewMouseLeftButtonDown"
PreviewMouseLeftButtonUp="EpgProgramScrollView_PreviewMouseLeftButtonUp"
PreviewMouseMove="EpgProgramScrollView_PreviewMouseMove">
<Grid>
<ItemsControl ItemsSource="{Binding ChannelList}" Grid.Column="1" Grid.Row="1">
<ItemsControl x:Name="ChannelListItemsControl" ItemsSource="{Binding ChannelList}" Grid.Column="1" Grid.Row="1">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="ChannelViewModel" >
<ItemsControl ItemsSource="{Binding EpgInfos}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="EpgInfoViewModel" >
<ItemsControl x:Name="EpgInfosItemsControl" ItemsSource="{Binding EpgInfos}">
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type vmm:EpgInfoViewModel}" >
<Border x:Name="EpgItem" BorderThickness="1" BorderBrush="Black"
Height="40" Opacity="0.9" Padding="2" Style="{StaticResource EpgItemStyle}"
PreviewMouseLeftButtonDown="EpgItem_PreviewMouseLeftButtonDown"
PreviewMouseLeftButtonUp="EpgItem_PreviewMouseLeftButtonUp"
PreviewMouseMove="EpgItem_PreviewMouseMove">
<StackPanel Orientation="Vertical">
PreviewMouseLeftButtonDown="EpgItem_PreviewMouseLeftButtonDown"
PreviewMouseMove="EpgItem_PreviewMouseMove"
>
<StackPanel Orientation="Vertical" x:Name="EpgItemInfo" HorizontalAlignment="Left" Loaded="EpgItemInfo_Loaded">
<TextBlock Text="{Binding Title}" FontSize="14" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding TimeSpanString}" FontSize="10" Margin="0,0,10,0" />
Expand All @@ -300,7 +310,17 @@
</Border.ToolTip>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type vmm:NonEpgInfoViewModel}" >
<Border x:Name="EpgItem" BorderThickness="1" BorderBrush="Black"
Height="40" Opacity="0.9" Padding="2" Style="{StaticResource NonEpgItemStyle}"
PreviewMouseLeftButtonUp="EpgItem_PreviewMouseLeftButtonUp">
<StackPanel Orientation="Vertical" x:Name="EpgItemInfo" HorizontalAlignment="Left" Loaded="EpgItemInfo_Loaded">
<TextBlock Text="{Binding Title}" FontSize="14" />
<TextBlock Text="{Binding TimeSpanString}" FontSize="10" Margin="0,0,10,0" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.Resources>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
Expand All @@ -315,8 +335,8 @@
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Border x:Name="CurrentTimeBar" Height="550" Width="2" Background="#44FF0000" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1" />
<Border x:Name="MouseTimeBar" Height="550" Width="1" BorderThickness="1,0,1,1" HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1" IsHitTestVisible="False" >
<Border x:Name="CurrentTimeBar" Width="2" Background="#44FF0000" HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Row="1" />
<Border x:Name="MouseTimeBar" Width="1" BorderThickness="1,0,1,1" HorizontalAlignment="Left" VerticalAlignment="Stretch" Grid.Row="1" IsHitTestVisible="False" >
<Border.BorderBrush>
<DrawingBrush Viewport="0,0,8,8" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
Expand Down
Loading

0 comments on commit 6a4e4a3

Please sign in to comment.