i live in spain but the S is silent
All checks were successful
Build and push image / Build (push) Successful in 49s
All checks were successful
Build and push image / Build (push) Successful in 49s
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<UserControl x:Class="ksBroadcastingTestClient.ClientConnections.ClientConnectionView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ksBroadcastingTestClient.ClientConnections"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Target: " FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding IPort}" FontWeight="Bold" />
|
||||
<TextBlock Text=" CId: " FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding ConnectionId}" FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox IsChecked="{Binding Connected}" Content="IsConnected" IsEnabled="False" />
|
||||
<CheckBox IsChecked="{Binding IsReadonly}" Content="IsReadonly" IsEnabled="False" />
|
||||
</StackPanel>
|
||||
<TextBlock Text="{Binding ErrorMessage}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ksBroadcastingTestClient.ClientConnections
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ClientConnectionViewModel.xaml
|
||||
/// </summary>
|
||||
public partial class ClientConnectionView : UserControl
|
||||
{
|
||||
public ClientConnectionView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using ksBroadcastingNetwork;
|
||||
|
||||
namespace ksBroadcastingTestClient.ClientConnections
|
||||
{
|
||||
public class ClientConnectionViewModel : KSObservableObject
|
||||
{
|
||||
public string IPort => Client.IpPort;
|
||||
public ACCUdpRemoteClient Client { get; }
|
||||
public Action<ACCUdpRemoteClient> OnClientConnectedCallback { get; }
|
||||
public int ConnectionId { get => Get<int>(); set => Set(value); }
|
||||
public bool Connected { get => Get<bool>(); set => Set(value); }
|
||||
public bool IsReadonly { get => Get<bool>(); set => Set(value); }
|
||||
public string ErrorMessage { get => Get<string>(); set => Set(value); }
|
||||
|
||||
public ClientConnectionViewModel(ACCUdpRemoteClient c, Action<ACCUdpRemoteClient> onClientConnectedCallback)
|
||||
{
|
||||
Client = c;
|
||||
OnClientConnectedCallback = onClientConnectedCallback;
|
||||
c.MessageHandler.OnConnectionStateChanged += ConnectionStateChanged;
|
||||
}
|
||||
|
||||
private void ConnectionStateChanged(int connectionId, bool connectionSuccess, bool isReadonly, string error)
|
||||
{
|
||||
ConnectionId = connectionId;
|
||||
Connected = connectionSuccess;
|
||||
IsReadonly = IsReadonly;
|
||||
ErrorMessage = error;
|
||||
|
||||
if (Connected)
|
||||
OnClientConnectedCallback?.Invoke(Client);
|
||||
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
Client.MessageHandler.OnConnectionStateChanged -= ConnectionStateChanged;
|
||||
Client.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
<UserControl x:Class="ksBroadcastingTestClient.ClientConnections.ClientPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:ksBroadcastingTestClient.ClientConnections"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="150"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="130"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel>
|
||||
<TextBlock Text="IP:" Margin="1" />
|
||||
<TextBlock Text="Port:" Margin="1" />
|
||||
<TextBlock Text="Display Name:" Margin="1" />
|
||||
<TextBlock Text="Connection PW:" Margin="1" />
|
||||
<TextBlock Text="Update interval:" Margin="1" />
|
||||
<TextBlock Text="Command PW:" Margin="1"/>
|
||||
<Button Content="Connect" Command="{Binding ConnectCmd}" Margin="1"/>
|
||||
<Button Content="Disconnect" Command="{Binding DisconnectCmd}" Margin="1"/>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBox Text="{Binding IP}" />
|
||||
<TextBox Text="{Binding Port}" />
|
||||
<TextBox Text="{Binding DisplayName}" />
|
||||
<TextBox Text="{Binding ConnectionPw}" />
|
||||
<TextBox Text="{Binding RealtimeUpdateIntervalMS}" />
|
||||
<TextBox Text="{Binding CommandPw}" />
|
||||
</StackPanel>
|
||||
|
||||
<ListView ItemsSource="{Binding Clients}" SelectedItem="{Binding SelectedClient}"
|
||||
Grid.ColumnSpan="2" Grid.Row="1" Margin="1, 20, 1, 1">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<local:ClientConnectionView />
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</Grid>
|
||||
</UserControl>
|
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ksBroadcastingTestClient.ClientConnections
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ClientPanel.xaml
|
||||
/// </summary>
|
||||
public partial class ClientPanel : UserControl
|
||||
{
|
||||
public ClientPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
using ksBroadcastingNetwork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ksBroadcastingTestClient.ClientConnections
|
||||
{
|
||||
public class ClientPanelViewModel : KSObservableObject
|
||||
{
|
||||
public string IP { get => Get<string>(); set => Set(value); }
|
||||
public int Port { get => Get<int>(); set => Set(value); }
|
||||
public string DisplayName { get => Get<string>(); set => Set(value); }
|
||||
public string ConnectionPw { get => Get<string>(); set => Set(value); }
|
||||
public string CommandPw { get => Get<string>(); set => Set(value); }
|
||||
public int RealtimeUpdateIntervalMS { get => Get<int>(); set => Set(value); }
|
||||
public KSRelayCommand ConnectCmd { get; }
|
||||
public KSRelayCommand DisconnectCmd { get; }
|
||||
|
||||
public ObservableCollection<ClientConnectionViewModel> Clients { get; } = new ObservableCollection<ClientConnectionViewModel>();
|
||||
public Action<ACCUdpRemoteClient> OnClientConnectedCallback { get; }
|
||||
public ClientConnectionViewModel SelectedClient { get => Get<ClientConnectionViewModel>(); set => Set(value); }
|
||||
|
||||
public ClientPanelViewModel(Action<ACCUdpRemoteClient> onClientConnectedCallback)
|
||||
{
|
||||
ConnectCmd = new KSRelayCommand(DoConnect);
|
||||
DisconnectCmd = new KSRelayCommand(DoDisconnect);
|
||||
|
||||
IP = "127.0.0.1";
|
||||
Port = 9000;
|
||||
DisplayName = "Your name";
|
||||
ConnectionPw = "asd";
|
||||
CommandPw = "";
|
||||
RealtimeUpdateIntervalMS = 250;
|
||||
OnClientConnectedCallback = onClientConnectedCallback;
|
||||
}
|
||||
|
||||
public void DoConnect(object parameter = null)
|
||||
{
|
||||
var c = new ACCUdpRemoteClient(IP, Port, DisplayName, ConnectionPw, CommandPw, RealtimeUpdateIntervalMS);
|
||||
Clients.Add(new ClientConnectionViewModel(c, OnClientConnectedCallback));
|
||||
}
|
||||
|
||||
private void DoDisconnect(object obj)
|
||||
{
|
||||
if(SelectedClient != null)
|
||||
{
|
||||
SelectedClient.Disconnect();
|
||||
Clients.Remove(SelectedClient);
|
||||
SelectedClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
internal void Shutdown()
|
||||
{
|
||||
foreach (var client in Clients)
|
||||
{
|
||||
client.Disconnect();
|
||||
}
|
||||
Clients.Clear();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user