forked from sourcegit-scm/sourcegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddWorktree.axaml.cs
More file actions
40 lines (36 loc) · 1.2 KB
/
AddWorktree.axaml.cs
File metadata and controls
40 lines (36 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
namespace SourceGit.Views
{
public partial class AddWorktree : UserControl
{
public AddWorktree()
{
InitializeComponent();
}
private async void SelectLocation(object _, RoutedEventArgs e)
{
var toplevel = TopLevel.GetTopLevel(this);
if (toplevel == null)
return;
var options = new FolderPickerOpenOptions() { AllowMultiple = false };
try
{
var selected = await toplevel.StorageProvider.OpenFolderPickerAsync(options);
if (selected.Count == 1)
{
var folder = selected[0];
var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder?.Path.ToString();
TxtLocation.Text = folderPath.TrimEnd('\\');
}
}
catch (Exception exception)
{
App.RaiseException(string.Empty, $"Failed to select location: {exception.Message}");
}
e.Handled = true;
}
}
}