using System.Windows;
using System.Windows.Controls;
using ytLive.ViewModels;
namespace ytLive.Controls;
public partial class OverlayHost : UserControl
{
public OverlayHost()
{
InitializeComponent();
#if DEBUG
// Development affordances are added at runtime, never declared in XAML: the panel is
// excluded from the Release compile (ytLive.csproj), so this line is the only
// reference to it and a Release build has none.
DeveloperPanelHost.Children.Add(new DeveloperPanel());
#endif
}
/// Is the enlarged brand-logo preview showing? Test seam — a Popup is a separate
/// window, so nothing else can observe it.
internal bool IsBrandLogoPreviewOpen => BrandLogoPreviewPopup.IsOpen;
/// Hover opens the enlargement. Nothing to show when no image is set, so the
/// thumbnail simply does nothing in that case.
private void BrandLogoThumb_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
=> OpenBrandLogoPreview();
/// Leaving the thumbnail closes it — unless the pointer walked onto the popup
/// itself (which sits beside it), where it stays put so the creator can look closely.
private void BrandLogoThumb_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
{
if (BrandLogoPreviewPopup.Child?.IsMouseOver == true) return;
CloseBrandLogoPreview();
}
/// A click collapses the enlargement — the explicit "enough, thanks" gesture.
private void BrandLogoThumb_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
=> CloseBrandLogoPreview();
private void BrandLogoPreviewPopup_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
=> CloseBrandLogoPreview();
/// The thumbnail is hidden when no image is set (see the XAML), so there is nothing
/// to open in that case — no empty frame can appear.
internal void OpenBrandLogoPreview() => BrandLogoPreviewPopup.IsOpen = true;
internal void CloseBrandLogoPreview() => BrandLogoPreviewPopup.IsOpen = false;
private void BackToAbout_Click(object sender, RoutedEventArgs e)
{
if (DataContext is MainViewModel vm)
{
vm.IsLicensesOpen = false;
vm.IsLicenseEntryOpen = false;
}
}
}