Creator directive, 2026-11-01. Settings stopped being a centred modal. - **Drawer** (Controls/SettingsDrawer): hosted in PreviewPane's pull-out stack, 320px, the same animated-width pattern as Stream Settings / YPP / Socials / TEST, opened by the gear rail tab on a single left click. SettingsDrawerOpen is exclusive with the other four, both directions. This also removes the modal's MaxHeight-700 scroll problem for good: the drawer is the height of the preview. - **Categories**: headings with controls indented beneath them. Zoom now owns *Zoom view shape* (Circle / Phone / Tablet) and *Zoom box follows*; Recordings, Brand logo and Scene transition are their own categories. - **The app menu moved to the LlamaCasty wordmark** (right-click → Report Bug / Feature Request / About). Left-click still opens About. The gear tab no longer carries a menu at all, so clicking it does exactly one thing. OverlayHost keeps only the Bug / Feature / About panels; its brand-logo handlers and the dev-panel injection moved with the settings block. BrandLogoPreviewTests follows the control (same assertions, new path). Release 0 warnings; 15 tests pass across brand logo, zoom, entitlement and preview history.
87 lines
2.8 KiB
C#
87 lines
2.8 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Net.Http;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Media.Imaging;
|
|
using ytLive.Helpers;
|
|
using ytLive.ViewModels;
|
|
|
|
namespace ytLive.Controls;
|
|
|
|
public partial class TopBar : UserControl
|
|
{
|
|
private static readonly HttpClient AvatarHttp = new() { Timeout = TimeSpan.FromSeconds(15) };
|
|
private string? _loadedAvatarUrl;
|
|
|
|
public TopBar()
|
|
{
|
|
InitializeComponent();
|
|
AvatarImage.Source = null;
|
|
AvatarInitial.Visibility = System.Windows.Visibility.Collapsed;
|
|
}
|
|
|
|
/// <summary>Right-click on the LlamaCasty wordmark opens the app menu (Report Bug / Feature
|
|
/// Request / About) — the menu that used to hang off the gear, which now opens the Settings
|
|
/// drawer directly (creator ruling 2026-11-01).</summary>
|
|
private void BrandWordmark_PreviewMouseRightButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
|
{
|
|
if (sender is Button { ContextMenu: { } menu } button)
|
|
{
|
|
menu.PlacementTarget = button;
|
|
menu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
|
|
menu.IsOpen = true;
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
|
|
public void RefreshAvatar()
|
|
{
|
|
_ = LoadAvatarImageAsync();
|
|
}
|
|
|
|
private async System.Threading.Tasks.Task LoadAvatarImageAsync()
|
|
{
|
|
var vm = DataContext as MainViewModel;
|
|
var url = vm?.AccountAvatarUrl;
|
|
if (vm is not { IsConnected: true })
|
|
{
|
|
ShowAvatarFallback(null);
|
|
return;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(url))
|
|
{
|
|
AppLog.Write("Avatar: connected but no profile image URL on the session");
|
|
ShowAvatarFallback(null);
|
|
return;
|
|
}
|
|
if (url == _loadedAvatarUrl && AvatarImage.Source != null) return;
|
|
try
|
|
{
|
|
var bytes = await AvatarHttp.GetByteArrayAsync(url);
|
|
using var ms = new MemoryStream(bytes);
|
|
var bitmap = new BitmapImage();
|
|
bitmap.BeginInit();
|
|
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
|
bitmap.StreamSource = ms;
|
|
bitmap.EndInit();
|
|
bitmap.Freeze();
|
|
_loadedAvatarUrl = url;
|
|
AvatarImage.Source = bitmap;
|
|
AvatarInitial.Visibility = System.Windows.Visibility.Collapsed;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
AppLog.Write($"Avatar load failed ({url}): {ex.Message}");
|
|
ShowAvatarFallback(vm?.AccountDisplayName);
|
|
}
|
|
}
|
|
|
|
private void ShowAvatarFallback(string? name)
|
|
{
|
|
_loadedAvatarUrl = null;
|
|
AvatarImage.Source = null;
|
|
AvatarInitial.Text = string.IsNullOrWhiteSpace(name) ? "?" : name.Substring(0, 1).ToUpperInvariant();
|
|
AvatarInitial.Visibility = System.Windows.Visibility.Visible;
|
|
}
|
|
} |