68 lines
1.7 KiB
C#
68 lines
1.7 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Input.Platform;
|
|
using Avalonia.Markup.Xaml;
|
|
|
|
namespace StreamPlayer.Desktop.Views;
|
|
|
|
public partial class BlockedDialog : Window
|
|
{
|
|
private readonly string _token;
|
|
|
|
private TextBlock? _reasonText;
|
|
private StackPanel? _tokenPanel;
|
|
private TextBox? _tokenText;
|
|
|
|
public BlockedDialog() : this(string.Empty, string.Empty)
|
|
{
|
|
}
|
|
|
|
public BlockedDialog(string reason, string token)
|
|
{
|
|
_token = token ?? string.Empty;
|
|
InitializeComponent();
|
|
if (_reasonText != null)
|
|
{
|
|
_reasonText.Text = string.IsNullOrWhiteSpace(reason)
|
|
? "Tu dispositivo fue bloqueado por el administrador."
|
|
: reason;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(_token))
|
|
{
|
|
if (_tokenPanel != null)
|
|
{
|
|
_tokenPanel.IsVisible = true;
|
|
}
|
|
if (_tokenText != null)
|
|
{
|
|
_tokenText.Text = _token;
|
|
}
|
|
}
|
|
}
|
|
|
|
private async void OnCopyClicked(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(_token))
|
|
{
|
|
return;
|
|
}
|
|
var clipboard = TopLevel.GetTopLevel(this)?.Clipboard;
|
|
if (clipboard != null)
|
|
{
|
|
await clipboard.SetTextAsync(_token);
|
|
}
|
|
}
|
|
|
|
private void OnCloseClicked(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
|
{
|
|
Close(true);
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
_reasonText = this.FindControl<TextBlock>("ReasonText");
|
|
_tokenPanel = this.FindControl<StackPanel>("TokenPanel");
|
|
_tokenText = this.FindControl<TextBox>("TokenText");
|
|
}
|
|
}
|