Add output folder selector
This commit is contained in:
parent
43a2d756dc
commit
52f07cf547
PhotoRenamerGui
@ -15,47 +15,47 @@
|
||||
</Window.DataContext>
|
||||
<Grid ColumnDefinitions="Auto,*,Auto" RowDefinitions="Auto,Auto,*">
|
||||
<Grid.Styles>
|
||||
<Style Selector="TemplatedControl.space">
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Style Selector=":is(TemplatedControl)">
|
||||
<Setter Property="Margin" Value="0,5" />
|
||||
</Style>
|
||||
</Grid.Styles>
|
||||
<Label
|
||||
Classes="space"
|
||||
Content="Input Folder"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
VerticalAlignment="Center" />
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center" />
|
||||
<Label
|
||||
Classes="space"
|
||||
Content="Output Folder"
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
VerticalAlignment="Center" />
|
||||
VerticalAlignment="Center"
|
||||
VerticalContentAlignment="Center" />
|
||||
<TextBox
|
||||
Classes="space"
|
||||
Grid.Column="1"
|
||||
Grid.Row="0"
|
||||
Text="{Binding InputFolder}"
|
||||
Watermark="Input" />
|
||||
Watermark="Input">
|
||||
<TextBox.InnerRightContent>
|
||||
<Button
|
||||
Command="{Binding SelectInputFolderCommand}"
|
||||
Content="..."
|
||||
Margin="0,5,5,5"
|
||||
VerticalAlignment="Stretch" />
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
<TextBox
|
||||
Classes="space"
|
||||
Grid.Column="1"
|
||||
Grid.Row="1"
|
||||
Text="{Binding OutputFolder}"
|
||||
Watermark="Output" />
|
||||
<Button
|
||||
Classes="space"
|
||||
Grid.Column="2"
|
||||
Grid.Row="0"
|
||||
VerticalAlignment="Stretch">
|
||||
...
|
||||
</Button>
|
||||
<Button
|
||||
Classes="space"
|
||||
Grid.Column="2"
|
||||
Grid.Row="1"
|
||||
VerticalAlignment="Stretch">
|
||||
...
|
||||
</Button>
|
||||
Watermark="Output">
|
||||
<TextBox.InnerRightContent>
|
||||
<Button
|
||||
Command="{Binding SelectOutputFolderCommand}"
|
||||
Content="..."
|
||||
Margin="0,5,5,5"
|
||||
VerticalAlignment="Stretch" />
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
@ -1,4 +1,9 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Platform.Storage;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
namespace PhotoRenamerGui;
|
||||
|
||||
@ -6,4 +11,24 @@ public partial class MainWindowViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty] private string? _inputFolder;
|
||||
[ObservableProperty] private string? _outputFolder;
|
||||
|
||||
[RelayCommand]
|
||||
private async Task SelectInputFolder()
|
||||
{
|
||||
InputFolder = await SearchFolder();
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task SelectOutputFolder()
|
||||
{
|
||||
OutputFolder = await SearchFolder();
|
||||
}
|
||||
|
||||
private async Task<string?> SearchFolder()
|
||||
{
|
||||
var storageProvider = (App.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow
|
||||
.StorageProvider;
|
||||
var result =await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions());
|
||||
return result.FirstOrDefault()?.TryGetLocalPath();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user