Thumbnail strip: show hotkey label next to each scene name
This commit is contained in:
+4
-3
@@ -238,11 +238,12 @@
|
||||
Stretch="UniformToFill"
|
||||
RenderOptions.BitmapScalingMode="LowQuality"/>
|
||||
</Border>
|
||||
<TextBlock Grid.Row="1" Text="{Binding Name}"
|
||||
Foreground="#a0a0b0" FontSize="10"
|
||||
<TextBlock Grid.Row="1" Foreground="#a0a0b0" FontSize="10"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="0,2,0,0"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
TextTrimming="CharacterEllipsis">
|
||||
<Run Text="{Binding Name, Mode=OneWay}"/><Run Text=" "/><Run Text="{Binding HotkeyLabel, Mode=OneWay}" Foreground="#6a6a7a" FontWeight="SemiBold"/>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
@@ -15,6 +15,7 @@ public class Scene : INotifyPropertyChanged
|
||||
private bool _hasSocialBar;
|
||||
private bool _isStaged;
|
||||
private bool _isLive;
|
||||
private string _hotkeyLabel = string.Empty;
|
||||
|
||||
public bool IsStaged
|
||||
{
|
||||
@@ -83,6 +84,16 @@ public class Scene : INotifyPropertyChanged
|
||||
set => Set(ref _snapshot, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current hotkey label for this scene (e.g. "F1", "Ctrl+F10").
|
||||
/// Set by MainViewModel from the active bindings; empty for non-canonical scenes.
|
||||
/// </summary>
|
||||
public string HotkeyLabel
|
||||
{
|
||||
get => _hotkeyLabel;
|
||||
set => Set(ref _hotkeyLabel, value);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private void Set<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using ytLive.Services;
|
||||
|
||||
namespace ytLive.Models;
|
||||
|
||||
@@ -21,6 +23,16 @@ public static class SceneCatalog
|
||||
|
||||
public static readonly string[] All = { Starting, Live, Brb, Chat, Ending };
|
||||
|
||||
/// <summary>Maps each canonical scene name to its hotkey action.</summary>
|
||||
public static readonly IReadOnlyDictionary<string, HotkeyId> SceneHotkeys = new Dictionary<string, HotkeyId>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
[Starting] = HotkeyId.SceneStarting,
|
||||
[Live] = HotkeyId.SceneLive,
|
||||
[Brb] = HotkeyId.SceneBrb,
|
||||
[Chat] = HotkeyId.SceneChat,
|
||||
[Ending] = HotkeyId.SceneEnding,
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string> DisplayNames = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
};
|
||||
|
||||
@@ -404,6 +404,22 @@ public class MainViewModel : ViewModelBase
|
||||
// Reload bindings from DB (the dialog already saved them).
|
||||
_hotkeyBindings = _layoutStore.LoadHotkeyBindings();
|
||||
HotkeyBindingsChanged?.Invoke(_hotkeyBindings);
|
||||
RefreshHotkeyLabels();
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshHotkeyLabels()
|
||||
{
|
||||
foreach (var scene in Scenes)
|
||||
{
|
||||
if (SceneCatalog.SceneHotkeys.TryGetValue(scene.Name, out var hid)
|
||||
&& _hotkeyBindings.TryGetValue(hid, out var chord))
|
||||
scene.HotkeyLabel = chord.ToDisplayString();
|
||||
else if (SceneCatalog.SceneHotkeys.TryGetValue(scene.Name, out var defId)
|
||||
&& GlobalHotkeyManager.Defaults.TryGetValue(defId, out var defChord))
|
||||
scene.HotkeyLabel = defChord.ToDisplayString();
|
||||
else
|
||||
scene.HotkeyLabel = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1842,6 +1858,7 @@ public class MainViewModel : ViewModelBase
|
||||
AddScene(name);
|
||||
}
|
||||
HealBackgrounds();
|
||||
RefreshHotkeyLabels();
|
||||
|
||||
foreach (var scene in Scenes)
|
||||
foreach (var config in scene.Elements.OfType<WebcamSceneConfig>())
|
||||
|
||||
Reference in New Issue
Block a user