using Avalonia; using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; using Mesen.Utilities; using System; namespace Mesen.Controls { public class PathSelector : UserControl { public static readonly StyledProperty DisabledPathProperty = AvaloniaProperty.Register(nameof(DisabledPath)); public static readonly StyledProperty PathProperty = AvaloniaProperty.Register(nameof(Path), "", false, Avalonia.Data.BindingMode.TwoWay); public static readonly StyledProperty EditableProperty = AvaloniaProperty.Register(nameof(Editable)); public string DisabledPath { get { return GetValue(DisabledPathProperty); } set { SetValue(DisabledPathProperty, value); } } public string Path { get { return GetValue(PathProperty); } set { SetValue(PathProperty, value); } } public bool Editable { get { return GetValue(EditableProperty); } set { SetValue(EditableProperty, value); } } public PathSelector() { InitializeComponent(); } private void InitializeComponent() { AvaloniaXamlLoader.Load(this); } private async void btnBrowse_OnClick(object sender, RoutedEventArgs e) { string? folderName = await FileDialogHelper.OpenFolder(VisualRoot); if(folderName?.Length > 0) { this.Path = folderName; } } } }