From 310c0f224f4c0805d488171bec0e5b6d00ae91cf Mon Sep 17 00:00:00 2001 From: lincube Date: Sat, 28 Feb 2026 04:51:00 +0800 Subject: [PATCH] 0.1.7 --- LanMontainDesktop/Localization/en-US.json | 5 + .../Views/MainWindow.Localization.cs | 8 + .../Views/MainWindow.Settings.cs | 101 ++++++++++- LanMontainDesktop/Views/MainWindow.axaml | 161 +++++++++++++++--- LanMontainDesktop/Views/MainWindow.axaml.cs | 27 +++ 5 files changed, 271 insertions(+), 31 deletions(-) diff --git a/LanMontainDesktop/Localization/en-US.json b/LanMontainDesktop/Localization/en-US.json index 0a0b78f..4de8237 100644 --- a/LanMontainDesktop/Localization/en-US.json +++ b/LanMontainDesktop/Localization/en-US.json @@ -74,8 +74,13 @@ "filepicker.video_files": "Video files", "common.day": "Day", "common.night": "Night", + "common.close": "Close", "common.recommended": "Recommended", "common.monet": "Monet", + "button.component_library": "Component Library", + "tooltip.component_library": "Component Library", + "component_library.title": "Component Library", + "component_library.empty": "No components yet. Components will appear here later.", "placement.fill": "Fill", "placement.fit": "Fit", "placement.stretch": "Stretch", diff --git a/LanMontainDesktop/Views/MainWindow.Localization.cs b/LanMontainDesktop/Views/MainWindow.Localization.cs index c6dc367..53e0ad4 100644 --- a/LanMontainDesktop/Views/MainWindow.Localization.cs +++ b/LanMontainDesktop/Views/MainWindow.Localization.cs @@ -58,6 +58,14 @@ public partial class MainWindow BackToWindowsTextBlock.Text = L("button.back_to_windows", "Back to Windows"); WallpaperPreviewBackButtonTextBlock.Text = L("button.back_to_windows", "Back to Windows"); ToolTip.SetTip(BackToWindowsButton, L("tooltip.back_to_windows", "Back to Windows")); + OpenComponentLibraryTextBlock.Text = L("button.component_library", "组件库"); + WallpaperPreviewComponentLibraryTextBlock.Text = L("button.component_library", "组件库"); + ToolTip.SetTip(OpenComponentLibraryButton, L("tooltip.component_library", "组件库")); + ComponentLibraryTitleTextBlock.Text = L("component_library.title", "组件库"); + ToolTip.SetTip(CloseComponentLibraryButton, L("common.close", "关闭")); + ComponentLibraryEmptyTextBlock.Text = L( + "component_library.empty", + "暂无组件,后续将在这里显示。"); SettingsTitleTextBlock.Text = L("settings.title", "Settings"); SettingsNavHeaderTextBlock.Text = L("settings.nav_header", "Settings"); diff --git a/LanMontainDesktop/Views/MainWindow.Settings.cs b/LanMontainDesktop/Views/MainWindow.Settings.cs index e93d0d8..517a24a 100644 --- a/LanMontainDesktop/Views/MainWindow.Settings.cs +++ b/LanMontainDesktop/Views/MainWindow.Settings.cs @@ -24,6 +24,11 @@ public partial class MainWindow { private void OnOpenSettingsClick(object? sender, RoutedEventArgs e) { + if (_isComponentLibraryOpen) + { + CloseComponentLibraryWindow(reopenSettings: false); + } + if (_isSettingsOpen) { CloseSettingsPage(); @@ -33,6 +38,27 @@ public partial class MainWindow OpenSettingsPage(); } + private void OnOpenComponentLibraryClick(object? sender, RoutedEventArgs e) + { + if (_isComponentLibraryOpen) + { + return; + } + + _reopenSettingsAfterComponentLibraryClose = _isSettingsOpen; + if (_isSettingsOpen) + { + CloseSettingsPage(immediate: true); + } + + OpenComponentLibraryWindow(); + } + + private void OnCloseComponentLibraryClick(object? sender, RoutedEventArgs e) + { + CloseComponentLibraryWindow(reopenSettings: true); + } + private void OnCloseSettingsClick(object? sender, RoutedEventArgs e) { CloseSettingsPage(); @@ -701,8 +727,10 @@ public partial class MainWindow private void ApplyTaskbarActionVisibility(TaskbarContext context) { if (BackToWindowsButton is null || + OpenComponentLibraryButton is null || OpenSettingsButton is null || WallpaperPreviewBackButtonVisual is null || + WallpaperPreviewComponentLibraryVisual is null || WallpaperPreviewSettingsButtonIcon is null) { return; @@ -710,10 +738,13 @@ public partial class MainWindow var showMinimize = _pinnedTaskbarActions.Contains(TaskbarActionId.MinimizeToWindows); var showSettings = _pinnedTaskbarActions.Contains(TaskbarActionId.OpenSettings); + var showComponentLibrary = _isSettingsOpen || _isComponentLibraryOpen; BackToWindowsButton.IsVisible = showMinimize; + OpenComponentLibraryButton.IsVisible = showComponentLibrary; OpenSettingsButton.IsVisible = showSettings; WallpaperPreviewBackButtonVisual.IsVisible = showMinimize; + WallpaperPreviewComponentLibraryVisual.IsVisible = showComponentLibrary; WallpaperPreviewSettingsButtonIcon.IsVisible = showSettings; if (TaskbarFixedActionsHost is not null) @@ -723,7 +754,7 @@ public partial class MainWindow if (TaskbarSettingsActionHost is not null) { - TaskbarSettingsActionHost.IsVisible = showSettings; + TaskbarSettingsActionHost.IsVisible = showSettings || showComponentLibrary; } if (WallpaperPreviewTaskbarFixedActionsHost is not null) @@ -733,7 +764,7 @@ public partial class MainWindow if (WallpaperPreviewTaskbarSettingsActionHost is not null) { - WallpaperPreviewTaskbarSettingsActionHost.IsVisible = showSettings; + WallpaperPreviewTaskbarSettingsActionHost.IsVisible = showSettings || showComponentLibrary; } var dynamicActions = ResolveDynamicTaskbarActions(context); @@ -775,6 +806,58 @@ public partial class MainWindow ApplyWidgetSizing(effectiveCellSize); } + private void OpenComponentLibraryWindow() + { + if (ComponentLibraryWindow is null) + { + return; + } + + _isComponentLibraryOpen = true; + ComponentLibraryWindow.IsVisible = true; + ComponentLibraryWindow.Opacity = 0; + ApplyTaskbarActionVisibility(GetCurrentTaskbarContext()); + + Dispatcher.UIThread.Post(() => + { + if (!_isComponentLibraryOpen || ComponentLibraryWindow is null) + { + return; + } + + ComponentLibraryWindow.Opacity = 1; + }, DispatcherPriority.Background); + } + + private void CloseComponentLibraryWindow(bool reopenSettings) + { + if (!_isComponentLibraryOpen || ComponentLibraryWindow is null) + { + return; + } + + _isComponentLibraryOpen = false; + ComponentLibraryWindow.Opacity = 0; + ApplyTaskbarActionVisibility(GetCurrentTaskbarContext()); + + DispatcherTimer.RunOnce(() => + { + if (_isComponentLibraryOpen || ComponentLibraryWindow is null) + { + return; + } + + ComponentLibraryWindow.IsVisible = false; + + var shouldReopenSettings = reopenSettings && _reopenSettingsAfterComponentLibraryClose; + _reopenSettingsAfterComponentLibraryClose = false; + if (shouldReopenSettings) + { + OpenSettingsPage(); + } + }, TimeSpan.FromMilliseconds(200)); + } + private IReadOnlyList ResolveDynamicTaskbarActions(TaskbarContext context) { if (!_enableDynamicTaskbarActions) @@ -1182,6 +1265,11 @@ public partial class MainWindow private void OpenSettingsPage() { + if (_isComponentLibraryOpen) + { + return; + } + if (_isSettingsOpen) { return; @@ -1207,7 +1295,7 @@ public partial class MainWindow }, DispatcherPriority.Background); } - private void CloseSettingsPage() + private void CloseSettingsPage(bool immediate = false) { if (!_isSettingsOpen) { @@ -1219,6 +1307,13 @@ public partial class MainWindow ApplyWallpaperBrush(); ApplyTaskbarActionVisibility(GetCurrentTaskbarContext()); + if (immediate) + { + SettingsPage.Opacity = 0; + SettingsPage.IsVisible = false; + return; + } + SettingsPage.Opacity = 0; DispatcherTimer.RunOnce(() => diff --git a/LanMontainDesktop/Views/MainWindow.axaml b/LanMontainDesktop/Views/MainWindow.axaml index 6ec3287..f86ff35 100644 --- a/LanMontainDesktop/Views/MainWindow.axaml +++ b/LanMontainDesktop/Views/MainWindow.axaml @@ -162,28 +162,56 @@ Grid.Column="2" Background="Transparent" BorderThickness="0"> - + + + + + @@ -377,8 +405,8 @@ + Foreground="{DynamicResource AdaptiveTextPrimaryBrush}" + Text="回到Windows" /> @@ -398,10 +426,30 @@ Grid.Column="2" Background="Transparent" BorderThickness="0"> - + + + + + + + @@ -776,6 +824,63 @@ + + + + + + + + + + + + + + + + + + + diff --git a/LanMontainDesktop/Views/MainWindow.axaml.cs b/LanMontainDesktop/Views/MainWindow.axaml.cs index f90e4fa..2c89147 100644 --- a/LanMontainDesktop/Views/MainWindow.axaml.cs +++ b/LanMontainDesktop/Views/MainWindow.axaml.cs @@ -76,6 +76,8 @@ public partial class MainWindow : Window private bool _suppressLanguageSelectionEvents; private bool _suppressSettingsPersistence; private bool _isUpdatingWallpaperPreviewLayout; + private bool _isComponentLibraryOpen; + private bool _reopenSettingsAfterComponentLibraryClose; private TranslateTransform? _settingsContentPanelTransform; private IBrush? _defaultDesktopBackground; private Bitmap? _wallpaperBitmap; @@ -327,6 +329,11 @@ public partial class MainWindow : Window BackToWindowsButton.FontSize = Math.Clamp(cellSize * 0.22, 8, 22); BackToWindowsButton.MinHeight = taskbarCell; BackToWindowsButton.MinWidth = Math.Clamp(cellSize * 2.3, 90, 320); + OpenComponentLibraryButton.Margin = new Thickness(0); + OpenComponentLibraryButton.Padding = new Thickness(horizontalPadding, verticalPadding); + OpenComponentLibraryButton.FontSize = Math.Clamp(cellSize * 0.22, 8, 22); + OpenComponentLibraryButton.MinHeight = taskbarCell; + OpenComponentLibraryButton.MinWidth = Math.Clamp(cellSize * 2.0, 88, 300); OpenSettingsButton.Margin = new Thickness(0); OpenSettingsButton.Height = taskbarCell; @@ -344,6 +351,23 @@ public partial class MainWindow : Window OpenSettingsButton.MinWidth = taskbarCell; OpenSettingsButton.Padding = new Thickness(Math.Clamp(taskbarCell * 0.2, 4, 12)); } + + UpdateComponentLibraryLayout(cellSize); + } + + private void UpdateComponentLibraryLayout(double cellSize) + { + if (ComponentLibraryWindow is null) + { + return; + } + + var horizontalMargin = Math.Clamp(cellSize * 0.7, 18, 44); + var bottomMargin = Math.Clamp(cellSize * 1.4, 56, 190); + ComponentLibraryWindow.Margin = new Thickness(horizontalMargin, 20, horizontalMargin, bottomMargin); + ComponentLibraryWindow.CornerRadius = new CornerRadius(Math.Clamp(cellSize * 0.24, 12, 24)); + ComponentLibraryWindow.Height = Math.Clamp(cellSize * 4.8, 220, 360); + ComponentLibraryWindow.Width = Math.Clamp(cellSize * 9.2, 360, 760); } private void UpdateSettingsViewportInsets(double cellSize) @@ -473,8 +497,11 @@ public partial class MainWindow : Window WallpaperPreviewClockTextBlock.FontSize = Math.Clamp(cellSize * 0.30, 6, 18); WallpaperPreviewBackButtonTextBlock.FontSize = Math.Clamp(cellSize * 0.19, 5, 13); + WallpaperPreviewComponentLibraryTextBlock.FontSize = Math.Clamp(cellSize * 0.18, 5, 12); WallpaperPreviewBackButtonVisual.MinHeight = previewTaskbarCell; WallpaperPreviewBackButtonVisual.MinWidth = Math.Clamp(cellSize * 2.1, 30, 120); + WallpaperPreviewComponentLibraryVisual.MinHeight = previewTaskbarCell; + WallpaperPreviewComponentLibraryVisual.MinWidth = Math.Clamp(cellSize * 2.0, 28, 110); WallpaperPreviewSettingsButtonIcon.Width = Math.Clamp(previewTaskbarCell * 0.42, 6, 14); WallpaperPreviewSettingsButtonIcon.Height = Math.Clamp(previewTaskbarCell * 0.42, 6, 14); }