diff options
Diffstat (limited to 'JVDesktop/Views')
| -rw-r--r-- | JVDesktop/Views/DashboardView.axaml | 4 | ||||
| -rw-r--r-- | JVDesktop/Views/DashboardView.axaml.cs | 41 |
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; + } + } + } + } } |
