mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-29 08:04:59 +00:00
46 lines
1.3 KiB
C#
46 lines
1.3 KiB
C#
using System;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Platform.Storage;
|
|
|
|
namespace SourceGit.Views
|
|
{
|
|
public partial class ConfigureWorkspace : ChromelessWindow
|
|
{
|
|
public ConfigureWorkspace()
|
|
{
|
|
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)
|
|
{
|
|
workspace.Selected.DefaultCloneDir = selected[0].Path.LocalPath;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
App.RaiseException(string.Empty, $"Failed to select default clone directory: {ex.Message}");
|
|
}
|
|
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
}
|