Uhr: separates Fenster fuer WebView-Modus, HWND-Airspace-Fix
This commit is contained in:
parent
30ac4ede6c
commit
085a904444
3 changed files with 67 additions and 2 deletions
16
ClockWindow.xaml
Normal file
16
ClockWindow.xaml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<Window x:Class="FritzTV.ClockWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
ShowInTaskbar="False"
|
||||
IsHitTestVisible="False"
|
||||
Topmost="True"
|
||||
SizeToContent="WidthAndHeight">
|
||||
<Border Background="#AA000000" CornerRadius="8" Padding="20,10">
|
||||
<TextBlock x:Name="TxtClock"
|
||||
Foreground="White" FontSize="48" FontWeight="Light"
|
||||
FontFamily="Segoe UI"/>
|
||||
</Border>
|
||||
</Window>
|
||||
13
ClockWindow.xaml.cs
Normal file
13
ClockWindow.xaml.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using System.Windows;
|
||||
|
||||
namespace FritzTV;
|
||||
|
||||
public partial class ClockWindow : Window
|
||||
{
|
||||
public ClockWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void UpdateTime(string time) => TxtClock.Text = time;
|
||||
}
|
||||
|
|
@ -45,6 +45,7 @@ public partial class MainWindow : Window
|
|||
// Uhr
|
||||
private readonly DispatcherTimer _clockTimer;
|
||||
private bool _clockVisible = false;
|
||||
private ClockWindow? _clockWindow;
|
||||
|
||||
// WndProc-Hook für globale Tastatureingaben (auch wenn WebView2 Fokus hat)
|
||||
private System.Windows.Interop.HwndSource? _hwndSource;
|
||||
|
|
@ -99,7 +100,13 @@ public partial class MainWindow : Window
|
|||
|
||||
// Uhr-Timer (jede Sekunde)
|
||||
_clockTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
|
||||
_clockTimer.Tick += (_, _) => TxtClock.Text = DateTime.Now.ToString("HH:mm:ss");
|
||||
_clockTimer.Tick += (_, _) =>
|
||||
{
|
||||
var time = DateTime.Now.ToString("HH:mm:ss");
|
||||
TxtClock.Text = time;
|
||||
_clockWindow?.UpdateTime(time);
|
||||
PositionClockWindow();
|
||||
};
|
||||
|
||||
Loaded += MainWindow_Loaded;
|
||||
Closing += MainWindow_Closing;
|
||||
|
|
@ -218,6 +225,7 @@ public partial class MainWindow : Window
|
|||
_zapTimer.Stop();
|
||||
_epgRefreshTimer.Stop();
|
||||
_clockTimer.Stop();
|
||||
_clockWindow?.Close();
|
||||
_player?.Stop();
|
||||
_settings.LastChannel = _currentChannel?.Name ?? "";
|
||||
_settings.Volume = SldVolume.Value;
|
||||
|
|
@ -718,10 +726,19 @@ public partial class MainWindow : Window
|
|||
private void ToggleClock()
|
||||
{
|
||||
_clockVisible = !_clockVisible;
|
||||
var time = DateTime.Now.ToString("HH:mm:ss");
|
||||
if (_clockVisible)
|
||||
{
|
||||
TxtClock.Text = DateTime.Now.ToString("HH:mm:ss");
|
||||
// WPF-Overlay (fuer TV-Modus innerhalb VideoView)
|
||||
TxtClock.Text = time;
|
||||
ClockOverlay.Visibility = Visibility.Visible;
|
||||
|
||||
// Separates Fenster (fuer WebView-Modus, schwebt ueber allem)
|
||||
_clockWindow = new ClockWindow { Owner = this };
|
||||
_clockWindow.UpdateTime(time);
|
||||
PositionClockWindow();
|
||||
_clockWindow.Show();
|
||||
|
||||
_clockTimer.Start();
|
||||
BtnClock.Foreground = new System.Windows.Media.SolidColorBrush(
|
||||
System.Windows.Media.Color.FromRgb(0x00, 0x78, 0xD4));
|
||||
|
|
@ -729,12 +746,31 @@ public partial class MainWindow : Window
|
|||
else
|
||||
{
|
||||
ClockOverlay.Visibility = Visibility.Collapsed;
|
||||
_clockWindow?.Close();
|
||||
_clockWindow = null;
|
||||
_clockTimer.Stop();
|
||||
BtnClock.Foreground = new System.Windows.Media.SolidColorBrush(
|
||||
System.Windows.Media.Color.FromRgb(0x88, 0x88, 0x88));
|
||||
}
|
||||
}
|
||||
|
||||
private void PositionClockWindow()
|
||||
{
|
||||
if (_clockWindow == null) return;
|
||||
try
|
||||
{
|
||||
// Oben rechts im Player-Bereich positionieren
|
||||
var area = VideoView.Visibility == Visibility.Visible
|
||||
? (System.Windows.FrameworkElement)VideoView
|
||||
: WebView;
|
||||
var pt = area.PointToScreen(new System.Windows.Point(area.ActualWidth, 0));
|
||||
// 16px Margin, Fensterbreite abziehen (wird erst nach Show() bekannt)
|
||||
_clockWindow.Left = pt.X - _clockWindow.ActualWidth - 16;
|
||||
_clockWindow.Top = pt.Y + 16;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void ToggleFullscreen()
|
||||
{
|
||||
if (!_isFullscreen)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue