mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
feat.试验性地改了一下融合桌面的组件库,反正还是不能用。
This commit is contained in:
@@ -698,6 +698,7 @@
|
|||||||
"component.editor.placement_label": "Placement ID",
|
"component.editor.placement_label": "Placement ID",
|
||||||
"component.editor.scope_label": "Scope",
|
"component.editor.scope_label": "Scope",
|
||||||
"component.editor.scope_instance": "Instance-scoped editor",
|
"component.editor.scope_instance": "Instance-scoped editor",
|
||||||
|
"component_category.all": "All",
|
||||||
"component_category.clock": "Clock",
|
"component_category.clock": "Clock",
|
||||||
"component_category.date": "Calendar",
|
"component_category.date": "Calendar",
|
||||||
"component_category.weather": "Weather",
|
"component_category.weather": "Weather",
|
||||||
|
|||||||
@@ -692,6 +692,7 @@
|
|||||||
"component.editor.placement_label": "实例 ID",
|
"component.editor.placement_label": "实例 ID",
|
||||||
"component.editor.scope_label": "作用域",
|
"component.editor.scope_label": "作用域",
|
||||||
"component.editor.scope_instance": "实例级编辑器",
|
"component.editor.scope_instance": "实例级编辑器",
|
||||||
|
"component_category.all": "全部",
|
||||||
"component_category.clock": "时钟",
|
"component_category.clock": "时钟",
|
||||||
"component_category.date": "日历",
|
"component_category.date": "日历",
|
||||||
"component_category.weather": "天气",
|
"component_category.weather": "天气",
|
||||||
|
|||||||
@@ -1,116 +1,138 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
xmlns:vm="using:LanMountainDesktop.ViewModels"
|
||||||
xmlns:fi="using:FluentIcons.Avalonia"
|
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||||
|
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||||
xmlns:converters="using:Avalonia.Data.Converters"
|
xmlns:converters="using:Avalonia.Data.Converters"
|
||||||
x:Class="LanMountainDesktop.Views.FusedDesktopComponentLibraryControl"
|
x:Class="LanMountainDesktop.Views.FusedDesktopComponentLibraryControl"
|
||||||
x:DataType="vm:ComponentLibraryWindowViewModel">
|
x:DataType="vm:ComponentLibraryWindowViewModel">
|
||||||
|
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
<!-- 分类列表项样式 -->
|
<!-- 分类列表项样式 - 遵循 Fluent NavigationView 风格 -->
|
||||||
<Style Selector="ListBoxItem.category-item">
|
<Style Selector="ListBoxItem.category-item">
|
||||||
<Setter Property="Padding" Value="0"/>
|
<Setter Property="Padding" Value="0"/>
|
||||||
<Setter Property="Margin" Value="0,0,0,4"/>
|
<Setter Property="Margin" Value="0,2"/>
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
|
<Setter Property="CornerRadius" Value="{DynamicResource DesignCornerRadiusSm}"/>
|
||||||
|
<Setter Property="Transitions">
|
||||||
|
<Transitions>
|
||||||
|
<BrushTransition Property="Background" Duration="0:0:0.083" Easing="0.05,0.75,0.10,1.00"/>
|
||||||
|
</Transitions>
|
||||||
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ListBoxItem.category-item:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
<Style Selector="ListBoxItem.category-item:pointerover /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="{DynamicResource SubtleFillColorSecondaryBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ListBoxItem.category-item:selected /template/ ContentPresenter#PART_ContentPresenter">
|
<Style Selector="ListBoxItem.category-item:selected /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="{DynamicResource AdaptiveNavItemSelectedBackgroundBrush}"/>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ListBoxItem.category-item:pressed /template/ ContentPresenter#PART_ContentPresenter">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource SubtleFillColorTertiaryBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<!-- 分类项内容容器 - 默认状态 -->
|
<!-- 分类项图标和文字 -->
|
||||||
<Style Selector="Border.category-content">
|
<Style Selector="ListBoxItem.category-item fi|FluentIcon.category-icon">
|
||||||
<Setter Property="Background" Value="{DynamicResource AdaptiveNavItemBackgroundBrush}"/>
|
|
||||||
<Setter Property="Padding" Value="12,10"/>
|
|
||||||
<Setter Property="CornerRadius" Value="{DynamicResource DesignCornerRadiusMd}"/>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem.category-item:selected Border.category-content">
|
|
||||||
<Setter Property="Background" Value="{DynamicResource AdaptiveAccentBrush}"/>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="ListBoxItem.category-item:pointerover Border.category-content">
|
|
||||||
<Setter Property="Opacity" Value="0.9"/>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- 分类项图标和文字 - 默认状态 -->
|
|
||||||
<Style Selector="ListBoxItem.category-item fi|SymbolIcon.category-icon">
|
|
||||||
<Setter Property="Foreground" Value="{DynamicResource AdaptiveTextPrimaryBrush}"/>
|
<Setter Property="Foreground" Value="{DynamicResource AdaptiveTextPrimaryBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ListBoxItem.category-item:selected fi|SymbolIcon.category-icon">
|
<Style Selector="ListBoxItem.category-item:selected fi|FluentIcon.category-icon">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource AdaptiveOnAccentBrush}"/>
|
<Setter Property="Foreground" Value="{DynamicResource AdaptiveTextPrimaryBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="ListBoxItem.category-item TextBlock.category-text">
|
<Style Selector="ListBoxItem.category-item TextBlock.category-text">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource AdaptiveTextPrimaryBrush}"/>
|
<Setter Property="Foreground" Value="{DynamicResource AdaptiveTextPrimaryBrush}"/>
|
||||||
</Style>
|
</Style>
|
||||||
<Style Selector="ListBoxItem.category-item:selected TextBlock.category-text">
|
<Style Selector="ListBoxItem.category-item:selected TextBlock.category-text">
|
||||||
<Setter Property="Foreground" Value="{DynamicResource AdaptiveOnAccentBrush}"/>
|
<Setter Property="Foreground" Value="{DynamicResource AdaptiveTextPrimaryBrush}"/>
|
||||||
|
<Setter Property="FontWeight" Value="SemiBold"/>
|
||||||
</Style>
|
</Style>
|
||||||
</UserControl.Styles>
|
</UserControl.Styles>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="280,*"
|
<Grid ColumnDefinitions="Auto,*"
|
||||||
ColumnSpacing="16"
|
ColumnSpacing="0"
|
||||||
Margin="0">
|
Margin="0">
|
||||||
<!-- 分类列表 (左侧) -->
|
<!-- 左侧导航列 - 分类列表 + 底部"查找更多组件" -->
|
||||||
<Border Classes="surface-translucent-panel"
|
<Border Width="280"
|
||||||
CornerRadius="{DynamicResource DesignCornerRadiusLg}"
|
Background="Transparent">
|
||||||
Padding="12">
|
<Grid RowDefinitions="*,Auto">
|
||||||
<ListBox x:Name="CategoryListBox"
|
<!-- 分类列表 -->
|
||||||
Background="Transparent"
|
<ListBox x:Name="CategoryListBox"
|
||||||
BorderThickness="0"
|
Grid.Row="0"
|
||||||
SelectionChanged="OnCategorySelectionChanged"
|
Background="Transparent"
|
||||||
ItemsSource="{Binding Categories}">
|
BorderThickness="0"
|
||||||
<ListBox.ItemTemplate>
|
Margin="8,8,4,0"
|
||||||
<DataTemplate x:DataType="vm:ComponentLibraryCategoryViewModel">
|
SelectionChanged="OnCategorySelectionChanged"
|
||||||
<Border Classes="category-content">
|
ItemsSource="{Binding Categories}">
|
||||||
|
<ListBox.ItemTemplate>
|
||||||
|
<DataTemplate x:DataType="vm:ComponentLibraryCategoryViewModel">
|
||||||
<Grid ColumnDefinitions="Auto,*"
|
<Grid ColumnDefinitions="Auto,*"
|
||||||
ColumnSpacing="12">
|
ColumnSpacing="12"
|
||||||
<fi:SymbolIcon Symbol="{Binding Icon}"
|
Margin="12,10">
|
||||||
|
<fi:FluentIcon Icon="{Binding Icon}"
|
||||||
IconVariant="Regular"
|
IconVariant="Regular"
|
||||||
FontSize="20"
|
FontSize="18"
|
||||||
Classes="category-icon"/>
|
Classes="category-icon"/>
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontSize="14"
|
FontSize="14"
|
||||||
FontWeight="SemiBold"
|
|
||||||
Classes="category-text"
|
Classes="category-text"
|
||||||
Text="{Binding Title}"/>
|
Text="{Binding Title}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</DataTemplate>
|
||||||
</DataTemplate>
|
</ListBox.ItemTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox>
|
||||||
</ListBox>
|
|
||||||
|
<!-- 底部"查找更多组件" - 在左侧导航列底部 -->
|
||||||
|
<StackPanel Grid.Row="1"
|
||||||
|
Margin="12,8,8,12">
|
||||||
|
<Border Height="1"
|
||||||
|
Background="{DynamicResource AdaptiveGlassPanelBorderBrush}"
|
||||||
|
Opacity="0.4"
|
||||||
|
Margin="0,0,0,8"/>
|
||||||
|
<Button Classes="hyperlink"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Click="OnFindMoreComponentsClick">
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="6">
|
||||||
|
<fi:FluentIcon Icon="Globe" IconVariant="Regular" FontSize="14"/>
|
||||||
|
<TextBlock Text="查找更多组件"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- 组件预览区 (右侧) -->
|
<!-- 右侧内容区与左侧的分隔线 -->
|
||||||
<Border Grid.Column="1"
|
<Border Grid.Column="1"
|
||||||
Classes="surface-translucent-strong"
|
Width="1"
|
||||||
CornerRadius="{DynamicResource DesignCornerRadiusLg}"
|
HorizontalAlignment="Left"
|
||||||
Padding="24">
|
Background="{DynamicResource AdaptiveGlassPanelBorderBrush}"
|
||||||
<Panel>
|
Opacity="0.5"/>
|
||||||
|
|
||||||
|
<!-- 组件预览区 (右侧) -->
|
||||||
|
<ScrollViewer Grid.Column="1"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Disabled">
|
||||||
|
<StackPanel Margin="24,16,20,16"
|
||||||
|
Spacing="0">
|
||||||
|
|
||||||
<!-- 有选中组件时的显示 -->
|
<!-- 有选中组件时的显示 -->
|
||||||
<Grid RowDefinitions="Auto,*,Auto"
|
<Panel IsVisible="{Binding SelectedComponent, Converter={x:Static converters:ObjectConverters.IsNotNull}}">
|
||||||
IsVisible="{Binding SelectedComponent, Converter={x:Static converters:ObjectConverters.IsNotNull}}">
|
|
||||||
<!-- 组件标题 -->
|
<!-- 组件标题 - 在右侧内容区顶部 -->
|
||||||
<TextBlock Grid.Row="0"
|
<TextBlock FontSize="28"
|
||||||
FontSize="28"
|
FontWeight="SemiBold"
|
||||||
FontWeight="Bold"
|
|
||||||
Foreground="{DynamicResource AdaptiveTextPrimaryBrush}"
|
Foreground="{DynamicResource AdaptiveTextPrimaryBrush}"
|
||||||
Text="{Binding SelectedComponent.DisplayName}"
|
Text="{Binding SelectedComponent.DisplayName}"
|
||||||
Margin="0,0,0,20"/>
|
Margin="0,0,0,16"/>
|
||||||
|
|
||||||
<!-- 预览区域 -->
|
<!-- 固定大小的预览卡片 - 与窗口背景有色差 -->
|
||||||
<Border Grid.Row="1"
|
<Border CornerRadius="{DynamicResource DesignCornerRadiusSm}"
|
||||||
CornerRadius="{DynamicResource DesignCornerRadiusComponent}"
|
Background="{DynamicResource AdaptiveSurfaceRaisedBrush}"
|
||||||
Background="{DynamicResource AdaptiveSurfaceBaseBrush}"
|
|
||||||
BorderBrush="{DynamicResource AdaptiveGlassPanelBorderBrush}"
|
BorderBrush="{DynamicResource AdaptiveGlassPanelBorderBrush}"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
Padding="20"
|
Width="420"
|
||||||
HorizontalAlignment="Center"
|
Height="320"
|
||||||
VerticalAlignment="Center">
|
HorizontalAlignment="Center">
|
||||||
<Grid Width="400"
|
<Grid Margin="16">
|
||||||
Height="300">
|
|
||||||
<!-- 预览图片 -->
|
<!-- 预览图片 -->
|
||||||
<Image Source="{Binding SelectedComponent.PreviewBitmap}"
|
<Image Source="{Binding SelectedComponent.PreviewBitmap}"
|
||||||
Stretch="Uniform"
|
Stretch="Uniform"
|
||||||
@@ -141,7 +163,8 @@
|
|||||||
<StackPanel HorizontalAlignment="Center"
|
<StackPanel HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Spacing="8">
|
Spacing="8">
|
||||||
<fi:SymbolIcon Symbol="ImageOff"
|
<fi:FluentIcon Icon="ImageOff"
|
||||||
|
IconVariant="Regular"
|
||||||
FontSize="48"
|
FontSize="48"
|
||||||
Opacity="0.5"
|
Opacity="0.5"
|
||||||
Foreground="{DynamicResource AdaptiveTextSecondaryBrush}"/>
|
Foreground="{DynamicResource AdaptiveTextSecondaryBrush}"/>
|
||||||
@@ -161,34 +184,29 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- 底部操作区 -->
|
<!-- "添加小组件"按钮 - 在预览卡片正下方居中,使用主题强调色 -->
|
||||||
<Grid Grid.Row="2"
|
<Button HorizontalAlignment="Center"
|
||||||
ColumnDefinitions="*,Auto"
|
Classes="accent"
|
||||||
Margin="0,24,0,0">
|
Padding="24,10"
|
||||||
<TextBlock Grid.Column="0"
|
Margin="0,16,0,0"
|
||||||
VerticalAlignment="Center"
|
Tag="{Binding SelectedComponent.ComponentId}"
|
||||||
FontSize="14"
|
Click="OnAddComponentClick">
|
||||||
Foreground="{DynamicResource AdaptiveTextSecondaryBrush}"
|
<StackPanel Orientation="Horizontal" Spacing="8">
|
||||||
Text="{Binding SelectedComponent.ComponentId, StringFormat='组件 ID: {0}'}"/>
|
<fi:FluentIcon Icon="Add" IconVariant="Regular" FontSize="16"/>
|
||||||
<Button Grid.Column="1"
|
<TextBlock Text="添加小组件" FontWeight="SemiBold"/>
|
||||||
Classes="accent"
|
</StackPanel>
|
||||||
Padding="20,12"
|
</Button>
|
||||||
Tag="{Binding SelectedComponent.ComponentId}"
|
</Panel>
|
||||||
Click="OnAddComponentClick">
|
|
||||||
<StackPanel Orientation="Horizontal" Spacing="8">
|
|
||||||
<fi:SymbolIcon Symbol="Add" FontSize="16"/>
|
|
||||||
<TextBlock Text="添加到桌面" FontWeight="SemiBold"/>
|
|
||||||
</StackPanel>
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<!-- 空状态 -->
|
<!-- 空状态 -->
|
||||||
<Grid IsVisible="{Binding SelectedComponent, Converter={x:Static converters:ObjectConverters.IsNull}}"
|
<Grid IsVisible="{Binding SelectedComponent, Converter={x:Static converters:ObjectConverters.IsNull}}"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center"
|
||||||
<StackPanel Spacing="16" HorizontalAlignment="Center">
|
MinHeight="400">
|
||||||
<fi:SymbolIcon Symbol="Apps"
|
<StackPanel Spacing="16" HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<fi:FluentIcon Icon="Apps"
|
||||||
|
IconVariant="Regular"
|
||||||
FontSize="64"
|
FontSize="64"
|
||||||
Opacity="0.3"
|
Opacity="0.3"
|
||||||
Foreground="{DynamicResource AdaptiveTextSecondaryBrush}"/>
|
Foreground="{DynamicResource AdaptiveTextSecondaryBrush}"/>
|
||||||
@@ -198,7 +216,7 @@
|
|||||||
Text="请从左侧选择一个组件"/>
|
Text="请从左侧选择一个组件"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Panel>
|
</StackPanel>
|
||||||
</Border>
|
</ScrollViewer>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.VisualTree;
|
||||||
using FluentIcons.Common;
|
using FluentIcons.Common;
|
||||||
using LanMountainDesktop.ComponentSystem;
|
using LanMountainDesktop.ComponentSystem;
|
||||||
using LanMountainDesktop.Services;
|
using LanMountainDesktop.Services;
|
||||||
@@ -29,6 +30,8 @@ public partial class FusedDesktopComponentLibraryControl : UserControl
|
|||||||
private readonly IRecommendationInfoService _recommendationInfoService = new RecommendationDataService();
|
private readonly IRecommendationInfoService _recommendationInfoService = new RecommendationDataService();
|
||||||
private readonly ICalculatorDataService _calculatorDataService = new CalculatorDataService();
|
private readonly ICalculatorDataService _calculatorDataService = new CalculatorDataService();
|
||||||
|
|
||||||
|
private static readonly LocalizationService _localizationService = new();
|
||||||
|
|
||||||
public FusedDesktopComponentLibraryControl()
|
public FusedDesktopComponentLibraryControl()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -76,26 +79,15 @@ public partial class FusedDesktopComponentLibraryControl : UserControl
|
|||||||
{
|
{
|
||||||
_viewModel.Categories.Clear();
|
_viewModel.Categories.Clear();
|
||||||
|
|
||||||
|
var languageCode = _settingsFacade.Region.Get().LanguageCode;
|
||||||
|
|
||||||
// 添加"全部组件"分类
|
// 添加"全部组件"分类
|
||||||
_viewModel.Categories.Add(new ComponentLibraryCategoryViewModel(
|
_viewModel.Categories.Add(new ComponentLibraryCategoryViewModel(
|
||||||
"all",
|
"all",
|
||||||
"全部组件",
|
L(languageCode, "component_category.all", "All"),
|
||||||
Symbol.Apps,
|
Symbol.Apps,
|
||||||
Array.Empty<ComponentLibraryItemViewModel>()));
|
Array.Empty<ComponentLibraryItemViewModel>()));
|
||||||
|
|
||||||
var categoryMap = new Dictionary<string, (string Display, Symbol Icon)>
|
|
||||||
{
|
|
||||||
{ "clock", ("时钟", Symbol.Clock) },
|
|
||||||
{ "date", ("日历", Symbol.CalendarDate) },
|
|
||||||
{ "weather", ("天气", Symbol.WeatherSunny) },
|
|
||||||
{ "board", ("画板", Symbol.Edit) },
|
|
||||||
{ "media", ("媒体", Symbol.Play) },
|
|
||||||
{ "info", ("资讯", Symbol.News) },
|
|
||||||
{ "calculator", ("工具", Symbol.Calculator) },
|
|
||||||
{ "study", ("学习", Symbol.Hourglass) },
|
|
||||||
{ "file", ("文件", Symbol.Folder) }
|
|
||||||
};
|
|
||||||
|
|
||||||
var usedCategories = _allDefinitions
|
var usedCategories = _allDefinitions
|
||||||
.Select(d => d.Category)
|
.Select(d => d.Category)
|
||||||
.Distinct()
|
.Distinct()
|
||||||
@@ -103,23 +95,62 @@ public partial class FusedDesktopComponentLibraryControl : UserControl
|
|||||||
|
|
||||||
foreach (var cat in usedCategories)
|
foreach (var cat in usedCategories)
|
||||||
{
|
{
|
||||||
if (categoryMap.TryGetValue(cat.ToLower(), out var info))
|
var icon = ResolveCategoryIcon(cat);
|
||||||
{
|
var title = GetLocalizedCategoryTitle(languageCode, cat);
|
||||||
var categoryComponents = _allDefinitions
|
|
||||||
.Where(d => string.Equals(d.Category, cat, StringComparison.OrdinalIgnoreCase))
|
|
||||||
.OrderBy(d => d.DisplayName)
|
|
||||||
.Select(d => CreateComponentItem(d))
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
_viewModel.Categories.Add(new ComponentLibraryCategoryViewModel(
|
var categoryComponents = _allDefinitions
|
||||||
cat,
|
.Where(d => string.Equals(d.Category, cat, StringComparison.OrdinalIgnoreCase))
|
||||||
info.Display,
|
.OrderBy(d => d.DisplayName)
|
||||||
info.Icon,
|
.Select(d => CreateComponentItem(d))
|
||||||
categoryComponents));
|
.ToArray();
|
||||||
}
|
|
||||||
|
_viewModel.Categories.Add(new ComponentLibraryCategoryViewModel(
|
||||||
|
cat,
|
||||||
|
title,
|
||||||
|
icon,
|
||||||
|
categoryComponents));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分类图标映射 - 与阑山桌面 Dock 栏组件库 (MainWindow.ComponentSystem) 保持一致
|
||||||
|
/// </summary>
|
||||||
|
private static Symbol ResolveCategoryIcon(string categoryId)
|
||||||
|
{
|
||||||
|
if (string.Equals(categoryId, "Clock", StringComparison.OrdinalIgnoreCase)) return Symbol.Clock;
|
||||||
|
if (string.Equals(categoryId, "Date", StringComparison.OrdinalIgnoreCase)) return Symbol.CalendarDate;
|
||||||
|
if (string.Equals(categoryId, "Weather", StringComparison.OrdinalIgnoreCase)) return Symbol.WeatherSunny;
|
||||||
|
if (string.Equals(categoryId, "Board", StringComparison.OrdinalIgnoreCase)) return Symbol.Edit;
|
||||||
|
if (string.Equals(categoryId, "Media", StringComparison.OrdinalIgnoreCase)) return Symbol.Play;
|
||||||
|
if (string.Equals(categoryId, "Info", StringComparison.OrdinalIgnoreCase)) return Symbol.Apps;
|
||||||
|
if (string.Equals(categoryId, "Calculator", StringComparison.OrdinalIgnoreCase)) return Symbol.Calculator;
|
||||||
|
if (string.Equals(categoryId, "Study", StringComparison.OrdinalIgnoreCase)) return Symbol.Hourglass;
|
||||||
|
if (string.Equals(categoryId, "File", StringComparison.OrdinalIgnoreCase)) return Symbol.Folder;
|
||||||
|
return Symbol.Apps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分类本地化标题 - 与阑山桌面 Dock 栏组件库 (MainWindow.ComponentSystem) 保持一致
|
||||||
|
/// </summary>
|
||||||
|
private string GetLocalizedCategoryTitle(string languageCode, string categoryId)
|
||||||
|
{
|
||||||
|
if (string.Equals(categoryId, "Clock", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.clock", "Clock");
|
||||||
|
if (string.Equals(categoryId, "Date", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.date", "Calendar");
|
||||||
|
if (string.Equals(categoryId, "Weather", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.weather", "Weather");
|
||||||
|
if (string.Equals(categoryId, "Board", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.board", "Board");
|
||||||
|
if (string.Equals(categoryId, "Media", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.media", "Media");
|
||||||
|
if (string.Equals(categoryId, "Info", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.info", "Info");
|
||||||
|
if (string.Equals(categoryId, "Calculator", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.calculator", "Calculator");
|
||||||
|
if (string.Equals(categoryId, "Study", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.study", "Study");
|
||||||
|
if (string.Equals(categoryId, "File", StringComparison.OrdinalIgnoreCase)) return L(languageCode, "component_category.file", "File");
|
||||||
|
return categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string L(string languageCode, string key, string fallback)
|
||||||
|
{
|
||||||
|
return _localizationService.GetString(languageCode, key, fallback);
|
||||||
|
}
|
||||||
|
|
||||||
private ComponentLibraryItemViewModel CreateComponentItem(DesktopComponentDefinition definition)
|
private ComponentLibraryItemViewModel CreateComponentItem(DesktopComponentDefinition definition)
|
||||||
{
|
{
|
||||||
var previewKey = ComponentPreviewKey.ForComponentType(
|
var previewKey = ComponentPreviewKey.ForComponentType(
|
||||||
@@ -221,4 +252,22 @@ public partial class FusedDesktopComponentLibraryControl : UserControl
|
|||||||
AddComponentRequested?.Invoke(this, componentId);
|
AddComponentRequested?.Invoke(this, componentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnFindMoreComponentsClick(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
// 打开设置窗口并导航到插件目录页面
|
||||||
|
if (Application.Current is App app && app.SettingsWindowService is { } settingsWindowService)
|
||||||
|
{
|
||||||
|
var mainWindow = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow as MainWindow;
|
||||||
|
var request = new SettingsWindowOpenRequest(
|
||||||
|
Source: "FusedDesktopComponentLibrary",
|
||||||
|
Owner: mainWindow,
|
||||||
|
PageId: "plugin-catalog");
|
||||||
|
settingsWindowService.Open(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭所在窗口
|
||||||
|
var window = this.FindAncestorOfType<Window>();
|
||||||
|
window?.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,69 +1,73 @@
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:controls="using:LanMountainDesktop.Views"
|
xmlns:controls="using:LanMountainDesktop.Views"
|
||||||
xmlns:fi="using:FluentIcons.Avalonia"
|
xmlns:fi="using:FluentIcons.Avalonia.Fluent"
|
||||||
x:Class="LanMountainDesktop.Views.FusedDesktopComponentLibraryWindow"
|
x:Class="LanMountainDesktop.Views.FusedDesktopComponentLibraryWindow"
|
||||||
Width="860" Height="620"
|
Width="860" Height="620"
|
||||||
MinWidth="600" MinHeight="500"
|
MinWidth="600" MinHeight="500"
|
||||||
|
CanResize="True"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
SystemDecorations="Full"
|
SystemDecorations="BorderOnly"
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
ExtendClientAreaChromeHints="NoChrome"
|
ExtendClientAreaChromeHints="NoChrome"
|
||||||
ExtendClientAreaTitleBarHeightHint="-1"
|
ExtendClientAreaTitleBarHeightHint="48"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
TransparencyLevelHint="Mica"
|
|
||||||
Title="添加小组件">
|
Title="添加小组件">
|
||||||
|
|
||||||
<Panel>
|
<Grid x:Name="RootGrid"
|
||||||
<!-- 背景磨砂效果 -->
|
Classes="settings-scope"
|
||||||
<Border Background="{DynamicResource AdaptiveSurfaceLowBrush}"
|
Background="{DynamicResource AdaptiveSettingsWindowBackgroundBrush}"
|
||||||
Opacity="0.85" />
|
RowDefinitions="Auto,*">
|
||||||
|
<!-- 自定义标题栏 - 与 SettingsWindow 风格一致 -->
|
||||||
|
<Border x:Name="WindowTitleBarHost"
|
||||||
|
Height="48"
|
||||||
|
Padding="12,0,12,0"
|
||||||
|
Background="{DynamicResource AdaptiveSettingsWindowBackgroundBrush}"
|
||||||
|
BorderBrush="{DynamicResource AdaptiveSettingsWindowBorderBrush}"
|
||||||
|
BorderThickness="0,0,0,1"
|
||||||
|
PointerPressed="OnWindowTitleBarPointerPressed">
|
||||||
|
<Grid ColumnDefinitions="Auto,Auto,*,Auto"
|
||||||
|
ColumnSpacing="8"
|
||||||
|
VerticalAlignment="Center">
|
||||||
|
<fi:FluentIcon x:Name="WindowBrandIcon"
|
||||||
|
Icon="Apps"
|
||||||
|
IconVariant="Filled"
|
||||||
|
FontSize="16"
|
||||||
|
IsHitTestVisible="False"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
|
||||||
<Grid RowDefinitions="Auto,*,Auto">
|
<TextBlock x:Name="WindowTitleTextBlock"
|
||||||
<!-- 自定义标题栏 -->
|
Grid.Column="1"
|
||||||
<Border Background="Transparent"
|
FontSize="12"
|
||||||
IsHitTestVisible="True"
|
FontWeight="SemiBold"
|
||||||
Padding="20,16">
|
IsHitTestVisible="False"
|
||||||
<Grid ColumnDefinitions="*,Auto">
|
Text="添加小组件" />
|
||||||
<StackPanel Spacing="6" VerticalAlignment="Center">
|
|
||||||
<TextBlock Text="添加小组件"
|
|
||||||
FontWeight="SemiBold"
|
|
||||||
FontSize="20"
|
|
||||||
Foreground="{DynamicResource AdaptiveTextPrimaryBrush}" />
|
|
||||||
<TextBlock Text="将精美组件放置在您的系统桌面上(负一屏)"
|
|
||||||
Opacity="0.6"
|
|
||||||
FontSize="13"
|
|
||||||
Foreground="{DynamicResource AdaptiveTextPrimaryBrush}" />
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<Button Grid.Column="1"
|
<TextBlock Grid.Column="2"
|
||||||
Width="36" Height="36"
|
FontSize="12"
|
||||||
Padding="0"
|
Opacity="0.6"
|
||||||
CornerRadius="{DynamicResource DesignCornerRadiusSm}"
|
IsHitTestVisible="False"
|
||||||
BorderThickness="0"
|
VerticalAlignment="Center"
|
||||||
Click="OnCloseClick">
|
Text="将精美组件放置在您的系统桌面上(负一屏)" />
|
||||||
<fi:SymbolIcon Symbol="Dismiss" FontSize="18" />
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<!-- 组件库控件 -->
|
<Button x:Name="CloseWindowButton"
|
||||||
<controls:FusedDesktopComponentLibraryControl x:Name="LibraryControl"
|
Grid.Column="3"
|
||||||
Grid.Row="1" />
|
Width="40"
|
||||||
|
Height="32"
|
||||||
<!-- 底部查找更多组件链接 -->
|
Padding="0"
|
||||||
<Border Grid.Row="2"
|
Background="Transparent"
|
||||||
Background="Transparent"
|
BorderThickness="0"
|
||||||
Padding="20,12">
|
Click="OnCloseClick">
|
||||||
<Button Classes="hyperlink"
|
<fi:FluentIcon Icon="Dismiss"
|
||||||
HorizontalAlignment="Center"
|
IconVariant="Regular"
|
||||||
Click="OnFindMoreComponentsClick">
|
FontSize="16" />
|
||||||
<StackPanel Orientation="Horizontal" Spacing="4">
|
|
||||||
<fi:SymbolIcon Symbol="Globe" FontSize="14" />
|
|
||||||
<TextBlock Text="查找更多组件" />
|
|
||||||
</StackPanel>
|
|
||||||
</Button>
|
</Button>
|
||||||
</Border>
|
</Grid>
|
||||||
</Grid>
|
</Border>
|
||||||
</Panel>
|
|
||||||
|
<!-- 组件库控件 -->
|
||||||
|
<controls:FusedDesktopComponentLibraryControl x:Name="LibraryControl"
|
||||||
|
Grid.Row="1"
|
||||||
|
Margin="12,8,16,8" />
|
||||||
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using LanMountainDesktop.ComponentSystem;
|
using LanMountainDesktop.ComponentSystem;
|
||||||
using LanMountainDesktop.Services;
|
using LanMountainDesktop.Services;
|
||||||
@@ -103,23 +104,11 @@ public partial class FusedDesktopComponentLibraryWindow : Window
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
private void OnWindowTitleBarPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||||
/// 查找更多组件链接点击处理 - 打开设置窗口的插件目录页面
|
|
||||||
/// </summary>
|
|
||||||
private void OnFindMoreComponentsClick(object? sender, RoutedEventArgs e)
|
|
||||||
{
|
{
|
||||||
// 关闭当前窗口
|
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||||
Close();
|
|
||||||
|
|
||||||
// 打开设置窗口并导航到插件目录页面
|
|
||||||
if (Application.Current is App app && app.SettingsWindowService is { } settingsWindowService)
|
|
||||||
{
|
{
|
||||||
var mainWindow = (Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow as MainWindow;
|
BeginMoveDrag(e);
|
||||||
var request = new SettingsWindowOpenRequest(
|
|
||||||
Source: "FusedDesktopComponentLibrary",
|
|
||||||
Owner: mainWindow,
|
|
||||||
PageId: "plugin-catalog");
|
|
||||||
settingsWindowService.Open(request);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user