From 75c557f565f9aa4d82ee97ff0d480483e5279363 Mon Sep 17 00:00:00 2001 From: Jelle Luteijn Date: Sat, 30 Mar 2024 21:41:30 +0100 Subject: [PATCH] add starter application --- .../AnimeCon.Vlc.Starter.csproj | 83 ++++++++++ AnimeCon.Vlc.Starter/App.config | 6 + AnimeCon.Vlc.Starter/Form1.Designer.cs | 150 ++++++++++++++++++ AnimeCon.Vlc.Starter/Form1.cs | 69 ++++++++ AnimeCon.Vlc.Starter/Form1.resx | 120 ++++++++++++++ AnimeCon.Vlc.Starter/Program.cs | 22 +++ .../Properties/AssemblyInfo.cs | 36 +++++ .../Properties/Resources.Designer.cs | 71 +++++++++ .../Properties/Resources.resx | 117 ++++++++++++++ .../Properties/Settings.Designer.cs | 30 ++++ .../Properties/Settings.settings | 7 + AnimeCon.Vlc.sln | 6 + 12 files changed, 717 insertions(+) create mode 100644 AnimeCon.Vlc.Starter/AnimeCon.Vlc.Starter.csproj create mode 100644 AnimeCon.Vlc.Starter/App.config create mode 100644 AnimeCon.Vlc.Starter/Form1.Designer.cs create mode 100644 AnimeCon.Vlc.Starter/Form1.cs create mode 100644 AnimeCon.Vlc.Starter/Form1.resx create mode 100644 AnimeCon.Vlc.Starter/Program.cs create mode 100644 AnimeCon.Vlc.Starter/Properties/AssemblyInfo.cs create mode 100644 AnimeCon.Vlc.Starter/Properties/Resources.Designer.cs create mode 100644 AnimeCon.Vlc.Starter/Properties/Resources.resx create mode 100644 AnimeCon.Vlc.Starter/Properties/Settings.Designer.cs create mode 100644 AnimeCon.Vlc.Starter/Properties/Settings.settings diff --git a/AnimeCon.Vlc.Starter/AnimeCon.Vlc.Starter.csproj b/AnimeCon.Vlc.Starter/AnimeCon.Vlc.Starter.csproj new file mode 100644 index 0000000..2859a14 --- /dev/null +++ b/AnimeCon.Vlc.Starter/AnimeCon.Vlc.Starter.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {6360085E-98D9-454C-AF86-66E472819D37} + WinExe + AnimeCon.Vlc.Starter + AnimeCon.Vlc.Starter + v4.8.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + Form1.cs + + + + + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/AnimeCon.Vlc.Starter/App.config b/AnimeCon.Vlc.Starter/App.config new file mode 100644 index 0000000..aee9adf --- /dev/null +++ b/AnimeCon.Vlc.Starter/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AnimeCon.Vlc.Starter/Form1.Designer.cs b/AnimeCon.Vlc.Starter/Form1.Designer.cs new file mode 100644 index 0000000..94c8da3 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Form1.Designer.cs @@ -0,0 +1,150 @@ +namespace AnimeCon.Vlc.Starter +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lbHosts = new System.Windows.Forms.ListBox(); + this.lblName = new System.Windows.Forms.Label(); + this.txtHostname = new System.Windows.Forms.TextBox(); + this.btnAdd = new System.Windows.Forms.Button(); + this.btnRemove = new System.Windows.Forms.Button(); + this.btnPause = new System.Windows.Forms.Button(); + this.lblPassword = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // lbHosts + // + this.lbHosts.FormattingEnabled = true; + this.lbHosts.Location = new System.Drawing.Point(13, 13); + this.lbHosts.Name = "lbHosts"; + this.lbHosts.Size = new System.Drawing.Size(192, 95); + this.lbHosts.TabIndex = 0; + // + // lblName + // + this.lblName.AutoSize = true; + this.lblName.Location = new System.Drawing.Point(13, 115); + this.lblName.Name = "lblName"; + this.lblName.Size = new System.Drawing.Size(58, 13); + this.lblName.TabIndex = 1; + this.lblName.Text = "Hostname:"; + // + // txtHostname + // + this.txtHostname.Location = new System.Drawing.Point(13, 132); + this.txtHostname.Name = "txtHostname"; + this.txtHostname.Size = new System.Drawing.Size(192, 20); + this.txtHostname.TabIndex = 2; + this.txtHostname.Text = "localhost:8080"; + // + // btnAdd + // + this.btnAdd.ForeColor = System.Drawing.SystemColors.ControlText; + this.btnAdd.Location = new System.Drawing.Point(13, 158); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(75, 23); + this.btnAdd.TabIndex = 3; + this.btnAdd.Text = "Add"; + this.btnAdd.UseVisualStyleBackColor = true; + this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click); + // + // btnRemove + // + this.btnRemove.ForeColor = System.Drawing.SystemColors.ControlText; + this.btnRemove.Location = new System.Drawing.Point(130, 158); + this.btnRemove.Name = "btnRemove"; + this.btnRemove.Size = new System.Drawing.Size(75, 23); + this.btnRemove.TabIndex = 4; + this.btnRemove.Text = "Remove"; + this.btnRemove.UseVisualStyleBackColor = true; + this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click); + // + // btnPause + // + this.btnPause.ForeColor = System.Drawing.SystemColors.ControlText; + this.btnPause.Location = new System.Drawing.Point(13, 266); + this.btnPause.Name = "btnPause"; + this.btnPause.Size = new System.Drawing.Size(192, 23); + this.btnPause.TabIndex = 5; + this.btnPause.Text = "Pause / Unpause"; + this.btnPause.UseVisualStyleBackColor = true; + this.btnPause.Click += new System.EventHandler(this.btnPause_Click); + // + // lblPassword + // + this.lblPassword.AutoSize = true; + this.lblPassword.Location = new System.Drawing.Point(16, 188); + this.lblPassword.Name = "lblPassword"; + this.lblPassword.Size = new System.Drawing.Size(56, 13); + this.lblPassword.TabIndex = 6; + this.lblPassword.Text = "Password:"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(13, 205); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.Size = new System.Drawing.Size(192, 20); + this.txtPassword.TabIndex = 7; + this.txtPassword.Text = "animecon"; + // + // 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, 312); + 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(); + + } + + #endregion + + private System.Windows.Forms.ListBox lbHosts; + private System.Windows.Forms.Label lblName; + private System.Windows.Forms.TextBox txtHostname; + private System.Windows.Forms.Button btnAdd; + private System.Windows.Forms.Button btnRemove; + private System.Windows.Forms.Button btnPause; + private System.Windows.Forms.Label lblPassword; + private System.Windows.Forms.TextBox txtPassword; + } +} + diff --git a/AnimeCon.Vlc.Starter/Form1.cs b/AnimeCon.Vlc.Starter/Form1.cs new file mode 100644 index 0000000..9982e78 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Form1.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Net.Http.Headers; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AnimeCon.Vlc.Starter +{ + public partial class Form1 : Form + { + public Form1() + { + InitializeComponent(); + } + + private void btnAdd_Click(object sender, EventArgs e) + { + lbHosts.Items.Add(txtHostname.Text); + } + + private void btnRemove_Click(object sender, EventArgs e) + { + lbHosts.Items.Remove(lbHosts.SelectedItems[lbHosts.SelectedIndex]); + } + + private void btnPause_Click(object sender, EventArgs e) + { + foreach (var item in lbHosts.Items) + { + DoWebRequestAsync(item.ToString()); + } + } + + private async Task DoWebRequestAsync(string hostname) + { + using (HttpClient httpClient = new HttpClient()) + { + // Convert the credentials to Base64 + string base64Credentials = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes($":{txtPassword.Text}")); + + // Add Authorization header with Basic Authentication + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64Credentials); + + try + { + // Make a GET request to the remote XML file + HttpResponseMessage response = await httpClient.GetAsync($"http://{hostname}/requests/status.xml?command=pl_pause"); + + // Ensure the request was successful + response.EnsureSuccessStatusCode(); + + return; + } + catch (Exception ex) + { + // Handle exception + Console.WriteLine($"Error: {ex.Message}"); + throw; + } + } + } + } +} diff --git a/AnimeCon.Vlc.Starter/Form1.resx b/AnimeCon.Vlc.Starter/Form1.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/AnimeCon.Vlc.Starter/Program.cs b/AnimeCon.Vlc.Starter/Program.cs new file mode 100644 index 0000000..8d4a397 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace AnimeCon.Vlc.Starter +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } +} diff --git a/AnimeCon.Vlc.Starter/Properties/AssemblyInfo.cs b/AnimeCon.Vlc.Starter/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9a72189 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AnimeCon.Vlc.Starter")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AnimeCon.Vlc.Starter")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6360085e-98d9-454c-af86-66e472819d37")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AnimeCon.Vlc.Starter/Properties/Resources.Designer.cs b/AnimeCon.Vlc.Starter/Properties/Resources.Designer.cs new file mode 100644 index 0000000..7a66686 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AnimeCon.Vlc.Starter.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AnimeCon.Vlc.Starter.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/AnimeCon.Vlc.Starter/Properties/Resources.resx b/AnimeCon.Vlc.Starter/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/AnimeCon.Vlc.Starter/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/AnimeCon.Vlc.Starter/Properties/Settings.Designer.cs b/AnimeCon.Vlc.Starter/Properties/Settings.Designer.cs new file mode 100644 index 0000000..c425aa2 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AnimeCon.Vlc.Starter.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/AnimeCon.Vlc.Starter/Properties/Settings.settings b/AnimeCon.Vlc.Starter/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/AnimeCon.Vlc.Starter/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/AnimeCon.Vlc.sln b/AnimeCon.Vlc.sln index 54ee91d..9c5354a 100644 --- a/AnimeCon.Vlc.sln +++ b/AnimeCon.Vlc.sln @@ -5,6 +5,8 @@ VisualStudioVersion = 17.8.34322.80 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimeCon.Vlc.Scraper", "AnimeCon.Vlc.Scraper\AnimeCon.Vlc.Scraper.csproj", "{C0F21F3B-96DD-44FA-997C-7350C7348250}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimeCon.Vlc.Starter", "AnimeCon.Vlc.Starter\AnimeCon.Vlc.Starter.csproj", "{6360085E-98D9-454C-AF86-66E472819D37}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +17,10 @@ Global {C0F21F3B-96DD-44FA-997C-7350C7348250}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0F21F3B-96DD-44FA-997C-7350C7348250}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0F21F3B-96DD-44FA-997C-7350C7348250}.Release|Any CPU.Build.0 = Release|Any CPU + {6360085E-98D9-454C-AF86-66E472819D37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6360085E-98D9-454C-AF86-66E472819D37}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6360085E-98D9-454C-AF86-66E472819D37}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6360085E-98D9-454C-AF86-66E472819D37}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE