mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-23 11:01:26 -07:00
40 lines
1.3 KiB
C#
40 lines
1.3 KiB
C#
using System.Windows;
|
|
using System.Windows.Input;
|
|
using Bloxstrap.Integrations;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace Bloxstrap.UI.ViewModels.ContextMenu
|
|
{
|
|
internal class ServerInformationViewModel : NotifyPropertyChangedViewModel
|
|
{
|
|
private readonly ActivityWatcher _activityWatcher;
|
|
|
|
public string InstanceId => _activityWatcher.Data.JobId;
|
|
|
|
public string ServerType => _activityWatcher.Data.ServerType.ToTranslatedString();
|
|
|
|
public string ServerLocation { get; private set; } = Strings.ContextMenu_ServerInformation_Loading;
|
|
|
|
public ICommand CopyInstanceIdCommand => new RelayCommand(CopyInstanceId);
|
|
|
|
public ICommand CloseWindowCommand => new RelayCommand(RequestClose);
|
|
|
|
public EventHandler? RequestCloseEvent;
|
|
|
|
public ServerInformationViewModel(Watcher watcher)
|
|
{
|
|
_activityWatcher = watcher.ActivityWatcher!;
|
|
|
|
Task.Run(async () =>
|
|
{
|
|
ServerLocation = await _activityWatcher.GetServerLocation();
|
|
OnPropertyChanged(nameof(ServerLocation));
|
|
});
|
|
}
|
|
|
|
private void CopyInstanceId() => Clipboard.SetDataObject(InstanceId);
|
|
|
|
private void RequestClose() => RequestCloseEvent?.Invoke(this, EventArgs.Empty);
|
|
}
|
|
}
|