Skip to content

Commit

Permalink
update lock button UI, add send command to hyperdeck
Browse files Browse the repository at this point in the history
  • Loading branch information
kjgriffin committed Nov 13, 2020
1 parent 8c3379e commit 180629d
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 11 deletions.
7 changes: 6 additions & 1 deletion HyperdeckControl/HyperdeckController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ private void Connection_OnConnectionFromMaster(string senderip, bool connected)
m_isConnected = connected;
}


public void Send(string cmd)
{
cmd.TrimEnd(System.Environment.NewLine.ToCharArray());
connection.SendStringASCII($"{cmd}\r\n");
}

public void RecordStart()
{
if (IsConnected)
Expand Down
5 changes: 5 additions & 0 deletions Integrated Presenter/BMDHyperdeck/BMDHyperdeckManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ private void M_hyperdeckController_OnMessageFromHyperDeck(object sender, string
OnMessageFromHyperDeck?.Invoke(this, message);
}

public void Send(string cmd)
{
m_hyperdeckController?.Send(cmd);
}

public void StartRecording()
{
m_hyperdeckController?.RecordStart();
Expand Down
13 changes: 9 additions & 4 deletions Integrated Presenter/HyperDeckMonitorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@
xmlns:local="clr-namespace:Integrated_Presenter"
mc:Ignorable="d"
Closed="OnClosed"
Title="HyperDeckMonitorWindow" Height="450" Width="800">
Title="HyperDeck Monitor" Height="450" Width="800">
<Grid>
<ScrollViewer>
<TextBlock Name="tb"></TextBlock>
</ScrollViewer>
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Name="tbCmd" Margin="10" PreviewTextInput="OnPreviewTextInput"></TextBox>
<ScrollViewer Grid.Row="1">
<TextBlock Name="tb"></TextBlock>
</ScrollViewer>
</Grid>
</Window>
16 changes: 16 additions & 0 deletions Integrated Presenter/HyperDeckMonitorWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@

namespace Integrated_Presenter
{

public delegate void TextCommandEvent(object sender, string cmd);

/// <summary>
/// Interaction logic for HyperDeckMonitorWindow.xaml
/// </summary>
public partial class HyperDeckMonitorWindow : Window
{

public event TextCommandEvent OnTextCommand;

public bool IsClosed { get; set; } = false;
public HyperDeckMonitorWindow()
{
Expand All @@ -36,5 +41,16 @@ private void OnClosed(object sender, EventArgs e)
{
IsClosed = true;
}

private void OnPreviewTextInput(object sender, TextCompositionEventArgs e)
{
if (e.Text.EndsWith('\r'))
{
// send command
string cmd = tbCmd.Text;
OnTextCommand?.Invoke(this, cmd);
tbCmd.Text = "";
}
}
}
}
6 changes: 3 additions & 3 deletions Integrated Presenter/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.ColumnSpan="2" TextAlignment="Center" Margin="0,5,0,0" Style="{StaticResource GrayText}">PROGRAM</TextBlock>
<Button Name="btnProgramLock" Click="ClickBtnProgramLock" Grid.Column="1" Width="100" HorizontalAlignment="Right" Focusable="False" IsTabStop="False">
<Button Name="btnProgramLock" Click="ClickBtnProgramLock" Grid.Column="1" Width="100" HorizontalAlignment="Right" Focusable="False" IsTabStop="False" Background="#2a2a2a" Foreground="Orange">
<Button.Content>LOCKED</Button.Content>
<Button.Template>
<ControlTemplate>
<Border Name="Border" Background="#1d1d1d" BorderBrush="Orange" Margin="3" BorderThickness="1">
<ContentControl Name="btnProgramLockName" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Orange" Content="{Binding Path=Content, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"></ContentControl>
<Border Name="Border" Background="#1d1d1d" BorderBrush="{TemplateBinding Foreground}" Margin="3" BorderThickness="1">
<ContentControl Name="btnProgramLockName" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="{TemplateBinding Foreground}" Content="{Binding Path=Content, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"></ContentControl>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
Expand Down
9 changes: 9 additions & 0 deletions Integrated Presenter/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,17 +1981,24 @@ private void OpenHyperdeckMonitorWindow(object sender, RoutedEventArgs e)
if (hyperDeckMonitorWindow == null)
{
hyperDeckMonitorWindow = new HyperDeckMonitorWindow();
hyperDeckMonitorWindow.OnTextCommand += HyperDeckMonitorWindow_OnTextCommand;
}
if (hyperDeckMonitorWindow.IsClosed)
{
hyperDeckMonitorWindow = new HyperDeckMonitorWindow();
hyperDeckMonitorWindow.OnTextCommand += HyperDeckMonitorWindow_OnTextCommand;
}

hyperDeckMonitorWindow.Show();




}

private void HyperDeckMonitorWindow_OnTextCommand(object sender, string cmd)
{
mHyperdeckManager?.Send(cmd);
}

private void ClickToggleRecording(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -2061,10 +2068,12 @@ private void UpdateProgramRowLockButtonUI()
if (IsProgramRowLocked)
{
btnProgramLock.Content = "LOCKED";
btnProgramLock.Foreground = Brushes.WhiteSmoke;
}
else
{
btnProgramLock.Content = "UNLOCKED";
btnProgramLock.Foreground = Brushes.Orange;
}
}

Expand Down
12 changes: 9 additions & 3 deletions VonEX/SlaveConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ public class SlaveConnection
public event StringDataRecievedEventArgs OnDataRecieved;
public event ConnectionEventArgs OnConnectionFromMaster;

public void Connect(string hostname, int port)
public async void Connect(string hostname, int port)
{
client = new TcpClient();
client.Connect(hostname, port);

try
{
await client.ConnectAsync(hostname, port);
}
catch (Exception ex)
{
return;
}
var constr = client.Client.RemoteEndPoint.ToString();
var addr = constr.Split(':')[0];
OnConnectionFromMaster?.Invoke(addr, true);
Expand Down

0 comments on commit 180629d

Please sign in to comment.