summaryrefslogtreecommitdiff
path: root/JVDesktop/Views
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-13 08:22:09 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-13 08:22:09 +0800
commit5d8b29664c13e6e5c6292d79973980182ece1441 (patch)
treeced2f67c82ce0748dbd0090f0fde6b921329d259 /JVDesktop/Views
parent7d59c15b0efd2aa5a27aef356a265f850a2e7e2f (diff)
Add data loading from wrapper to view modelHEADmain
Diffstat (limited to 'JVDesktop/Views')
-rw-r--r--JVDesktop/Views/DashboardView.axaml4
-rw-r--r--JVDesktop/Views/DashboardView.axaml.cs41
2 files changed, 43 insertions, 2 deletions
diff --git a/JVDesktop/Views/DashboardView.axaml b/JVDesktop/Views/DashboardView.axaml
index 553754f..1f0a0c4 100644
--- a/JVDesktop/Views/DashboardView.axaml
+++ b/JVDesktop/Views/DashboardView.axaml
@@ -38,13 +38,13 @@
<Border Grid.Row="1" Background="Black">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock
- Text="{Binding Greeting}"
+ Text="{Binding WorkspaceInitialized}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
<Button
Content="Click"
- Command="{Binding ButtonClickCommand}"
+ Click="SetupWorkspace"
Margin="0,10,0,0"
/>
</StackPanel>
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;
+ }
+ }
+ }
+ }
}