-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAgentViewModel.cs
52 lines (42 loc) · 1.32 KB
/
AgentViewModel.cs
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
using Windows.ApplicationModel.DataTransfer;
using CommunityToolkit.Mvvm.Input;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
namespace Coder.Desktop.App.ViewModels;
public enum AgentConnectionStatus
{
Green,
Red,
Yellow,
Gray,
}
public partial class AgentViewModel
{
public required string Hostname { get; set; }
public required string HostnameSuffix { get; set; } // including leading dot
public required AgentConnectionStatus ConnectionStatus { get; set; }
public string FullHostname => Hostname + HostnameSuffix;
public required string DashboardUrl { get; set; }
[RelayCommand]
private void CopyHostname(object parameter)
{
var dataPackage = new DataPackage
{
RequestedOperation = DataPackageOperation.Copy,
};
dataPackage.SetText(FullHostname);
Clipboard.SetContent(dataPackage);
if (parameter is not FrameworkElement frameworkElement) return;
var flyout = new Flyout
{
Content = new TextBlock
{
Text = "DNS Copied",
Margin = new Thickness(4),
},
};
FlyoutBase.SetAttachedFlyout(frameworkElement, flyout);
FlyoutBase.ShowAttachedFlyout(frameworkElement);
}
}