From 5d8b29664c13e6e5c6292d79973980182ece1441 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 13 Jan 2026 08:22:09 +0800 Subject: Add data loading from wrapper to view model --- JVDesktop/Views/DashboardView.axaml.cs | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'JVDesktop/Views/DashboardView.axaml.cs') 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); } + + /// + /// Select and setup workspace + /// + 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; + } + } + } + } } -- cgit