blob: 42e65f9934ba0a9d0270282e607b18ec5d22eb99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
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;
public partial class DashboardView : Window
{
public DashboardView() => InitializeComponent();
private void MoveWindow(object sender, PointerPressedEventArgs e)
{
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;
}
}
}
}
}
|