mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-22 17:24:27 +08:00
0.6.7.2
文档组件优化
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
x:Class="LanMountainDesktop.Views.ComponentEditors.OfficeRecentDocumentsComponentEditor">
|
||||
<StackPanel Spacing="16">
|
||||
<Border Classes="component-editor-hero-card"
|
||||
Padding="24">
|
||||
<StackPanel Spacing="8">
|
||||
<TextBlock x:Name="HeadlineTextBlock"
|
||||
Classes="component-editor-headline"
|
||||
TextWrapping="Wrap" />
|
||||
<TextBlock x:Name="DescriptionTextBlock"
|
||||
Classes="component-editor-secondary-text"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Classes="component-editor-card"
|
||||
Padding="20">
|
||||
<StackPanel Spacing="12">
|
||||
<TextBlock x:Name="SourcesHeaderTextBlock"
|
||||
Classes="component-editor-section-title" />
|
||||
<TextBlock x:Name="SourcesDescriptionTextBlock"
|
||||
Classes="component-editor-secondary-text"
|
||||
TextWrapping="Wrap" />
|
||||
<CheckBox x:Name="RegistryCheckBox"
|
||||
IsCheckedChanged="OnSourceSelectionChanged" />
|
||||
<CheckBox x:Name="RecentFoldersCheckBox"
|
||||
IsCheckedChanged="OnSourceSelectionChanged" />
|
||||
<CheckBox x:Name="JumpListsCheckBox"
|
||||
IsCheckedChanged="OnSourceSelectionChanged" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<TextBlock x:Name="HintTextBlock"
|
||||
Classes="component-editor-secondary-text"
|
||||
Margin="12,0"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Avalonia.Interactivity;
|
||||
using LanMountainDesktop.ComponentSystem;
|
||||
using LanMountainDesktop.Models;
|
||||
|
||||
namespace LanMountainDesktop.Views.ComponentEditors;
|
||||
|
||||
public partial class OfficeRecentDocumentsComponentEditor : ComponentEditorViewBase
|
||||
{
|
||||
private bool _suppressEvents;
|
||||
|
||||
public OfficeRecentDocumentsComponentEditor()
|
||||
: this(null)
|
||||
{
|
||||
}
|
||||
|
||||
public OfficeRecentDocumentsComponentEditor(DesktopComponentEditorContext? context)
|
||||
: base(context)
|
||||
{
|
||||
InitializeComponent();
|
||||
ApplyState();
|
||||
}
|
||||
|
||||
private void ApplyState()
|
||||
{
|
||||
var snapshot = LoadSnapshot();
|
||||
var enabledSources = OfficeRecentDocumentSourceTypes.NormalizeValues(
|
||||
snapshot.OfficeRecentDocumentsEnabledSources,
|
||||
useDefaultWhenEmpty: snapshot.OfficeRecentDocumentsEnabledSources is null);
|
||||
|
||||
HeadlineTextBlock.Text = Context?.Definition.DisplayName ?? "Office Recent Documents";
|
||||
DescriptionTextBlock.Text = L(
|
||||
"office_recent_documents.settings.desc",
|
||||
"Choose which Windows and Office sources this widget should scan for recent documents.");
|
||||
SourcesHeaderTextBlock.Text = L(
|
||||
"office_recent_documents.settings.sources_title",
|
||||
"Recent document sources");
|
||||
SourcesDescriptionTextBlock.Text = L(
|
||||
"office_recent_documents.settings.sources_desc",
|
||||
"You can combine multiple sources. Registry selection also keeps the Office interop MRU fallback available.");
|
||||
RegistryCheckBox.Content = L(
|
||||
"office_recent_documents.settings.source.registry",
|
||||
"Office registry MRU");
|
||||
RecentFoldersCheckBox.Content = L(
|
||||
"office_recent_documents.settings.source.recent_folders",
|
||||
"Windows Recent folders");
|
||||
JumpListsCheckBox.Content = L(
|
||||
"office_recent_documents.settings.source.jump_lists",
|
||||
"Windows Jump Lists");
|
||||
HintTextBlock.Text = L(
|
||||
"office_recent_documents.settings.hint",
|
||||
"If you disable all sources, this widget will stay empty until at least one source is enabled again.");
|
||||
|
||||
_suppressEvents = true;
|
||||
RegistryCheckBox.IsChecked = enabledSources.Contains(OfficeRecentDocumentSourceTypes.Registry, StringComparer.OrdinalIgnoreCase);
|
||||
RecentFoldersCheckBox.IsChecked = enabledSources.Contains(OfficeRecentDocumentSourceTypes.RecentFolders, StringComparer.OrdinalIgnoreCase);
|
||||
JumpListsCheckBox.IsChecked = enabledSources.Contains(OfficeRecentDocumentSourceTypes.JumpLists, StringComparer.OrdinalIgnoreCase);
|
||||
_suppressEvents = false;
|
||||
}
|
||||
|
||||
private void OnSourceSelectionChanged(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
_ = sender;
|
||||
_ = e;
|
||||
if (_suppressEvents)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedSources = new[]
|
||||
{
|
||||
RegistryCheckBox.IsChecked == true ? OfficeRecentDocumentSourceTypes.Registry : null,
|
||||
RecentFoldersCheckBox.IsChecked == true ? OfficeRecentDocumentSourceTypes.RecentFolders : null,
|
||||
JumpListsCheckBox.IsChecked == true ? OfficeRecentDocumentSourceTypes.JumpLists : null
|
||||
}
|
||||
.Where(static value => !string.IsNullOrWhiteSpace(value))
|
||||
.Cast<string>()
|
||||
.ToList();
|
||||
|
||||
var snapshot = LoadSnapshot();
|
||||
snapshot.OfficeRecentDocumentsEnabledSources = selectedSources;
|
||||
SaveSnapshot(snapshot, nameof(ComponentSettingsSnapshot.OfficeRecentDocumentsEnabledSources));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user