diff --git a/USB_Relay_Control.sln b/USB_Relay_Control.sln new file mode 100644 index 0000000..c491c35 --- /dev/null +++ b/USB_Relay_Control.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "USB_Relay_Control", "USB_Relay_Control\USB_Relay_Control.csproj", "{42149B00-ABEA-4E10-9591-D4E6774C7860}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Debug|x86.ActiveCfg = Debug|x86 + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Debug|x86.Build.0 = Debug|x86 + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Release|Any CPU.Build.0 = Release|Any CPU + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Release|x86.ActiveCfg = Release|x86 + {42149B00-ABEA-4E10-9591-D4E6774C7860}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/USB_Relay_Control/App.config b/USB_Relay_Control/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/USB_Relay_Control/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/USB_Relay_Control/Form1.Designer.cs b/USB_Relay_Control/Form1.Designer.cs new file mode 100644 index 0000000..337d559 --- /dev/null +++ b/USB_Relay_Control/Form1.Designer.cs @@ -0,0 +1,190 @@ +namespace USB_Relay_Control +{ + 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.listBox1 = new System.Windows.Forms.ListBox(); + this.label2 = new System.Windows.Forms.Label(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button5 = new System.Windows.Forms.Button(); + this.button6 = new System.Windows.Forms.Button(); + this.button7 = new System.Windows.Forms.Button(); + this.button8 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // listBox1 + // + this.listBox1.FormattingEnabled = true; + this.listBox1.Location = new System.Drawing.Point(14, 25); + this.listBox1.Name = "listBox1"; + this.listBox1.Size = new System.Drawing.Size(169, 95); + this.listBox1.TabIndex = 1; + this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(12, 9); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(52, 13); + this.label2.TabIndex = 5; + this.label2.Text = "Devices :"; + // + // button1 + // + this.button1.Enabled = false; + this.button1.Location = new System.Drawing.Point(14, 126); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(169, 23); + this.button1.TabIndex = 11; + this.button1.Text = "Relay 1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button_Click); + // + // button2 + // + this.button2.Enabled = false; + this.button2.Location = new System.Drawing.Point(14, 155); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(169, 23); + this.button2.TabIndex = 12; + this.button2.Text = "Relay 2"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button_Click); + // + // button3 + // + this.button3.Enabled = false; + this.button3.Location = new System.Drawing.Point(14, 184); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(169, 23); + this.button3.TabIndex = 13; + this.button3.Text = "Relay 3"; + this.button3.UseVisualStyleBackColor = true; + this.button3.Click += new System.EventHandler(this.button_Click); + // + // button4 + // + this.button4.Enabled = false; + this.button4.Location = new System.Drawing.Point(15, 213); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(169, 23); + this.button4.TabIndex = 14; + this.button4.Text = "Relay 4"; + this.button4.UseVisualStyleBackColor = true; + this.button4.Click += new System.EventHandler(this.button_Click); + // + // button5 + // + this.button5.Enabled = false; + this.button5.Location = new System.Drawing.Point(15, 242); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(169, 23); + this.button5.TabIndex = 15; + this.button5.Text = "Relay 5"; + this.button5.UseVisualStyleBackColor = true; + this.button5.Click += new System.EventHandler(this.button_Click); + // + // button6 + // + this.button6.Enabled = false; + this.button6.Location = new System.Drawing.Point(15, 271); + this.button6.Name = "button6"; + this.button6.Size = new System.Drawing.Size(169, 23); + this.button6.TabIndex = 16; + this.button6.Text = "Relay 6"; + this.button6.UseVisualStyleBackColor = true; + this.button6.Click += new System.EventHandler(this.button_Click); + // + // button7 + // + this.button7.Enabled = false; + this.button7.Location = new System.Drawing.Point(15, 300); + this.button7.Name = "button7"; + this.button7.Size = new System.Drawing.Size(169, 23); + this.button7.TabIndex = 17; + this.button7.Text = "Relay 7"; + this.button7.UseVisualStyleBackColor = true; + this.button7.Click += new System.EventHandler(this.button_Click); + // + // button8 + // + this.button8.Enabled = false; + this.button8.Location = new System.Drawing.Point(15, 329); + this.button8.Name = "button8"; + this.button8.Size = new System.Drawing.Size(169, 23); + this.button8.TabIndex = 18; + this.button8.Text = "Relay 8"; + this.button8.UseVisualStyleBackColor = true; + this.button8.Click += new System.EventHandler(this.button_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(195, 364); + this.Controls.Add(this.button8); + this.Controls.Add(this.button7); + this.Controls.Add(this.button6); + this.Controls.Add(this.button5); + this.Controls.Add(this.button4); + this.Controls.Add(this.button3); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.label2); + this.Controls.Add(this.listBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "Form1"; + this.Text = "USB Relay"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.ListBox listBox1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button6; + private System.Windows.Forms.Button button7; + private System.Windows.Forms.Button button8; + + } +} + diff --git a/USB_Relay_Control/Form1.cs b/USB_Relay_Control/Form1.cs new file mode 100644 index 0000000..99985ce --- /dev/null +++ b/USB_Relay_Control/Form1.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace USB_Relay_Control +{ + + public partial class Form1 : Form + { + int _deviceHandle = 0; + List