From b3c5c52965c3f0a7212b4f4fc37d94b0794d9550 Mon Sep 17 00:00:00 2001 From: Erick Kinnee Date: Thu, 7 Mar 2019 07:25:09 -0600 Subject: [PATCH] Add console based test app. Changeup on namespaces. Experimenting with events. --- SharpCAT.sln | 6 ++ SharpCAT/SharpCAT.cs | 22 ++++- SharpCATConsole/App.config | 6 ++ SharpCATConsole/Program.cs | 24 ++++++ SharpCATConsole/Properties/AssemblyInfo.cs | 36 ++++++++ SharpCATConsole/SharpCATConsole.csproj | 63 ++++++++++++++ .../packages.config | 0 SharpCATForms/Form1.Designer.cs | 84 +++++++++++++++---- SharpCATForms/Form1.cs | 2 +- SharpCATForms/SharpCATForms.csproj | 4 - 10 files changed, 227 insertions(+), 20 deletions(-) create mode 100644 SharpCATConsole/App.config create mode 100644 SharpCATConsole/Program.cs create mode 100644 SharpCATConsole/Properties/AssemblyInfo.cs create mode 100644 SharpCATConsole/SharpCATConsole.csproj rename {SharpCATForms => SharpCATConsole}/packages.config (100%) diff --git a/SharpCAT.sln b/SharpCAT.sln index 7f838cf..6233c7a 100644 --- a/SharpCAT.sln +++ b/SharpCAT.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCATForms", "SharpCATFo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpCATLib", "SharpCAT\SharpCATLib.csproj", "{DAD3E7BE-905A-4768-A695-0BCF96171E35}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpCATConsole", "SharpCATConsole\SharpCATConsole.csproj", "{C0C9250E-EFCE-4F8F-8249-345647440EB9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {DAD3E7BE-905A-4768-A695-0BCF96171E35}.Debug|Any CPU.Build.0 = Debug|Any CPU {DAD3E7BE-905A-4768-A695-0BCF96171E35}.Release|Any CPU.ActiveCfg = Release|Any CPU {DAD3E7BE-905A-4768-A695-0BCF96171E35}.Release|Any CPU.Build.0 = Release|Any CPU + {C0C9250E-EFCE-4F8F-8249-345647440EB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C0C9250E-EFCE-4F8F-8249-345647440EB9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C0C9250E-EFCE-4F8F-8249-345647440EB9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C0C9250E-EFCE-4F8F-8249-345647440EB9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SharpCAT/SharpCAT.cs b/SharpCAT/SharpCAT.cs index dd8dc20..aeb532f 100644 --- a/SharpCAT/SharpCAT.cs +++ b/SharpCAT/SharpCAT.cs @@ -1,9 +1,26 @@ -using System.IO.Ports; +using System; +using System.IO.Ports; namespace SharpCATLib { public class SharpCAT { + public SharpCAT() + { + PortsSelected += new EventHandler(OnPortsSelected); + } + + public event EventHandler PortsSelected; + public void OnSetPortsToUse() + { + PortsSelected?.Invoke(this, EventArgs.Empty); + } + + private void OnPortsSelected(object s, EventArgs e) + { + //Init and start the serial ports selected. + } + public double[] CTCSSTones = { 67.0, 69.3, 71.9, 74.4, 77.0, 79.7, 82.5, 85.4, 88.5, 91.5, 94.8, 97.4, 100.0, 103.5, 107.2, 110.9, 114.8, 118.8, 123, 127.3, 131.8, 136.5, 141.3, 146.2, 151.4, 156.7, 162.2, 167.9, 173.8, 179.9, 186.2, 192.8, @@ -25,5 +42,8 @@ namespace SharpCATLib private readonly string CmdPad = "00000000"; + private SerialPort[] PortsToUse; + + } } \ No newline at end of file diff --git a/SharpCATConsole/App.config b/SharpCATConsole/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/SharpCATConsole/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SharpCATConsole/Program.cs b/SharpCATConsole/Program.cs new file mode 100644 index 0000000..f59ea6e --- /dev/null +++ b/SharpCATConsole/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SharpCATLib; + +namespace SharpCATConsole +{ + class Program + { + static void Main(string[] args) + { + SharpCAT sharpCAT = new SharpCAT(); + Console.WriteLine("Ports found: "); + foreach (var port in sharpCAT.PortNames) + { + Console.WriteLine(port); + } + + Console.ReadKey(); + } + } +} diff --git a/SharpCATConsole/Properties/AssemblyInfo.cs b/SharpCATConsole/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8adc79b --- /dev/null +++ b/SharpCATConsole/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("SharpCATConsole")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SharpCATConsole")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[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("c0c9250e-efce-4f8f-8249-345647440eb9")] + +// 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/SharpCATConsole/SharpCATConsole.csproj b/SharpCATConsole/SharpCATConsole.csproj new file mode 100644 index 0000000..65bd561 --- /dev/null +++ b/SharpCATConsole/SharpCATConsole.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {C0C9250E-EFCE-4F8F-8249-345647440EB9} + Exe + SharpCATConsole + SharpCATConsole + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + ..\packages\System.IO.Ports.4.5.0\lib\net461\System.IO.Ports.dll + + + + + + + + + + + + + + + + + + + {dad3e7be-905a-4768-a695-0bcf96171e35} + SharpCATLib + + + + \ No newline at end of file diff --git a/SharpCATForms/packages.config b/SharpCATConsole/packages.config similarity index 100% rename from SharpCATForms/packages.config rename to SharpCATConsole/packages.config diff --git a/SharpCATForms/Form1.Designer.cs b/SharpCATForms/Form1.Designer.cs index 70be0c9..c65228a 100644 --- a/SharpCATForms/Form1.Designer.cs +++ b/SharpCATForms/Form1.Designer.cs @@ -28,43 +28,99 @@ /// private void InitializeComponent() { - this.ComPorts = new System.Windows.Forms.ListBox(); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.ComPort1Tab = new System.Windows.Forms.TabPage(); + this.ComPort2Tab = new System.Windows.Forms.TabPage(); this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.ComPortListBox = new System.Windows.Forms.ListBox(); + this.tabControl1.SuspendLayout(); + this.ComPort1Tab.SuspendLayout(); + this.ComPort2Tab.SuspendLayout(); this.SuspendLayout(); // - // ComPorts + // tabControl1 // - this.ComPorts.FormattingEnabled = true; - this.ComPorts.Location = new System.Drawing.Point(229, 25); - this.ComPorts.Name = "ComPorts"; - this.ComPorts.Size = new System.Drawing.Size(120, 95); - this.ComPorts.TabIndex = 0; + this.tabControl1.Controls.Add(this.ComPort1Tab); + this.tabControl1.Controls.Add(this.ComPort2Tab); + this.tabControl1.Location = new System.Drawing.Point(12, 12); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(364, 410); + this.tabControl1.TabIndex = 0; + // + // ComPort1Tab + // + this.ComPort1Tab.Controls.Add(this.textBox1); + this.ComPort1Tab.Location = new System.Drawing.Point(4, 22); + this.ComPort1Tab.Name = "ComPort1Tab"; + this.ComPort1Tab.Padding = new System.Windows.Forms.Padding(3); + this.ComPort1Tab.Size = new System.Drawing.Size(356, 384); + this.ComPort1Tab.TabIndex = 0; + this.ComPort1Tab.Text = "Port 1"; + this.ComPort1Tab.UseVisualStyleBackColor = true; + // + // ComPort2Tab + // + this.ComPort2Tab.Controls.Add(this.textBox2); + this.ComPort2Tab.Location = new System.Drawing.Point(4, 22); + this.ComPort2Tab.Name = "ComPort2Tab"; + this.ComPort2Tab.Padding = new System.Windows.Forms.Padding(3); + this.ComPort2Tab.Size = new System.Drawing.Size(356, 384); + this.ComPort2Tab.TabIndex = 1; + this.ComPort2Tab.Text = "Port 2"; + this.ComPort2Tab.UseVisualStyleBackColor = true; // // textBox1 // - this.textBox1.Location = new System.Drawing.Point(98, 335); + this.textBox1.Location = new System.Drawing.Point(7, 7); + this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(100, 20); - this.textBox1.TabIndex = 1; + this.textBox1.Size = new System.Drawing.Size(340, 371); + this.textBox1.TabIndex = 0; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(7, 7); + this.textBox2.Multiline = true; + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(340, 371); + this.textBox2.TabIndex = 1; + // + // ComPortListBox + // + this.ComPortListBox.FormattingEnabled = true; + this.ComPortListBox.Location = new System.Drawing.Point(462, 48); + this.ComPortListBox.Name = "ComPortListBox"; + this.ComPortListBox.Size = new System.Drawing.Size(120, 95); + this.ComPortListBox.TabIndex = 1; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.textBox1); - this.Controls.Add(this.ComPorts); + this.Controls.Add(this.ComPortListBox); + this.Controls.Add(this.tabControl1); this.Name = "Form1"; this.Text = "Form1"; + this.tabControl1.ResumeLayout(false); + this.ComPort1Tab.ResumeLayout(false); + this.ComPort1Tab.PerformLayout(); + this.ComPort2Tab.ResumeLayout(false); + this.ComPort2Tab.PerformLayout(); this.ResumeLayout(false); - this.PerformLayout(); } #endregion - private System.Windows.Forms.ListBox ComPorts; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage ComPort1Tab; private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TabPage ComPort2Tab; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.ListBox ComPortListBox; } } diff --git a/SharpCATForms/Form1.cs b/SharpCATForms/Form1.cs index 18992de..b24ac0e 100644 --- a/SharpCATForms/Form1.cs +++ b/SharpCATForms/Form1.cs @@ -11,7 +11,7 @@ namespace SharpCATForms InitializeComponent(); - ComPorts.DataSource = sharpCAT.PortNames; + ComPortListBox.DataSource = sharpCAT.PortNames; } } } \ No newline at end of file diff --git a/SharpCATForms/SharpCATForms.csproj b/SharpCATForms/SharpCATForms.csproj index 0f8cc36..bbad6ca 100644 --- a/SharpCATForms/SharpCATForms.csproj +++ b/SharpCATForms/SharpCATForms.csproj @@ -40,9 +40,6 @@ - - ..\packages\System.IO.Ports.4.5.0\lib\net461\System.IO.Ports.dll - @@ -74,7 +71,6 @@ True Resources.resx - SettingsSingleFileGenerator Settings.Designer.cs