mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-22 00:54:26 +08:00
settings_re5
This commit is contained in:
@@ -13,6 +13,7 @@ using FluentAvalonia.UI.Controls;
|
||||
using LanMountainDesktop.Models;
|
||||
using LanMountainDesktop.PluginSdk;
|
||||
using LanMountainDesktop.Services;
|
||||
using LanMountainDesktop.Theme;
|
||||
using LanMountainDesktop.Views.Components;
|
||||
|
||||
namespace LanMountainDesktop.Views;
|
||||
@@ -193,6 +194,30 @@ public partial class MainWindow
|
||||
return false;
|
||||
}
|
||||
|
||||
private ThemeColorContext BuildAdaptiveThemeContext()
|
||||
{
|
||||
return new ThemeColorContext(
|
||||
_selectedThemeColor,
|
||||
IsLightBackground: !_isNightMode,
|
||||
IsLightNavBackground: !_isNightMode,
|
||||
IsNightMode: _isNightMode);
|
||||
}
|
||||
|
||||
private void ApplyAdaptiveThemeResources()
|
||||
{
|
||||
var context = BuildAdaptiveThemeContext();
|
||||
ThemeColorSystemService.ApplyThemeResources(Resources, context);
|
||||
GlassEffectService.ApplyGlassResources(Resources, context);
|
||||
|
||||
if (Application.Current?.Resources is { } applicationResources)
|
||||
{
|
||||
ThemeColorSystemService.ApplyThemeResources(applicationResources, context);
|
||||
GlassEffectService.ApplyGlassResources(applicationResources, context);
|
||||
}
|
||||
|
||||
_defaultDesktopBackground = GetThemeBrush("AdaptiveSurfaceBaseBrush");
|
||||
}
|
||||
|
||||
private void TryRestoreWallpaper(string? savedWallpaperPath)
|
||||
{
|
||||
_wallpaperPath = string.IsNullOrWhiteSpace(savedWallpaperPath) ? null : savedWallpaperPath;
|
||||
@@ -285,6 +310,9 @@ public partial class MainWindow
|
||||
Application.Current.RequestedThemeVariant = requestedThemeVariant;
|
||||
}
|
||||
|
||||
ApplyAdaptiveThemeResources();
|
||||
ApplyWallpaperBrush();
|
||||
|
||||
if (!refreshPalettes)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -25,43 +25,6 @@
|
||||
<Design.DataContext>
|
||||
<vm:MainWindowViewModel />
|
||||
</Design.DataContext>
|
||||
|
||||
<Window.Resources>
|
||||
<SolidColorBrush x:Key="AdaptivePrimaryBrush" Color="#FF1D4ED8" />
|
||||
<SolidColorBrush x:Key="AdaptiveSecondaryBrush" Color="#FF1E40AF" />
|
||||
<SolidColorBrush x:Key="AdaptiveTextPrimaryBrush" Color="#FFF8FAFC" />
|
||||
<SolidColorBrush x:Key="AdaptiveTextSecondaryBrush" Color="#FFE2E8F0" />
|
||||
<SolidColorBrush x:Key="AdaptiveTextMutedBrush" Color="#FF94A3B8" />
|
||||
<SolidColorBrush x:Key="AdaptiveTextAccentBrush" Color="#FF93C5FD" />
|
||||
<SolidColorBrush x:Key="AdaptiveAccentBrush" Color="#FF3B82F6" />
|
||||
<SolidColorBrush x:Key="AdaptiveOnAccentBrush" Color="#FFFFFFFF" />
|
||||
<SolidColorBrush x:Key="AdaptiveSurfaceBaseBrush" Color="#FF020617" />
|
||||
<SolidColorBrush x:Key="AdaptiveSurfaceRaisedBrush" Color="#FF1E293B" />
|
||||
<SolidColorBrush x:Key="AdaptiveSurfaceOverlayBrush" Color="#CC0F172A" />
|
||||
<SolidColorBrush x:Key="AdaptiveButtonBackgroundBrush" Color="#66334155" />
|
||||
<SolidColorBrush x:Key="AdaptiveButtonBorderBrush" Color="#80E2E8F0" />
|
||||
<SolidColorBrush x:Key="AdaptiveButtonHoverBackgroundBrush" Color="#88475A74" />
|
||||
<SolidColorBrush x:Key="AdaptiveButtonPressedBackgroundBrush" Color="#AA2A3B55" />
|
||||
<SolidColorBrush x:Key="AdaptiveGlassPanelBackgroundBrush" Color="#70233448" />
|
||||
<SolidColorBrush x:Key="AdaptiveGlassPanelBorderBrush" Color="#70475569" />
|
||||
<SolidColorBrush x:Key="AdaptiveGlassStrongBackgroundBrush" Color="#A01E293B" />
|
||||
<SolidColorBrush x:Key="AdaptiveGlassStrongBorderBrush" Color="#80475569" />
|
||||
<SolidColorBrush x:Key="AdaptiveGlassOverlayBackgroundBrush" Color="#9A0F172A" />
|
||||
<SolidColorBrush x:Key="AdaptiveNavTextBrush" Color="#FFF8FAFC" />
|
||||
<SolidColorBrush x:Key="AdaptiveNavSelectedTextBrush" Color="#FFFFFFFF" />
|
||||
<SolidColorBrush x:Key="AdaptiveNavSelectionIndicatorBrush" Color="#FF93C5FD" />
|
||||
<SolidColorBrush x:Key="AdaptiveNavItemBackgroundBrush" Color="#220F172A" />
|
||||
<SolidColorBrush x:Key="AdaptiveNavItemHoverBackgroundBrush" Color="#40334155" />
|
||||
<SolidColorBrush x:Key="AdaptiveNavItemSelectedBackgroundBrush" Color="#CC1D4ED8" />
|
||||
<SolidColorBrush x:Key="AdaptiveToggleOnBrush" Color="#FF3B82F6" />
|
||||
<SolidColorBrush x:Key="AdaptiveToggleOffBrush" Color="#66475569" />
|
||||
<SolidColorBrush x:Key="AdaptiveToggleBorderBrush" Color="#80E2E8F0" />
|
||||
<x:Double x:Key="AdaptiveGlassPanelBlurRadius">22</x:Double>
|
||||
<x:Double x:Key="AdaptiveGlassStrongBlurRadius">28</x:Double>
|
||||
<x:Double x:Key="AdaptiveGlassPanelOpacity">0.92</x:Double>
|
||||
<x:Double x:Key="AdaptiveGlassStrongOpacity">0.95</x:Double>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid x:Name="DesktopPage"
|
||||
HorizontalAlignment="Stretch"
|
||||
|
||||
@@ -3,78 +3,102 @@
|
||||
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
||||
xmlns:controls="using:LanMountainDesktop.Controls"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||
x:Class="LanMountainDesktop.Views.SettingsPages.AboutSettingsPage"
|
||||
x:DataType="vm:AboutSettingsPageViewModel">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Classes="settings-page-container">
|
||||
<TextBlock Classes="settings-section-title"
|
||||
Text="{Binding PageTitle}" />
|
||||
<TextBlock Classes="settings-section-description"
|
||||
Text="{Binding PageDescription}" />
|
||||
|
||||
<controls:SettingsSectionCard IconKey="Info"
|
||||
Title="{Binding AppInfoHeader}">
|
||||
<controls:SettingsSectionCard.CardContent>
|
||||
<StackPanel Spacing="14">
|
||||
<StackPanel Classes="settings-item">
|
||||
<TextBlock Classes="settings-item-label"
|
||||
Text="{Binding VersionLabel}" />
|
||||
<TextBlock Opacity="0.82"
|
||||
Text="{Binding VersionText}" />
|
||||
</StackPanel>
|
||||
<!-- 应用信息分组 -->
|
||||
<controls:IconText Icon="Info"
|
||||
Text="{Binding AppInfoHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<StackPanel Classes="settings-item">
|
||||
<TextBlock Classes="settings-item-label"
|
||||
Text="{Binding RenderBackendLabel}" />
|
||||
<TextBlock Opacity="0.82"
|
||||
Text="{Binding RenderBackendText}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</controls:SettingsSectionCard.CardContent>
|
||||
</controls:SettingsSectionCard>
|
||||
<ui:SettingsExpander Header="{Binding AppInfoHeader}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Info" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding VersionLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
Opacity="0.82"
|
||||
Text="{Binding VersionText}" />
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding RenderBackendLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBlock Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
Opacity="0.82"
|
||||
Text="{Binding RenderBackendText}" />
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<ui:SettingsExpander Classes="settings-expander-card"
|
||||
Header="{Binding UpdateHeader}"
|
||||
<Separator Classes="settings-separator" />
|
||||
|
||||
<!-- 更新设置分组 -->
|
||||
<controls:IconText Icon="ArrowSync"
|
||||
Text="{Binding UpdateHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ui:SettingsExpander Header="{Binding UpdateHeader}"
|
||||
IsExpanded="True">
|
||||
<StackPanel Spacing="12">
|
||||
<controls:SettingsOptionCard IconKey="ArrowSync"
|
||||
Title="{Binding AutoCheckUpdatesLabel}">
|
||||
<controls:SettingsOptionCard.ActionContent>
|
||||
<ToggleSwitch IsChecked="{Binding AutoCheckUpdates}" />
|
||||
</controls:SettingsOptionCard.ActionContent>
|
||||
</controls:SettingsOptionCard>
|
||||
|
||||
<controls:SettingsOptionCard IconKey="ArrowSync"
|
||||
Title="{Binding IncludePrereleaseUpdatesLabel}">
|
||||
<controls:SettingsOptionCard.ActionContent>
|
||||
<ToggleSwitch IsChecked="{Binding IncludePrereleaseUpdates}" />
|
||||
</controls:SettingsOptionCard.ActionContent>
|
||||
</controls:SettingsOptionCard>
|
||||
|
||||
<controls:SettingsOptionCard IconKey="ArrowSync"
|
||||
Title="{Binding UpdateChannelLabel}">
|
||||
<controls:SettingsOptionCard.DetailsContent>
|
||||
<ComboBox ItemsSource="{Binding UpdateChannels}"
|
||||
SelectedItem="{Binding SelectedUpdateChannel}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:SelectionOption">
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</controls:SettingsOptionCard.DetailsContent>
|
||||
</controls:SettingsOptionCard>
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Spacing="12">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="ArrowSync" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding AutoCheckUpdatesLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<ToggleSwitch Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
IsChecked="{Binding AutoCheckUpdates}" />
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding IncludePrereleaseUpdatesLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<ToggleSwitch Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
IsChecked="{Binding IncludePrereleaseUpdates}" />
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding UpdateChannelLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1"
|
||||
MinWidth="160"
|
||||
HorizontalAlignment="Right"
|
||||
ItemsSource="{Binding UpdateChannels}"
|
||||
SelectedItem="{Binding SelectedUpdateChannel}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:SelectionOption">
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
<ui:SettingsExpanderItem>
|
||||
<StackPanel Spacing="8">
|
||||
<Button Command="{Binding CheckForUpdatesCommand}"
|
||||
Content="{Binding CheckForUpdatesButtonText}" />
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Opacity="0.76"
|
||||
<TextBlock Opacity="0.76"
|
||||
FontSize="12"
|
||||
TextWrapping="Wrap"
|
||||
Text="{Binding UpdateStatus}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
|
||||
@@ -2,96 +2,79 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
||||
xmlns:controls="using:LanMountainDesktop.Controls"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||
x:Class="LanMountainDesktop.Views.SettingsPages.AppearanceSettingsPage"
|
||||
x:DataType="vm:AppearanceSettingsPageViewModel">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Classes="settings-page-container">
|
||||
<TextBlock Classes="settings-section-title"
|
||||
Text="{Binding PageTitle}" />
|
||||
<TextBlock Classes="settings-section-description"
|
||||
Text="{Binding PageDescription}" />
|
||||
|
||||
<controls:SettingsOptionCard IconKey="DesignIdeas"
|
||||
Title="{Binding NightModeLabel}">
|
||||
<controls:SettingsOptionCard.ActionContent>
|
||||
<controls:IconText Icon="Color"
|
||||
Text="{Binding ThemeHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ui:SettingsExpander Header="{Binding NightModeLabel}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="WeatherMoon" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding IsNightMode}" />
|
||||
</controls:SettingsOptionCard.ActionContent>
|
||||
</controls:SettingsOptionCard>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<controls:SettingsOptionCard IconKey="DesignIdeas"
|
||||
Title="{Binding UseSystemChromeLabel}">
|
||||
<controls:SettingsOptionCard.ActionContent>
|
||||
<ui:SettingsExpander Header="{Binding UseSystemChromeLabel}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Window" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding UseSystemChrome}" />
|
||||
</controls:SettingsOptionCard.ActionContent>
|
||||
</controls:SettingsOptionCard>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<controls:SettingsOptionCard IconKey="DesignIdeas"
|
||||
Title="{Binding ThemeColorLabel}">
|
||||
<controls:SettingsOptionCard.DetailsContent>
|
||||
<ui:SettingsExpander Header="{Binding ThemeColorLabel}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Color" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<TextBox Watermark="#AABBCC"
|
||||
MinWidth="160"
|
||||
Text="{Binding ThemeColor}" />
|
||||
</controls:SettingsOptionCard.DetailsContent>
|
||||
</controls:SettingsOptionCard>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<controls:SettingsSectionCard IconKey="DesignIdeas"
|
||||
Title="{Binding WallpaperHeader}">
|
||||
<controls:SettingsSectionCard.CardContent>
|
||||
<StackPanel Spacing="14">
|
||||
<StackPanel Classes="settings-item">
|
||||
<TextBlock Classes="settings-item-label"
|
||||
Text="{Binding WallpaperPathLabel}" />
|
||||
<TextBox IsReadOnly="True"
|
||||
Text="{Binding WallpaperPath}" />
|
||||
</StackPanel>
|
||||
<Separator Classes="settings-separator" />
|
||||
|
||||
<StackPanel Classes="settings-item">
|
||||
<TextBlock Classes="settings-item-label"
|
||||
Text="{Binding WallpaperPlacementLabel}" />
|
||||
<ComboBox ItemsSource="{Binding WallpaperPlacements}"
|
||||
SelectedItem="{Binding SelectedWallpaperPlacement}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:SelectionOption">
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
<controls:IconText Icon="Clock"
|
||||
Text="{Binding ClockHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<Button HorizontalAlignment="Left"
|
||||
Click="OnBrowseWallpaperClick"
|
||||
Content="{Binding ImportWallpaperButtonText}" />
|
||||
</StackPanel>
|
||||
</controls:SettingsSectionCard.CardContent>
|
||||
</controls:SettingsSectionCard>
|
||||
<ui:SettingsExpander Header="{Binding ClockHeader}"
|
||||
Description="{Binding ClockDescription}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Clock" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<ToggleSwitch IsChecked="{Binding ShowClock}" />
|
||||
</ui:SettingsExpander.Footer>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding ClockFormatLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1"
|
||||
MinWidth="160"
|
||||
HorizontalAlignment="Right"
|
||||
ItemsSource="{Binding ClockFormats}"
|
||||
SelectedItem="{Binding SelectedClockFormat}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:SelectionOption">
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<controls:SettingsSectionCard IconKey="DesignIdeas"
|
||||
Title="{Binding ClockHeader}"
|
||||
Description="{Binding ClockDescription}">
|
||||
<controls:SettingsSectionCard.CardContent>
|
||||
<StackPanel Spacing="14">
|
||||
<controls:SettingsOptionCard IconKey="DesignIdeas"
|
||||
Title="{Binding ClockHeader}">
|
||||
<controls:SettingsOptionCard.ActionContent>
|
||||
<ToggleSwitch IsChecked="{Binding ShowClock}" />
|
||||
</controls:SettingsOptionCard.ActionContent>
|
||||
</controls:SettingsOptionCard>
|
||||
|
||||
<controls:SettingsOptionCard IconKey="DesignIdeas"
|
||||
Title="{Binding ClockFormatLabel}">
|
||||
<controls:SettingsOptionCard.DetailsContent>
|
||||
<ComboBox ItemsSource="{Binding ClockFormats}"
|
||||
SelectedItem="{Binding SelectedClockFormat}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:SelectionOption">
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</controls:SettingsOptionCard.DetailsContent>
|
||||
</controls:SettingsOptionCard>
|
||||
</StackPanel>
|
||||
</controls:SettingsSectionCard.CardContent>
|
||||
</controls:SettingsSectionCard>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using LanMountainDesktop.PluginSdk;
|
||||
using LanMountainDesktop.Services.Settings;
|
||||
using LanMountainDesktop.ViewModels;
|
||||
using System.Linq;
|
||||
|
||||
namespace LanMountainDesktop.Views.SettingsPages;
|
||||
|
||||
@@ -30,25 +27,4 @@ public partial class AppearanceSettingsPage : SettingsPageBase
|
||||
}
|
||||
|
||||
public AppearanceSettingsPageViewModel ViewModel { get; }
|
||||
|
||||
private async void OnBrowseWallpaperClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (TopLevel.GetTopLevel(this)?.StorageProvider is not { } storageProvider)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var files = await storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = ViewModel.FilePickerTitle,
|
||||
AllowMultiple = false
|
||||
});
|
||||
|
||||
var file = files.FirstOrDefault();
|
||||
var localPath = file?.TryGetLocalPath();
|
||||
if (!string.IsNullOrWhiteSpace(localPath))
|
||||
{
|
||||
await ViewModel.ImportWallpaperAsync(localPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,56 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
||||
xmlns:controls="using:LanMountainDesktop.Controls"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||
x:Class="LanMountainDesktop.Views.SettingsPages.ComponentsSettingsPage"
|
||||
x:DataType="vm:ComponentsSettingsPageViewModel">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Classes="settings-page-container">
|
||||
<TextBlock Classes="settings-section-title"
|
||||
Text="{Binding PageTitle}" />
|
||||
<TextBlock Classes="settings-section-description"
|
||||
Text="{Binding PageDescription}" />
|
||||
|
||||
<ui:SettingsExpander Classes="settings-expander-card"
|
||||
Header="{Binding GridHeader}"
|
||||
<!-- 网格布局设置分组 -->
|
||||
<controls:IconText Icon="GridDots"
|
||||
Text="{Binding GridHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ui:SettingsExpander Header="{Binding GridHeader}"
|
||||
IsExpanded="True">
|
||||
<StackPanel Spacing="14">
|
||||
<StackPanel Classes="settings-item">
|
||||
<TextBlock Classes="settings-item-label"
|
||||
Text="{Binding ShortSideCellsLabel}" />
|
||||
<NumericUpDown Minimum="6"
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="GridDots" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding ShortSideCellsLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1"
|
||||
MinWidth="120"
|
||||
HorizontalAlignment="Right"
|
||||
Minimum="6"
|
||||
Maximum="96"
|
||||
Value="{Binding ShortSideCells}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Classes="settings-item">
|
||||
<TextBlock Classes="settings-item-label"
|
||||
Text="{Binding EdgeInsetPercentLabel}" />
|
||||
<NumericUpDown Minimum="0"
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding EdgeInsetPercentLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<NumericUpDown Grid.Column="1"
|
||||
MinWidth="120"
|
||||
HorizontalAlignment="Right"
|
||||
Minimum="0"
|
||||
Maximum="30"
|
||||
Value="{Binding EdgeInsetPercent}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Classes="settings-item">
|
||||
<TextBlock Classes="settings-item-label"
|
||||
Text="{Binding SpacingPresetLabel}" />
|
||||
<ComboBox ItemsSource="{Binding SpacingPresets}"
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*">
|
||||
<TextBlock Text="{Binding SpacingPresetLabel}"
|
||||
VerticalAlignment="Center" />
|
||||
<ComboBox Grid.Column="1"
|
||||
MinWidth="160"
|
||||
HorizontalAlignment="Right"
|
||||
ItemsSource="{Binding SpacingPresets}"
|
||||
SelectedItem="{Binding SelectedSpacingPreset}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:SelectionOption">
|
||||
@@ -42,9 +58,10 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
|
||||
@@ -3,18 +3,22 @@
|
||||
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
||||
xmlns:controls="using:LanMountainDesktop.Controls"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||
x:Class="LanMountainDesktop.Views.SettingsPages.GeneralSettingsPage"
|
||||
x:DataType="vm:GeneralSettingsPageViewModel">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Classes="settings-page-container">
|
||||
<TextBlock Classes="settings-section-title"
|
||||
Text="{Binding PageTitle}" />
|
||||
<TextBlock Classes="settings-section-description"
|
||||
Text="{Binding PageDescription}" />
|
||||
|
||||
<controls:SettingsOptionCard IconKey="Settings"
|
||||
Title="{Binding LanguageHeader}">
|
||||
<controls:SettingsOptionCard.DetailsContent>
|
||||
<!-- 区域设置分组 -->
|
||||
<controls:IconText Icon="Globe"
|
||||
Text="{Binding BasicHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ui:SettingsExpander Header="{Binding LanguageHeader}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Settings" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<ComboBox MinWidth="240"
|
||||
ItemsSource="{Binding Languages}"
|
||||
SelectedItem="{Binding SelectedLanguage}">
|
||||
@@ -24,13 +28,15 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</controls:SettingsOptionCard.DetailsContent>
|
||||
</controls:SettingsOptionCard>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<controls:SettingsOptionCard IconKey="Settings"
|
||||
Title="{Binding TimeZoneHeader}"
|
||||
Description="{Binding TimeZoneDescription}">
|
||||
<controls:SettingsOptionCard.DetailsContent>
|
||||
<ui:SettingsExpander Header="{Binding TimeZoneHeader}"
|
||||
Description="{Binding TimeZoneDescription}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Clock" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<ComboBox MinWidth="280"
|
||||
ItemsSource="{Binding TimeZones}"
|
||||
SelectedItem="{Binding SelectedTimeZone}">
|
||||
@@ -40,12 +46,14 @@
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</controls:SettingsOptionCard.DetailsContent>
|
||||
</controls:SettingsOptionCard>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<controls:SettingsSectionCard IconKey="Info"
|
||||
Title="{Binding PreviewHeader}">
|
||||
<controls:SettingsSectionCard.CardContent>
|
||||
<ui:SettingsExpander Header="{Binding PreviewHeader}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Calendar" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpanderItem>
|
||||
<Grid ColumnDefinitions="Auto,*"
|
||||
ColumnSpacing="16"
|
||||
RowDefinitions="Auto,Auto"
|
||||
@@ -63,13 +71,22 @@
|
||||
Opacity="0.82"
|
||||
Text="{Binding PreviewDateText}" />
|
||||
</Grid>
|
||||
</controls:SettingsSectionCard.CardContent>
|
||||
</controls:SettingsSectionCard>
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<ui:SettingsExpander Classes="settings-expander-card"
|
||||
Header="{Binding RuntimeHeader}"
|
||||
<Separator Classes="settings-separator" />
|
||||
|
||||
<!-- 运行时设置分组 -->
|
||||
<controls:IconText Icon="DeveloperBoard"
|
||||
Text="{Binding RuntimeHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ui:SettingsExpander Header="{Binding RenderModeHeader}"
|
||||
Description="{Binding RuntimeDescription}"
|
||||
IsExpanded="True">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="DeveloperBoard" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<ComboBox MinWidth="240"
|
||||
ItemsSource="{Binding RenderModes}"
|
||||
@@ -81,7 +98,14 @@
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</ui:SettingsExpander.Footer>
|
||||
<ui:SettingsExpanderItem>
|
||||
<TextBlock Text="{Binding RenderModeRestartMessage}"
|
||||
Opacity="0.7"
|
||||
FontSize="12"
|
||||
TextWrapping="Wrap" />
|
||||
</ui:SettingsExpanderItem>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,87 +1,92 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
||||
xmlns:controls="using:LanMountainDesktop.Controls"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||
x:Class="LanMountainDesktop.Views.SettingsPages.PluginsSettingsPage"
|
||||
x:Name="Root"
|
||||
x:DataType="vm:PluginsSettingsPageViewModel">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Classes="settings-page-container">
|
||||
<TextBlock Classes="settings-section-title"
|
||||
Text="{Binding PageTitle}" />
|
||||
<TextBlock Classes="settings-section-description"
|
||||
Text="{Binding PageDescription}" />
|
||||
|
||||
<StackPanel Orientation="Horizontal"
|
||||
Spacing="12"
|
||||
Margin="0,0,0,18">
|
||||
<Button Command="{Binding RefreshCommand}"
|
||||
Content="{Binding RefreshButtonText}" />
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Opacity="0.76"
|
||||
Text="{Binding StatusMessage}" />
|
||||
</StackPanel>
|
||||
<!-- 刷新按钮和状态 -->
|
||||
<ui:SettingsExpander Header="{Binding RefreshButtonText}"
|
||||
Description="{Binding StatusMessage}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="ArrowSync" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<Button Command="{Binding RefreshCommand}"
|
||||
Content="{Binding RefreshButtonText}" />
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<TextBlock Classes="settings-subsection-title"
|
||||
Text="{Binding InstalledHeader}" />
|
||||
<Separator Classes="settings-separator" />
|
||||
|
||||
<!-- 已安装插件分组 -->
|
||||
<controls:IconText Icon="PuzzleCube"
|
||||
Text="{Binding InstalledHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ItemsControl ItemsSource="{Binding InstalledPlugins}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:InstalledPluginItemViewModel">
|
||||
<Border Classes="settings-list-item">
|
||||
<Grid Classes="settings-list-actions"
|
||||
ColumnDefinitions="*,Auto,Auto">
|
||||
<ui:SettingsExpander>
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="PuzzleCube" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Header>
|
||||
<StackPanel>
|
||||
<TextBlock FontWeight="SemiBold"
|
||||
Text="{Binding Name}" />
|
||||
<TextBlock Opacity="0.76"
|
||||
FontSize="12"
|
||||
Text="{Binding Description}" />
|
||||
<TextBlock Opacity="0.58"
|
||||
FontSize="11"
|
||||
Text="{Binding Version}" />
|
||||
<TextBlock FontWeight="SemiBold" Text="{Binding Name}" />
|
||||
<TextBlock Opacity="0.76" FontSize="12" Text="{Binding Description}" />
|
||||
</StackPanel>
|
||||
<ToggleSwitch Grid.Column="1"
|
||||
IsChecked="{Binding IsEnabled}"
|
||||
Command="{Binding #Root.DataContext.TogglePluginCommand}"
|
||||
CommandParameter="{Binding}" />
|
||||
<Button Grid.Column="2"
|
||||
Command="{Binding #Root.DataContext.DeletePluginCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="{Binding #Root.DataContext.DeleteButtonText}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</ui:SettingsExpander.Header>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<ToggleSwitch IsChecked="{Binding IsEnabled}"
|
||||
Command="{Binding #Root.DataContext.TogglePluginCommand}"
|
||||
CommandParameter="{Binding}" />
|
||||
<Button Command="{Binding #Root.DataContext.DeletePluginCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="{Binding #Root.DataContext.DeleteButtonText}" />
|
||||
</StackPanel>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
<TextBlock Classes="settings-subsection-title"
|
||||
Text="{Binding MarketplaceHeader}" />
|
||||
<Separator Classes="settings-separator" />
|
||||
|
||||
<!-- 市场插件分组 -->
|
||||
<controls:IconText Icon="ShoppingBag"
|
||||
Text="{Binding MarketplaceHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ItemsControl ItemsSource="{Binding MarketPlugins}">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:PluginMarketItemViewModel">
|
||||
<Border Classes="settings-list-item">
|
||||
<Grid Classes="settings-list-actions"
|
||||
ColumnDefinitions="*,Auto">
|
||||
<ui:SettingsExpander>
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="ShoppingBag" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Header>
|
||||
<StackPanel>
|
||||
<TextBlock FontWeight="SemiBold"
|
||||
Text="{Binding Name}" />
|
||||
<TextBlock Opacity="0.76"
|
||||
FontSize="12"
|
||||
Text="{Binding Description}" />
|
||||
<TextBlock Opacity="0.58"
|
||||
FontSize="11"
|
||||
Text="{Binding Version}" />
|
||||
<TextBlock FontWeight="SemiBold" Text="{Binding Name}" />
|
||||
<TextBlock Opacity="0.76" FontSize="12" Text="{Binding Description}" />
|
||||
</StackPanel>
|
||||
<Button Grid.Column="1"
|
||||
Command="{Binding #Root.DataContext.InstallPluginCommand}"
|
||||
</ui:SettingsExpander.Header>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<Button Command="{Binding #Root.DataContext.InstallPluginCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="{Binding #Root.DataContext.InstallButtonText}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
||||
xmlns:controls="using:LanMountainDesktop.Controls"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||
x:Class="LanMountainDesktop.Views.SettingsPages.WallpaperSettingsPage"
|
||||
x:DataType="vm:WallpaperSettingsPageViewModel">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Classes="settings-page-container">
|
||||
|
||||
<controls:IconText Icon="Image"
|
||||
Text="{Binding WallpaperHeader}"
|
||||
Margin="0,0,0,4" />
|
||||
|
||||
<ui:SettingsExpander Header="{Binding WallpaperPathLabel}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Image" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||
<TextBox IsReadOnly="True"
|
||||
MinWidth="200"
|
||||
Text="{Binding WallpaperPath}" />
|
||||
<Button Click="OnBrowseWallpaperClick"
|
||||
Content="{Binding ImportWallpaperButtonText}" />
|
||||
</StackPanel>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
<ui:SettingsExpander Header="{Binding WallpaperPlacementLabel}"
|
||||
Description="{Binding WallpaperPlacementDescription}">
|
||||
<ui:SettingsExpander.IconSource>
|
||||
<fi:SymbolIconSource Symbol="Maximize" />
|
||||
</ui:SettingsExpander.IconSource>
|
||||
<ui:SettingsExpander.Footer>
|
||||
<ComboBox MinWidth="160"
|
||||
ItemsSource="{Binding WallpaperPlacements}"
|
||||
SelectedItem="{Binding SelectedWallpaperPlacement}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="vm:SelectionOption">
|
||||
<TextBlock Text="{Binding Label}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
</ui:SettingsExpander.Footer>
|
||||
</ui:SettingsExpander>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,54 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Platform.Storage;
|
||||
using LanMountainDesktop.PluginSdk;
|
||||
using LanMountainDesktop.Services.Settings;
|
||||
using LanMountainDesktop.ViewModels;
|
||||
using System.Linq;
|
||||
|
||||
namespace LanMountainDesktop.Views.SettingsPages;
|
||||
|
||||
[SettingsPageInfo(
|
||||
"wallpaper",
|
||||
"Wallpaper",
|
||||
SettingsPageCategory.Appearance,
|
||||
IconKey = "Image",
|
||||
SortOrder = 15,
|
||||
TitleLocalizationKey = "settings.wallpaper.title",
|
||||
DescriptionLocalizationKey = "settings.wallpaper.description")]
|
||||
public partial class WallpaperSettingsPage : SettingsPageBase
|
||||
{
|
||||
public WallpaperSettingsPage()
|
||||
: this(new WallpaperSettingsPageViewModel(HostSettingsFacadeProvider.GetOrCreate()))
|
||||
{
|
||||
}
|
||||
|
||||
public WallpaperSettingsPage(WallpaperSettingsPageViewModel viewModel)
|
||||
{
|
||||
ViewModel = viewModel;
|
||||
DataContext = ViewModel;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WallpaperSettingsPageViewModel ViewModel { get; }
|
||||
|
||||
private async void OnBrowseWallpaperClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (TopLevel.GetTopLevel(this)?.StorageProvider is not { } storageProvider)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var files = await storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = ViewModel.FilePickerTitle,
|
||||
AllowMultiple = false
|
||||
});
|
||||
|
||||
var file = files.FirstOrDefault();
|
||||
var localPath = file?.TryGetLocalPath();
|
||||
if (!string.IsNullOrWhiteSpace(localPath))
|
||||
{
|
||||
await ViewModel.ImportWallpaperAsync(localPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
x:DataType="vm:SettingsWindowViewModel"
|
||||
Width="1120"
|
||||
Height="760"
|
||||
MinWidth="920"
|
||||
MinHeight="620"
|
||||
MinWidth="560"
|
||||
MinHeight="480"
|
||||
CanResize="True"
|
||||
WindowStartupLocation="Manual"
|
||||
SystemDecorations="BorderOnly"
|
||||
@@ -17,7 +17,29 @@
|
||||
Icon="/Assets/avalonia-logo.ico"
|
||||
Title="{Binding Title}">
|
||||
|
||||
<Grid Background="{DynamicResource AdaptiveSurfaceBaseBrush}"
|
||||
<Window.Resources>
|
||||
<x:Double x:Key="SettingsPageContentWidth">920</x:Double>
|
||||
</Window.Resources>
|
||||
|
||||
<Window.Styles>
|
||||
<Style Selector="Grid.page-title-container">
|
||||
<Setter Property="Margin" Value="0,16,0,0" />
|
||||
<Setter Property="Width" Value="{DynamicResource SettingsPageContentWidth}" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBlock.page-title-text">
|
||||
<Setter Property="FontSize" Value="28" />
|
||||
<Setter Property="FontWeight" Value="Normal" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBlock.page-title-text:narrow">
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
|
||||
<Grid Classes="settings-scope"
|
||||
Background="{DynamicResource AdaptiveSurfaceBaseBrush}"
|
||||
RowDefinitions="Auto,Auto,*">
|
||||
<Border x:Name="WindowTitleBarHost"
|
||||
Height="48"
|
||||
@@ -121,10 +143,24 @@
|
||||
<SolidColorBrush x:Key="NavigationViewContentGridBorderBrush" Color="Transparent" />
|
||||
</ui:NavigationView.Resources>
|
||||
|
||||
<Grid ColumnDefinitions="*,Auto"
|
||||
<Grid x:Name="SettingsContentGrid"
|
||||
ColumnDefinitions="*,Auto"
|
||||
ColumnSpacing="20"
|
||||
Margin="12,0,16,16">
|
||||
<ui:Frame x:Name="ContentFrame" />
|
||||
<Grid Grid.Column="0"
|
||||
RowDefinitions="Auto,*">
|
||||
<Grid x:Name="PageTitleContainer"
|
||||
Grid.Row="0"
|
||||
Classes="page-title-container"
|
||||
IsVisible="{Binding IsPageTitleVisible}">
|
||||
<TextBlock x:Name="PageTitleTextBlock"
|
||||
Classes="page-title-text"
|
||||
Text="{Binding CurrentPageTitle}" />
|
||||
</Grid>
|
||||
|
||||
<ui:Frame x:Name="ContentFrame"
|
||||
Grid.Row="1" />
|
||||
</Grid>
|
||||
|
||||
<Border x:Name="DrawerBorder"
|
||||
Grid.Column="1"
|
||||
|
||||
@@ -6,6 +6,7 @@ using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Threading;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using LanMountainDesktop.PluginSdk;
|
||||
using LanMountainDesktop.Services;
|
||||
@@ -17,10 +18,17 @@ namespace LanMountainDesktop.Views;
|
||||
|
||||
public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
{
|
||||
private const double BaseSettingsContentWidth = 960d;
|
||||
private const double MinSettingsContentWidth = 320d;
|
||||
private const double MaxSettingsContentWidth = 1280d;
|
||||
private const double BaseDrawerWidth = 296d;
|
||||
private const double BaseNarrowThreshold = 800d;
|
||||
|
||||
private readonly ISettingsPageRegistry _pageRegistry;
|
||||
private readonly IHostApplicationLifecycle _hostApplicationLifecycle;
|
||||
private readonly Dictionary<string, Control> _cachedPages = new(StringComparer.OrdinalIgnoreCase);
|
||||
private readonly bool _useSystemChrome;
|
||||
private bool _isResponsiveLayoutRefreshPending;
|
||||
|
||||
public SettingsWindow()
|
||||
: this(
|
||||
@@ -44,6 +52,11 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
InitializeComponent();
|
||||
ApplyChromeMode(useSystemChrome);
|
||||
|
||||
if (RootNavigationView is not null)
|
||||
{
|
||||
RootNavigationView.PropertyChanged += OnRootNavigationViewPropertyChanged;
|
||||
}
|
||||
|
||||
Opened += OnOpened;
|
||||
SizeChanged += OnWindowSizeChanged;
|
||||
Closed += OnClosed;
|
||||
@@ -59,6 +72,8 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
SyncTitleText();
|
||||
UpdateChromeMetrics();
|
||||
UpdatePaneToggleIcon();
|
||||
UpdateResponsiveLayout();
|
||||
RequestResponsiveLayoutRefresh();
|
||||
}
|
||||
|
||||
public void ReloadPages(string? pageId)
|
||||
@@ -86,6 +101,8 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
ViewModel.DrawerTitle = title ?? ViewModel.DrawerFallbackTitle;
|
||||
ViewModel.IsDrawerOpen = true;
|
||||
SyncTitleText();
|
||||
UpdateResponsiveLayout();
|
||||
RequestResponsiveLayoutRefresh();
|
||||
}
|
||||
|
||||
public void CloseDrawer()
|
||||
@@ -98,6 +115,8 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
ViewModel.IsDrawerOpen = false;
|
||||
ViewModel.DrawerTitle = null;
|
||||
SyncTitleText();
|
||||
UpdateResponsiveLayout();
|
||||
RequestResponsiveLayoutRefresh();
|
||||
}
|
||||
|
||||
public void RequestRestart(string? reason = null)
|
||||
@@ -285,6 +304,8 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
_ = sender;
|
||||
_ = e;
|
||||
UpdateChromeMetrics();
|
||||
UpdateResponsiveLayout();
|
||||
RequestResponsiveLayoutRefresh();
|
||||
}
|
||||
|
||||
private void OnWindowSizeChanged(object? sender, SizeChangedEventArgs e)
|
||||
@@ -292,12 +313,139 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
_ = sender;
|
||||
_ = e;
|
||||
UpdateChromeMetrics();
|
||||
UpdateResponsiveLayout();
|
||||
RequestResponsiveLayoutRefresh();
|
||||
}
|
||||
|
||||
private bool TryApplyResponsiveLayout()
|
||||
{
|
||||
if (SettingsContentGrid is null || DrawerBorder is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var width = Bounds.Width > 1 ? Bounds.Width : Math.Max(Width, MinWidth);
|
||||
var renderScale = RenderScaling > 0 ? RenderScaling : 1d;
|
||||
var titleScale = WindowTitleTextBlock?.FontSize > 0
|
||||
? WindowTitleTextBlock.FontSize / 12d
|
||||
: 1d;
|
||||
var pageTitleScale = PageTitleTextBlock?.FontSize > 0
|
||||
? PageTitleTextBlock.FontSize / 28d
|
||||
: 1d;
|
||||
var typographyScale = Math.Max(titleScale, pageTitleScale);
|
||||
var contentScale = Math.Clamp(
|
||||
1d + ((renderScale - 1d) * 0.7d) + ((typographyScale - 1d) * 0.45d),
|
||||
1d,
|
||||
1.45d);
|
||||
|
||||
var horizontalMargin = Math.Clamp(16d * renderScale, 12d, 32d);
|
||||
var topMargin = Math.Clamp(2d * renderScale, 0d, 8d);
|
||||
var bottomMargin = Math.Clamp(16d * renderScale, 12d, 28d);
|
||||
var columnSpacing = Math.Clamp(20d * renderScale, 12d, 28d);
|
||||
var drawerWidth = Math.Clamp(BaseDrawerWidth * contentScale, 276d, 380d);
|
||||
var compactPaneWidth = Math.Clamp(48d * renderScale, 40d, 60d);
|
||||
var narrowThreshold = Math.Clamp(BaseNarrowThreshold * renderScale, 760d, 980d);
|
||||
var isNarrow = width < narrowThreshold;
|
||||
var paneReservedWidth = GetReservedPaneWidth(compactPaneWidth, isNarrow);
|
||||
|
||||
SettingsContentGrid.Margin = new Thickness(horizontalMargin, topMargin, horizontalMargin, bottomMargin);
|
||||
DrawerBorder.Width = drawerWidth;
|
||||
|
||||
if (isNarrow)
|
||||
{
|
||||
SettingsContentGrid.ColumnDefinitions = new ColumnDefinitions("*");
|
||||
SettingsContentGrid.ColumnSpacing = 0;
|
||||
if (DrawerBorder.IsVisible)
|
||||
{
|
||||
ViewModel.IsDrawerOpen = false;
|
||||
}
|
||||
|
||||
DrawerBorder.IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsContentGrid.ColumnDefinitions = new ColumnDefinitions("*,Auto");
|
||||
SettingsContentGrid.ColumnSpacing = columnSpacing;
|
||||
}
|
||||
|
||||
var contentHostWidth = ContentFrame?.Bounds.Width > 1
|
||||
? ContentFrame.Bounds.Width
|
||||
: 0d;
|
||||
if (contentHostWidth <= 1)
|
||||
{
|
||||
var rootContentWidth = RootNavigationView?.Bounds.Width > 1
|
||||
? RootNavigationView.Bounds.Width - paneReservedWidth
|
||||
: SettingsContentGrid.Bounds.Width;
|
||||
contentHostWidth = rootContentWidth - (isNarrow ? 0d : drawerWidth + SettingsContentGrid.ColumnSpacing);
|
||||
}
|
||||
|
||||
contentHostWidth = Math.Max(MinSettingsContentWidth, contentHostWidth);
|
||||
|
||||
var edgePadding = Math.Clamp(24d * renderScale, 14d, 40d);
|
||||
var preferredContentWidth = Math.Clamp(BaseSettingsContentWidth * contentScale, 820d, MaxSettingsContentWidth);
|
||||
var availableContentWidth = Math.Max(MinSettingsContentWidth, contentHostWidth - edgePadding * 2d);
|
||||
var resolvedContentWidth = availableContentWidth > preferredContentWidth
|
||||
? preferredContentWidth
|
||||
: availableContentWidth;
|
||||
|
||||
Resources["SettingsPageContentWidth"] = resolvedContentWidth;
|
||||
|
||||
if (PageTitleContainer is not null)
|
||||
{
|
||||
PageTitleContainer.Width = resolvedContentWidth;
|
||||
PageTitleContainer.HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center;
|
||||
}
|
||||
|
||||
if (PageTitleTextBlock is not null)
|
||||
{
|
||||
var narrowTitleThreshold = Math.Clamp(760d * renderScale, 700d, 860d);
|
||||
PageTitleTextBlock.Classes.Set("narrow", resolvedContentWidth < narrowTitleThreshold);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateResponsiveLayout()
|
||||
{
|
||||
_ = TryApplyResponsiveLayout();
|
||||
return;
|
||||
|
||||
if (SettingsContentGrid is null || DrawerBorder is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var width = Bounds.Width;
|
||||
const double narrowThreshold = 800;
|
||||
|
||||
var isNarrow = width < narrowThreshold;
|
||||
|
||||
// 小窗口时隐藏抽屉面板
|
||||
if (isNarrow)
|
||||
{
|
||||
SettingsContentGrid.ColumnDefinitions = new ColumnDefinitions("*");
|
||||
SettingsContentGrid.ColumnSpacing = 0;
|
||||
if (DrawerBorder.IsVisible)
|
||||
{
|
||||
ViewModel.IsDrawerOpen = false;
|
||||
}
|
||||
DrawerBorder.IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingsContentGrid.ColumnDefinitions = new ColumnDefinitions("*,Auto");
|
||||
SettingsContentGrid.ColumnSpacing = 20;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClosed(object? sender, EventArgs e)
|
||||
{
|
||||
_cachedPages.Clear();
|
||||
PendingRestartStateService.StateChanged -= OnPendingRestartStateChanged;
|
||||
if (RootNavigationView is not null)
|
||||
{
|
||||
RootNavigationView.PropertyChanged -= OnRootNavigationViewPropertyChanged;
|
||||
}
|
||||
Opened -= OnOpened;
|
||||
SizeChanged -= OnWindowSizeChanged;
|
||||
}
|
||||
@@ -322,6 +470,8 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
|
||||
RootNavigationView.IsPaneOpen = !RootNavigationView.IsPaneOpen;
|
||||
UpdatePaneToggleIcon();
|
||||
UpdateResponsiveLayout();
|
||||
RequestResponsiveLayoutRefresh();
|
||||
}
|
||||
|
||||
private void OnCloseWindowClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
@@ -331,6 +481,46 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
Close();
|
||||
}
|
||||
|
||||
private void OnRootNavigationViewPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
_ = sender;
|
||||
|
||||
if (e.Property == NavigationView.IsPaneOpenProperty ||
|
||||
e.Property == NavigationView.OpenPaneLengthProperty ||
|
||||
e.Property == NavigationView.PaneDisplayModeProperty)
|
||||
{
|
||||
UpdatePaneToggleIcon();
|
||||
RequestResponsiveLayoutRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void RequestResponsiveLayoutRefresh()
|
||||
{
|
||||
if (_isResponsiveLayoutRefreshPending)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_isResponsiveLayoutRefreshPending = true;
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
_isResponsiveLayoutRefreshPending = false;
|
||||
UpdateResponsiveLayout();
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private double GetReservedPaneWidth(double compactPaneWidth, bool isNarrow)
|
||||
{
|
||||
if (RootNavigationView is null || isNarrow)
|
||||
{
|
||||
return 0d;
|
||||
}
|
||||
|
||||
return RootNavigationView.IsPaneOpen
|
||||
? RootNavigationView.OpenPaneLength
|
||||
: compactPaneWidth;
|
||||
}
|
||||
|
||||
private void UpdatePaneToggleIcon()
|
||||
{
|
||||
if (TogglePaneButtonIcon is null || RootNavigationView is null)
|
||||
@@ -457,6 +647,7 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
return iconKey?.Trim() switch
|
||||
{
|
||||
"DesignIdeas" => Symbol.Color,
|
||||
"Image" => Symbol.Image,
|
||||
"GridDots" => Symbol.GridDots,
|
||||
"PuzzlePiece" => Symbol.PuzzlePiece,
|
||||
"Info" => Symbol.Info,
|
||||
|
||||
Reference in New Issue
Block a user