Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Add Macro Tabpage with 5 custom macros with shortcut #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/CasparCGFrontend/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="CasparCGFrontend.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="CasparCGFrontend.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<CasparCGFrontend.Properties.Settings>
Expand All @@ -15,4 +18,23 @@
</setting>
</CasparCGFrontend.Properties.Settings>
</applicationSettings>
<userSettings>
<CasparCGFrontend.Properties.Settings>
<setting name="Macro1" serializeAs="String">
<value />
</setting>
<setting name="Macro2" serializeAs="String">
<value />
</setting>
<setting name="Macro3" serializeAs="String">
<value />
</setting>
<setting name="Macro4" serializeAs="String">
<value />
</setting>
<setting name="Macro5" serializeAs="String">
<value />
</setting>
</CasparCGFrontend.Properties.Settings>
</userSettings>
</configuration>
1 change: 1 addition & 0 deletions src/CasparCGFrontend/CasparCGFrontend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
<ItemGroup>
<Content Include="CasparCG.ico" />
<Content Include="configdoc.txt" />
<None Include="Resources\Macro.png" />
<None Include="Resources\Log.png" />
<None Include="Resources\Disconnection.png" />
<None Include="Resources\Status.png" />
Expand Down
415 changes: 373 additions & 42 deletions src/CasparCGFrontend/MainForm.Designer.cs

Large diffs are not rendered by default.

112 changes: 111 additions & 1 deletion src/CasparCGFrontend/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ public MainForm()
this.Text += " " + Settings.Default.Version;

this.tabControl.SelectedTab = this.tabPageStatus;

this.InitializeMacros();
}

private void InitializeMacros()
{
textBoxMacro1.Text = Settings.Default.Macro1;
textBoxMacro2.Text = Settings.Default.Macro2;
textBoxMacro3.Text = Settings.Default.Macro3;
textBoxMacro4.Text = Settings.Default.Macro4;
textBoxMacro5.Text = Settings.Default.Macro5;
}

private void MainForm_Load(object sender, EventArgs e)
Expand All @@ -78,6 +89,7 @@ private void DockControls()
this.panelChannels.Dock = DockStyle.Fill;
this.panelAdvanced.Dock = DockStyle.Fill;
this.panelConsole.Dock = DockStyle.Fill;
this.panelMacro.Dock = DockStyle.Fill;
}

private bool ProcessExists(string name)
Expand Down Expand Up @@ -521,6 +533,11 @@ private void buttonConsole_Click(object sender, EventArgs e)
this.textBoxCommand.Focus();
}

private void buttonMacro_Click(object sender, EventArgs e)
{
this.tabControl.SelectedTab = this.tabPageMacro;
}

private void quitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
Expand Down Expand Up @@ -566,7 +583,8 @@ private void textBoxCommand_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
ExecuteCommand();
if (!this.textBoxCommand.Text.Equals("exit") && !this.textBoxCommand.Text.Equals("q") && !this.textBoxCommand.Text.Equals("quit") && !this.textBoxCommand.Text.Equals("bye"))
ExecuteCommand();

this.textBoxCommand.Clear();
}
Expand Down Expand Up @@ -616,5 +634,97 @@ private void listBox4_Click(object sender, EventArgs e)
}
}

private void ExecuteCommand(string sMultilineText)
{
string[] allLines = sMultilineText.Replace("\r", "").Split('\n');
foreach (string text in allLines)
{
try
{
if (string.IsNullOrEmpty(text))
System.Threading.Thread.Sleep(40);
else
this.process.StandardInput.Write(string.Format("{0}\r\n", text));
}
catch (Exception ex) { }
}
}

private void buttonMacro1_Click(object sender, EventArgs e)
{
ExecuteCommand(textBoxMacro1.Text);
}

private void buttonMacro2_Click(object sender, EventArgs e)
{
ExecuteCommand(textBoxMacro2.Text);
}

private void buttonMacro3_Click(object sender, EventArgs e)
{
ExecuteCommand(textBoxMacro3.Text);
}

private void buttonMacro4_Click(object sender, EventArgs e)
{
ExecuteCommand(textBoxMacro4.Text);
}

private void buttonMacro5_Click(object sender, EventArgs e)
{
ExecuteCommand(textBoxMacro5.Text);
}

private void buttonMacroSave_Click(object sender, EventArgs e)
{
Settings.Default.Macro1 = textBoxMacro1.Text;
Settings.Default.Macro2 = textBoxMacro2.Text;
Settings.Default.Macro3 = textBoxMacro3.Text;
Settings.Default.Macro4 = textBoxMacro4.Text;
Settings.Default.Macro5 = textBoxMacro5.Text;
Settings.Default.Save();
}

private void buttonMacroRestore_Click(object sender, EventArgs e)
{
this.InitializeMacros();
}

private void buttonMacroReset_Click(object sender, EventArgs e)
{
textBoxMacro1.Text = "";
textBoxMacro2.Text = "";
textBoxMacro3.Text = "";
textBoxMacro4.Text = "";
textBoxMacro5.Text = "";
}

private void MainForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F1)
{
ExecuteCommand(textBoxMacro1.Text);
}
else
if (e.KeyCode == Keys.F2)
{
ExecuteCommand(textBoxMacro2.Text);
}
else
if (e.KeyCode == Keys.F3)
{
ExecuteCommand(textBoxMacro3.Text);
}
else
if (e.KeyCode == Keys.F4)
{
ExecuteCommand(textBoxMacro4.Text);
}
else
if (e.KeyCode == Keys.F5)
{
ExecuteCommand(textBoxMacro5.Text);
}
}
}
}
17 changes: 16 additions & 1 deletion src/CasparCGFrontend/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,21 @@
<metadata name="thumbnailspathLabel.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label48.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label47.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label46.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label31.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label45.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
Expand All @@ -230,7 +245,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACM
CQAAAk1TRnQBSQFMAwEBAAHYAQoB2AEKASABAAEgAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA
CQAAAk1TRnQBSQFMAwEBAAEIAQsBCAELASABAAEgAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA
AYADAAEgAwABAQEAAQgGAAEQGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA
AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA
AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm
Expand Down
45 changes: 18 additions & 27 deletions src/CasparCGFrontend/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/CasparCGFrontend/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,7 @@
<data name="Log" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Log.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Macro" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Macro.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading