mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
Add DesktopComponentRenderMode and thread the render mode through runtime context and creation APIs so controls can be created for library previews. Replace image-based preview system with static preview Controls: viewmodels and ComponentLibraryWindow now use PreviewControl, and ComponentPreviewImageService/related types and tests were removed. Add ComponentPreviewRuntimeQuiescer to attach/detach preview controls (stop timers, disable input) for safe static previews. Simplify component-library collapse state/presenter by removing transient expanded opacity handling. Update runtime registry, services, views and tests to support the new flow.
94 lines
2.2 KiB
C#
94 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using Avalonia.Controls;
|
|
using FluentIcons.Common;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
namespace LanMountainDesktop.ViewModels;
|
|
|
|
public sealed class ComponentLibraryWindowViewModel : ViewModelBase
|
|
{
|
|
private string _title = "Widgets";
|
|
private ComponentLibraryItemViewModel? _selectedComponent;
|
|
|
|
public string Title
|
|
{
|
|
get => _title;
|
|
set => SetProperty(ref _title, value);
|
|
}
|
|
|
|
public ObservableCollection<ComponentLibraryCategoryViewModel> Categories { get; } = [];
|
|
|
|
public ObservableCollection<ComponentLibraryItemViewModel> Components { get; } = [];
|
|
|
|
public ComponentLibraryItemViewModel? SelectedComponent
|
|
{
|
|
get => _selectedComponent;
|
|
set => SetProperty(ref _selectedComponent, value);
|
|
}
|
|
}
|
|
|
|
public sealed class ComponentLibraryCategoryViewModel
|
|
{
|
|
public ComponentLibraryCategoryViewModel(
|
|
string id,
|
|
string title,
|
|
Symbol icon,
|
|
IReadOnlyList<ComponentLibraryItemViewModel> components)
|
|
{
|
|
Id = id;
|
|
Title = title;
|
|
Icon = icon;
|
|
Components = components;
|
|
}
|
|
|
|
public string Id { get; }
|
|
|
|
public string Title { get; }
|
|
|
|
public Symbol Icon { get; }
|
|
|
|
public IReadOnlyList<ComponentLibraryItemViewModel> Components { get; }
|
|
}
|
|
|
|
public sealed class ComponentLibraryItemViewModel
|
|
: ObservableObject
|
|
{
|
|
private string _displayName;
|
|
private string? _description;
|
|
private Control? _previewControl;
|
|
|
|
public ComponentLibraryItemViewModel(
|
|
string componentId,
|
|
string displayName,
|
|
string? description = null,
|
|
Control? previewControl = null)
|
|
{
|
|
ComponentId = componentId;
|
|
_displayName = displayName;
|
|
_description = description;
|
|
_previewControl = previewControl;
|
|
}
|
|
|
|
public string ComponentId { get; }
|
|
|
|
public string DisplayName
|
|
{
|
|
get => _displayName;
|
|
set => SetProperty(ref _displayName, value);
|
|
}
|
|
|
|
public string? Description
|
|
{
|
|
get => _description;
|
|
set => SetProperty(ref _description, value);
|
|
}
|
|
|
|
public Control? PreviewControl
|
|
{
|
|
get => _previewControl;
|
|
set => SetProperty(ref _previewControl, value);
|
|
}
|
|
|
|
}
|