add extra options

This commit is contained in:
Jelle Luteijn 2024-06-04 11:28:44 +02:00
parent 75c557f565
commit 1e8e9f5c83
2 changed files with 176 additions and 110 deletions

View file

@ -28,110 +28,149 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.lbHosts = new System.Windows.Forms.ListBox(); this.lbHosts = new System.Windows.Forms.ListBox();
this.lblName = new System.Windows.Forms.Label(); this.lblName = new System.Windows.Forms.Label();
this.txtHostname = new System.Windows.Forms.TextBox(); this.txtHostname = new System.Windows.Forms.TextBox();
this.btnAdd = new System.Windows.Forms.Button(); this.btnAdd = new System.Windows.Forms.Button();
this.btnRemove = new System.Windows.Forms.Button(); this.btnRemove = new System.Windows.Forms.Button();
this.btnPause = new System.Windows.Forms.Button(); this.btnPause = new System.Windows.Forms.Button();
this.lblPassword = new System.Windows.Forms.Label(); this.lblPassword = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox(); this.txtPassword = new System.Windows.Forms.TextBox();
this.SuspendLayout(); this.btnStop = new System.Windows.Forms.Button();
// this.btnNext = new System.Windows.Forms.Button();
// lbHosts this.btnPrevious = new System.Windows.Forms.Button();
// this.SuspendLayout();
this.lbHosts.FormattingEnabled = true; //
this.lbHosts.Location = new System.Drawing.Point(13, 13); // lbHosts
this.lbHosts.Name = "lbHosts"; //
this.lbHosts.Size = new System.Drawing.Size(192, 95); this.lbHosts.FormattingEnabled = true;
this.lbHosts.TabIndex = 0; this.lbHosts.Location = new System.Drawing.Point(13, 13);
// this.lbHosts.Name = "lbHosts";
// lblName this.lbHosts.Size = new System.Drawing.Size(192, 95);
// this.lbHosts.TabIndex = 0;
this.lblName.AutoSize = true; //
this.lblName.Location = new System.Drawing.Point(13, 115); // lblName
this.lblName.Name = "lblName"; //
this.lblName.Size = new System.Drawing.Size(58, 13); this.lblName.AutoSize = true;
this.lblName.TabIndex = 1; this.lblName.Location = new System.Drawing.Point(13, 115);
this.lblName.Text = "Hostname:"; this.lblName.Name = "lblName";
// this.lblName.Size = new System.Drawing.Size(58, 13);
// txtHostname this.lblName.TabIndex = 1;
// this.lblName.Text = "Hostname:";
this.txtHostname.Location = new System.Drawing.Point(13, 132); //
this.txtHostname.Name = "txtHostname"; // txtHostname
this.txtHostname.Size = new System.Drawing.Size(192, 20); //
this.txtHostname.TabIndex = 2; this.txtHostname.Location = new System.Drawing.Point(13, 132);
this.txtHostname.Text = "localhost:8080"; this.txtHostname.Name = "txtHostname";
// this.txtHostname.Size = new System.Drawing.Size(192, 20);
// btnAdd this.txtHostname.TabIndex = 2;
// this.txtHostname.Text = "localhost:8080";
this.btnAdd.ForeColor = System.Drawing.SystemColors.ControlText; //
this.btnAdd.Location = new System.Drawing.Point(13, 158); // btnAdd
this.btnAdd.Name = "btnAdd"; //
this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnAdd.TabIndex = 3; this.btnAdd.Location = new System.Drawing.Point(13, 158);
this.btnAdd.Text = "Add"; this.btnAdd.Name = "btnAdd";
this.btnAdd.UseVisualStyleBackColor = true; this.btnAdd.Size = new System.Drawing.Size(75, 23);
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); this.btnAdd.TabIndex = 3;
// this.btnAdd.Text = "Add";
// btnRemove this.btnAdd.UseVisualStyleBackColor = true;
// this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
this.btnRemove.ForeColor = System.Drawing.SystemColors.ControlText; //
this.btnRemove.Location = new System.Drawing.Point(130, 158); // btnRemove
this.btnRemove.Name = "btnRemove"; //
this.btnRemove.Size = new System.Drawing.Size(75, 23); this.btnRemove.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnRemove.TabIndex = 4; this.btnRemove.Location = new System.Drawing.Point(130, 158);
this.btnRemove.Text = "Remove"; this.btnRemove.Name = "btnRemove";
this.btnRemove.UseVisualStyleBackColor = true; this.btnRemove.Size = new System.Drawing.Size(75, 23);
this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click); this.btnRemove.TabIndex = 4;
// this.btnRemove.Text = "Remove";
// btnPause this.btnRemove.UseVisualStyleBackColor = true;
// this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
this.btnPause.ForeColor = System.Drawing.SystemColors.ControlText; //
this.btnPause.Location = new System.Drawing.Point(13, 266); // btnPause
this.btnPause.Name = "btnPause"; //
this.btnPause.Size = new System.Drawing.Size(192, 23); this.btnPause.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnPause.TabIndex = 5; this.btnPause.Location = new System.Drawing.Point(13, 266);
this.btnPause.Text = "Pause / Unpause"; this.btnPause.Name = "btnPause";
this.btnPause.UseVisualStyleBackColor = true; this.btnPause.Size = new System.Drawing.Size(192, 23);
this.btnPause.Click += new System.EventHandler(this.btnPause_Click); this.btnPause.TabIndex = 5;
// this.btnPause.Text = "Pause / Unpause";
// lblPassword this.btnPause.UseVisualStyleBackColor = true;
// this.btnPause.Click += new System.EventHandler(this.btnPause_Click);
this.lblPassword.AutoSize = true; //
this.lblPassword.Location = new System.Drawing.Point(16, 188); // lblPassword
this.lblPassword.Name = "lblPassword"; //
this.lblPassword.Size = new System.Drawing.Size(56, 13); this.lblPassword.AutoSize = true;
this.lblPassword.TabIndex = 6; this.lblPassword.Location = new System.Drawing.Point(16, 188);
this.lblPassword.Text = "Password:"; this.lblPassword.Name = "lblPassword";
// this.lblPassword.Size = new System.Drawing.Size(56, 13);
// txtPassword this.lblPassword.TabIndex = 6;
// this.lblPassword.Text = "Password:";
this.txtPassword.Location = new System.Drawing.Point(13, 205); //
this.txtPassword.Name = "txtPassword"; // txtPassword
this.txtPassword.Size = new System.Drawing.Size(192, 20); //
this.txtPassword.TabIndex = 7; this.txtPassword.Location = new System.Drawing.Point(13, 205);
this.txtPassword.Text = "animecon"; this.txtPassword.Name = "txtPassword";
// this.txtPassword.Size = new System.Drawing.Size(192, 20);
// Form1 this.txtPassword.TabIndex = 7;
// this.txtPassword.Text = "animecon";
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; // btnStop
this.BackColor = System.Drawing.SystemColors.ControlText; //
this.ClientSize = new System.Drawing.Size(216, 312); this.btnStop.ForeColor = System.Drawing.SystemColors.ControlText;
this.Controls.Add(this.txtPassword); this.btnStop.Location = new System.Drawing.Point(12, 291);
this.Controls.Add(this.lblPassword); this.btnStop.Name = "btnStop";
this.Controls.Add(this.btnPause); this.btnStop.Size = new System.Drawing.Size(192, 23);
this.Controls.Add(this.btnRemove); this.btnStop.TabIndex = 8;
this.Controls.Add(this.btnAdd); this.btnStop.Text = "Stop";
this.Controls.Add(this.txtHostname); this.btnStop.UseVisualStyleBackColor = true;
this.Controls.Add(this.lblName); this.btnStop.Click += new System.EventHandler(this.btnStop_Click);
this.Controls.Add(this.lbHosts); //
this.ForeColor = System.Drawing.SystemColors.ControlLight; // btnNext
this.Name = "Form1"; //
this.Text = "Starter"; this.btnNext.ForeColor = System.Drawing.SystemColors.ControlText;
this.ResumeLayout(false); this.btnNext.Location = new System.Drawing.Point(109, 237);
this.PerformLayout(); this.btnNext.Name = "btnNext";
this.btnNext.Size = new System.Drawing.Size(96, 23);
this.btnNext.TabIndex = 9;
this.btnNext.Text = "Next";
this.btnNext.UseVisualStyleBackColor = true;
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
//
// btnPrevious
//
this.btnPrevious.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnPrevious.Location = new System.Drawing.Point(12, 237);
this.btnPrevious.Name = "btnPrevious";
this.btnPrevious.Size = new System.Drawing.Size(96, 23);
this.btnPrevious.TabIndex = 10;
this.btnPrevious.Text = "Previous";
this.btnPrevious.UseVisualStyleBackColor = true;
this.btnPrevious.Click += new System.EventHandler(this.btnPrevious_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ControlText;
this.ClientSize = new System.Drawing.Size(216, 326);
this.Controls.Add(this.btnPrevious);
this.Controls.Add(this.btnNext);
this.Controls.Add(this.btnStop);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.lblPassword);
this.Controls.Add(this.btnPause);
this.Controls.Add(this.btnRemove);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.txtHostname);
this.Controls.Add(this.lblName);
this.Controls.Add(this.lbHosts);
this.ForeColor = System.Drawing.SystemColors.ControlLight;
this.Name = "Form1";
this.Text = "Starter";
this.ResumeLayout(false);
this.PerformLayout();
} }
@ -145,6 +184,9 @@
private System.Windows.Forms.Button btnPause; private System.Windows.Forms.Button btnPause;
private System.Windows.Forms.Label lblPassword; private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox txtPassword; private System.Windows.Forms.TextBox txtPassword;
} private System.Windows.Forms.Button btnStop;
private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button btnPrevious;
}
} }

