-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMcpServerDialogWindow.axaml.cs
More file actions
95 lines (79 loc) · 2.35 KB
/
Copy pathMcpServerDialogWindow.axaml.cs
File metadata and controls
95 lines (79 loc) · 2.35 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System.Collections.Generic;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using LlamaServerLauncher.Models;
using LlamaServerLauncher.Services;
using LlamaServerLauncher.ViewModels;
namespace LlamaServerLauncher;
public partial class McpServerDialogWindow : Window
{
private McpServerDialogViewModel? _viewModel;
public DialogGeometry? CapturedGeometry { get; private set; }
public bool IsConfirmed { get; private set; }
public bool IsDeleteRequested { get; private set; }
public McpServerDialogWindow()
{
InitializeComponent();
}
public void SetViewModel(McpServerDialogViewModel vm, Dictionary<string, DialogGeometry>? dialogGeometryDict = null)
{
_viewModel = vm;
DataContext = vm;
vm.RequestClose += Close;
if (dialogGeometryDict != null)
DialogPositionHelper.ApplySavedGeometry(this, dialogGeometryDict, "McpServerDialog");
}
private async void BrowseCommandClick(object? sender, RoutedEventArgs e)
{
if (_viewModel != null)
await _viewModel.BrowseCommandAsync();
}
private async void BrowseWorkingDirectoryClick(object? sender, RoutedEventArgs e)
{
if (_viewModel != null)
await _viewModel.BrowseWorkingDirectoryAsync();
}
private async void TestClick(object? sender, RoutedEventArgs e)
{
if (_viewModel != null)
await _viewModel.ProbeAsync();
}
private void DeleteClick(object? sender, RoutedEventArgs e)
{
IsDeleteRequested = true;
IsConfirmed = false;
Close();
}
private void SaveClick(object? sender, RoutedEventArgs e)
{
IsConfirmed = true;
Close();
}
private void CancelClick(object? sender, RoutedEventArgs e)
{
IsConfirmed = false;
Close();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
CancelClick(null, e);
e.Handled = true;
return;
}
base.OnKeyDown(e);
}
protected override void OnClosing(WindowClosingEventArgs e)
{
CapturedGeometry = new DialogGeometry
{
Width = Width,
Height = Height,
Left = Position.X,
Top = Position.Y
};
base.OnClosing(e);
}
}