sourcegit/src/Views/ConfigureWorkspace.axaml.cs
leo 03216fc31e
code_style: run dotnet format and re-order codes
Signed-off-by: leo <longshuang@msn.cn>
2025-04-15 16:30:50 +08:00

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;
}
}
}