-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathConfigureWorkspace.axaml.cs
More file actions
49 lines (43 loc) · 1.49 KB
/
Copy pathConfigureWorkspace.axaml.cs
File metadata and controls
49 lines (43 loc) · 1.49 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
41
42
43
44
45
46
47
48
49
using System;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
namespace SourceGit.Views
{
public partial class ConfigureWorkspace : ChromelessWindow
{
public ConfigureWorkspace()
{
CloseOnESC = true;
InitializeComponent();
}
protected override void OnClosing(WindowClosingEventArgs e)
{
base.OnClosing(e);
if (!Design.IsDesignMode)
ViewModels.Preferences.Instance.Save();
}
private async void SelectDefaultCloneDir(object _, RoutedEventArgs e)
{
var workspace = DataContext as ViewModels.ConfigureWorkspace;
if (workspace?.Selected == null)
return;
var options = new FolderPickerOpenOptions() { AllowMultiple = false };
try
{
var selected = await StorageProvider.OpenFolderPickerAsync(options);
if (selected.Count == 1)
{
var folder = selected[0];
var folderPath = folder is { Path: { IsAbsoluteUri: true } path } ? path.LocalPath : folder?.Path.ToString();
workspace.Selected.DefaultCloneDir = folderPath;
}
}
catch (Exception ex)
{
await new Alert().ShowAsync(this, $"Failed to select default clone directory: {ex.Message}", true);
}
e.Handled = true;
}
}
}