From bc23b643152abd4b6f82259d584dbc3506482f05 Mon Sep 17 00:00:00 2001 From: gramps Date: Sun, 30 Aug 2026 09:08:24 -0700 Subject: [PATCH] =?UTF-8?q?refactor:=20extract=20BottomBar=20out=20of=20Ma?= =?UTF-8?q?inWindow.xaml=20=E2=80=94=20Phase=202,=20Commit=2012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New Controls/ folder + namespace ytLive.Controls. BottomBar takes the Grid.Row=3 footer: gear menu button (with its GearButton_Click handler moved to the control's code-behind), centered stream-stats (bitrate/FPS/dropped/ duration/health), and the quality dropdown. All bindings inherit the window DataContext; app-level styles resolve from Themes/Controls.xaml as before. Zero behavior change; build 0 warnings; 246 pass, only the 2 known failures. Docs: ViewModels/index.md tracker gains a Phase 2 section in the same commit. --- Controls/BottomBar.xaml | 64 ++++++++++++++++++++++++++++++++++++++ Controls/BottomBar.xaml.cs | 22 +++++++++++++ MainWindow.xaml | 63 ++----------------------------------- MainWindow.xaml.cs | 10 ------ ViewModels/index.md | 5 ++- 5 files changed, 92 insertions(+), 72 deletions(-) create mode 100644 Controls/BottomBar.xaml create mode 100644 Controls/BottomBar.xaml.cs diff --git a/Controls/BottomBar.xaml b/Controls/BottomBar.xaml new file mode 100644 index 0000000..18686fb --- /dev/null +++ b/Controls/BottomBar.xaml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Controls/BottomBar.xaml.cs b/Controls/BottomBar.xaml.cs new file mode 100644 index 0000000..df355db --- /dev/null +++ b/Controls/BottomBar.xaml.cs @@ -0,0 +1,22 @@ +using System.Windows; +using System.Windows.Controls; + +namespace ytLive.Controls; + +public partial class BottomBar : UserControl +{ + public BottomBar() + { + InitializeComponent(); + } + + private void GearButton_Click(object sender, RoutedEventArgs e) + { + if (sender is Button { ContextMenu: { } menu } button) + { + menu.PlacementTarget = button; + menu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; + menu.IsOpen = true; + } + } +} \ No newline at end of file diff --git a/MainWindow.xaml b/MainWindow.xaml index 0f809f1..4d15880 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -6,6 +6,7 @@ xmlns:vm="clr-namespace:ytLive.ViewModels" xmlns:models="clr-namespace:ytLive.Models" xmlns:Helpers="clr-namespace:ytLive.Helpers" + xmlns:controls="clr-namespace:ytLive.Controls" xmlns:notifications="clr-namespace:Notification.Wpf.Controls;assembly=Notification.Wpf" mc:Ignorable="d" Title="{Binding WindowTitle}" Height="1040" Width="1920" @@ -1437,68 +1438,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index ff50937..afe5cc7 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -291,16 +291,6 @@ public partial class MainWindow : Window e.Handled = true; // the button's right-click context menu must not fire } - private void GearButton_Click(object sender, RoutedEventArgs e) - { - if (sender is Button { ContextMenu: { } menu } button) - { - menu.PlacementTarget = button; - menu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom; - menu.IsOpen = true; - } - } - private void BackToAbout_Click(object sender, RoutedEventArgs e) { if (DataContext is ViewModels.MainViewModel vm) diff --git a/ViewModels/index.md b/ViewModels/index.md index 7ef9d8a..9017529 100644 --- a/ViewModels/index.md +++ b/ViewModels/index.md @@ -51,7 +51,10 @@ Progress (Commit N/12 · tag): - [x] **Commit 9/12 · `refactor-commit-9`** — **Streaming** → `MainViewModel.Streaming.cs` - [x] **Commit 10/12 · `refactor-commit-10`** — **Chat** → `MainViewModel.Chat.cs` - [x] **Commit 11/12 · `refactor-commit-11`** — **Overlays** → `MainViewModel.Overlays.cs` -- [x] **Phase 1 complete:** core `MainViewModel.cs` split into 10 functional partials (1,890 → 758 lines). Phase 2 (splitting `MainWindow.xaml` into UserControls) not yet started. +- [x] **Phase 1 complete:** core `MainViewModel.cs` split into 10 functional partials (1,890 → 758 lines). + +**Phase 2 — `MainWindow.xaml` split into UserControls** (new `Controls/` folder, namespace `ytLive.Controls`): +- [x] **Commit 12 · `refactor-commit-12`** — **BottomBar** → `Controls/BottomBar.xaml(.cs)` (gear menu + stream stats + quality dropdown; `GearButton_Click` moved to the control's code-behind). Pending: TopBar, health banner, left scene/chat panel, preview pane, overlay host. The partial `.cs` files land next to `MainViewModel.cs` in this folder as the split proceeds; each partial carries its own `using`s and re-declares nothing from core. \ No newline at end of file