View file

@ -33,11 +33,35 @@ namespace AnimeCon.Vlc.Starter
{ {
foreach (var item in lbHosts.Items) foreach (var item in lbHosts.Items)
{ {
DoWebRequestAsync(item.ToString()); DoWebRequestAsync(item.ToString(), "pl_pause");
} }
} }
private async Task DoWebRequestAsync(string hostname) private void btnStop_Click(object sender, EventArgs e)
{
foreach (var item in lbHosts.Items)
{
DoWebRequestAsync(item.ToString(), "pl_stop");
}
}
private void btnPrevious_Click(object sender, EventArgs e)
{
foreach (var item in lbHosts.Items)
{
DoWebRequestAsync(item.ToString(), "pl_previous");
}
}
private void btnNext_Click(object sender, EventArgs e)
{
foreach (var item in lbHosts.Items)
{
DoWebRequestAsync(item.ToString(), "pl_next");
}
}
private async Task DoWebRequestAsync(string hostname, string command)
{ {
using (HttpClient httpClient = new HttpClient()) using (HttpClient httpClient = new HttpClient())
{ {
@ -50,7 +74,7 @@ namespace AnimeCon.Vlc.Starter
try try
{ {
// Make a GET request to the remote XML file // Make a GET request to the remote XML file
HttpResponseMessage response = await httpClient.GetAsync($"http://{hostname}/requests/status.xml?command=pl_pause"); HttpResponseMessage response = await httpClient.GetAsync($"http://{hostname}/requests/status.xml?command={command}");
// Ensure the request was successful // Ensure the request was successful
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
@ -65,5 +89,5 @@ namespace AnimeCon.Vlc.Starter
} }
} }
} }
} }
} }