Files
minecraft-modpack-updater/ModpackUpdater.Apps.Manager/Features/Workspaces/LocalFolder/LocalFolderWorkspaceConfigEditorView.axaml.cs
2025-11-17 16:54:15 +01:00

49 lines
1.4 KiB
C#

using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
using ModpackUpdater.Apps.Manager.LangRes;
using Pilz.UI.AvaloniaUI.Dialogs;
namespace ModpackUpdater.Apps.Manager.Features.Workspaces.LocalFolder;
public partial class LocalFolderWorkspaceConfigEditorView : AvaloniaFlyoutBase
{
public LocalFolderWorkspaceConfig Settings { get; }
public LocalFolderWorkspaceConfigEditorView() : this(new())
{
}
public LocalFolderWorkspaceConfigEditorView(LocalFolderWorkspaceConfig settings)
{
Settings = settings;
DataContext = settings;
InitializeComponent();
ButtonSearch.ImageSource = AppGlobals.Symbols.GetImageSource(AppSymbols.opened_folder);
}
protected override object? GetResult()
{
return Settings;
}
private async void ButtonSearch_OnClick(object? sender, RoutedEventArgs e)
{
if (TopLevel.GetTopLevel(this) is not { } topLevel)
return;
var filePaths = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
{
Title = GeneralLangRes.SelectRootFolder,
AllowMultiple = false,
});
if (filePaths.Count < 1)
return;
TextBoxRootFolderPath.Text = filePaths[0].Path.AbsolutePath;
if (string.IsNullOrWhiteSpace(TextBoxName.Text))
TextBoxName.Text = filePaths[0].Name;
}
}