Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/Views/Avalonia/ExplorerSettings.axaml.cs
Hongtao Zhang c0d17672af feat(avalonia): add Avalonia settings views for 8 plugins
- Add i18n injection to Application.Resources for DynamicResource bindings
- Create Avalonia settings views for plugins:
  - Explorer (ExplorerSettings + QuickAccessLinkSettings dialog)
  - BrowserBookmark (SettingsControl + CustomBrowserSettingWindow)
  - Calculator (CalculatorSettings)
  - ProcessKiller (SettingsControl)
  - PluginsManager (PluginsManagerSettings)
  - WebSearch (SettingsControl)
  - Shell (ShellSetting + converter)
  - Program (ProgramSetting)
- Add IsAvalonia detection pattern for dual-framework dialog support
- Update 11 plugin .csproj files with CopyToAvaloniaOutput targets
- Add System.Threading.Tasks using for async RelayCommand support
2026-01-26 15:30:33 -08:00

85 lines
2.5 KiB
C#

#nullable enable
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using Avalonia.Platform.Storage;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using System;
namespace Flow.Launcher.Plugin.Explorer.Views.Avalonia
{
public partial class ExplorerSettings : UserControl
{
public ExplorerSettings()
{
InitializeComponent();
}
public ExplorerSettings(SettingsViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
private void btnOpenIndexingOptions_Click(object sender, RoutedEventArgs e)
{
SettingsViewModel.OpenWindowsIndexingOptions();
}
private async void BtnOpenFileEditorPath_OnClick(object? sender, RoutedEventArgs e)
{
if (DataContext is not SettingsViewModel vm) return;
var topLevel = TopLevel.GetTopLevel(this);
if (topLevel == null) return;
var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
AllowMultiple = false
});
if (files.Count > 0)
{
vm.FileEditorPath = files[0].Path.LocalPath;
}
}
private async void BtnOpenFolderEditorPath_OnClick(object? sender, RoutedEventArgs e)
{
if (DataContext is not SettingsViewModel vm) return;
var topLevel = TopLevel.GetTopLevel(this);
if (topLevel == null) return;
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{
AllowMultiple = false
});
if (folders.Count > 0)
{
vm.FolderEditorPath = folders[0].Path.LocalPath;
}
}
private async void BtnOpenShellPath_OnClick(object? sender, RoutedEventArgs e)
{
if (DataContext is not SettingsViewModel vm) return;
var topLevel = TopLevel.GetTopLevel(this);
if (topLevel == null) return;
var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
AllowMultiple = false
});
if (files.Count > 0)
{
vm.ShellPath = files[0].Path.LocalPath;
}
}
}
}