summaryrefslogtreecommitdiff
path: root/JVDesktop/Views/DashboardView.axaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'JVDesktop/Views/DashboardView.axaml.cs')
-rw-r--r--JVDesktop/Views/DashboardView.axaml.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/JVDesktop/Views/DashboardView.axaml.cs b/JVDesktop/Views/DashboardView.axaml.cs
index ae58263..42e65f9 100644
--- a/JVDesktop/Views/DashboardView.axaml.cs
+++ b/JVDesktop/Views/DashboardView.axaml.cs
@@ -1,5 +1,12 @@
+using System;
+using System.IO;
+using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Input;
+using Avalonia.Interactivity;
+using Avalonia.Platform.Storage;
+using CommandLineWrapper;
+using JVDesktop.ViewModels;
namespace JVDesktop.Views;
@@ -12,4 +19,38 @@ public partial class DashboardView : Window
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
BeginMoveDrag(e);
}
+
+ /// <summary>
+ /// Select and setup workspace
+ /// </summary>
+ private async void SetupWorkspace(object? sender, RoutedEventArgs routedEventArgs)
+ {
+ var topLevel = GetTopLevel(this);
+ if (topLevel == null) return;
+
+ var storageProvider = topLevel.StorageProvider;
+
+ var result = await storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions
+ {
+ Title = "Select JustEnoughVCS Workspace",
+ AllowMultiple = false
+ });
+
+ if (result.Count > 0)
+ {
+ var selectedFolder = result[0];
+ var folderPath = selectedFolder.Path.LocalPath;
+
+ if (Directory.Exists(folderPath))
+ {
+ var workspace = new JVCSWorkspace();
+ await workspace.InitializeAsync(folderPath);
+ if (workspace.SuccessInitialized)
+ {
+ if (DataContext is DashboardViewModel viewModel)
+ viewModel.Workspace = workspace;
+ }
+ }
+ }
+ }
}