From a3a0cc201bee4b5898d467e85048970a7eddbaeb Mon Sep 17 00:00:00 2001 From: syneffort Date: Thu, 5 Oct 2023 17:56:04 +0900 Subject: [PATCH] update --- .../TelnetSamples/AsyncSocketTelnetClient.cs | 71 ++-- .../TelnetSamples/AsyncStreamTelnetClient.cs | 5 +- .../TelnetSamples/AsyncTelnetConsole.cs | 20 +- .../TelnetSamples/IAsyncTelnetClient.cs | 1 + .../ConsoleApp/TelnetSamples/TelnetConsole.cs | 10 +- .../SerialComApp/SerialCommApp.Designer.cs | 388 +++++++++--------- MySolution/SerialComApp/SerialCommApp.resx | 28 +- 7 files changed, 279 insertions(+), 244 deletions(-) diff --git a/MySolution/ConsoleApp/TelnetSamples/AsyncSocketTelnetClient.cs b/MySolution/ConsoleApp/TelnetSamples/AsyncSocketTelnetClient.cs index 27dbb57..3c746d9 100644 --- a/MySolution/ConsoleApp/TelnetSamples/AsyncSocketTelnetClient.cs +++ b/MySolution/ConsoleApp/TelnetSamples/AsyncSocketTelnetClient.cs @@ -12,17 +12,18 @@ namespace ConsoleApp.TelnetSamples { internal class AsyncSocketTelnetClient : IAsyncTelnetClient { - private readonly CancellationTokenSource CTS = new CancellationTokenSource(); + private CancellationTokenSource _cts; public event EventHandler MessageCallback; + public event EventHandler ErrorCallback; - private Socket _socket; + private Socket _socket; public async void Connect(string ip, int port = 23) { try { - Close(); + //Close(); _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socket.ReceiveTimeout = 1000; @@ -31,28 +32,37 @@ namespace ConsoleApp.TelnetSamples IPEndPoint iPEndPoint = new IPEndPoint(ipAddress, port); await _socket.ConnectAsync(iPEndPoint); - Task.Run(ReadAsync); + _cts = new CancellationTokenSource(); + Task.Run(ReadAsync, _cts.Token); } - catch (Exception) + catch (Exception ex) { - throw; - } + if (this.ErrorCallback != null) + this.ErrorCallback(this, ex); + } } private async void ReadAsync() { try { - StringBuilder sb = new StringBuilder(); byte[] readBuffer = new byte[1024]; while (true) { - int bytesRead = await _socket.ReceiveAsync(readBuffer); - if (bytesRead < 1) + if (_cts != null && _cts.IsCancellationRequested) break; - string data = Encoding.ASCII.GetString(readBuffer, 0, bytesRead); + int bytesRead = _cts != null && _cts.IsCancellationRequested ? 0 : await _socket.ReceiveAsync(readBuffer); + if (bytesRead < 1) + { + if (sb.Length > 0 && this.MessageCallback != null) + this.MessageCallback(this, sb.ToString()); + + break; + } + + string data = Encoding.ASCII.GetString(readBuffer, 0, bytesRead); sb.Append(data); if (!data.EndsWith("\r\n>")) @@ -69,25 +79,31 @@ namespace ConsoleApp.TelnetSamples sb.Clear(); } } - catch (Exception) - { - throw; - } - } + catch (Exception ex) + { + if (this.ErrorCallback != null) + this.ErrorCallback(this, ex); + } + } public async void SendCommand(string command) { try { + command = command.Replace(" ", ""); + if (string.IsNullOrEmpty(command)) + return; + command += "\r\n"; byte[] sendBytes = Encoding.ASCII.GetBytes(command); await _socket.SendAsync(sendBytes); } - catch (Exception) - { - throw; - } - } + catch (Exception ex) + { + if (this.ErrorCallback != null) + this.ErrorCallback(this, ex); + } + } public void Close() { @@ -96,14 +112,17 @@ namespace ConsoleApp.TelnetSamples if (_socket == null) return; + _cts.Cancel(); + _socket.Shutdown(SocketShutdown.Both); _socket.Close(); _socket.Dispose(); } - catch (Exception) - { - throw; - } - } + catch (Exception ex) + { + if (this.ErrorCallback != null) + this.ErrorCallback(this, ex); + } + } } } diff --git a/MySolution/ConsoleApp/TelnetSamples/AsyncStreamTelnetClient.cs b/MySolution/ConsoleApp/TelnetSamples/AsyncStreamTelnetClient.cs index cbb0b78..c892133 100644 --- a/MySolution/ConsoleApp/TelnetSamples/AsyncStreamTelnetClient.cs +++ b/MySolution/ConsoleApp/TelnetSamples/AsyncStreamTelnetClient.cs @@ -7,11 +7,12 @@ using System.Threading.Tasks; namespace ConsoleApp.TelnetSamples { - internal class AsyncStreamTelnetClient : IAsyncTelnetClient + internal class AsyncStreamTelnetClient : IAsyncTelnetClient { public event EventHandler MessageCallback; + public event EventHandler ErrorCallback; - private TcpClient _client; + private TcpClient _client; private NetworkStream _stream; public async void Connect(string ip, int port = 23) diff --git a/MySolution/ConsoleApp/TelnetSamples/AsyncTelnetConsole.cs b/MySolution/ConsoleApp/TelnetSamples/AsyncTelnetConsole.cs index f677cd2..945d7b3 100644 --- a/MySolution/ConsoleApp/TelnetSamples/AsyncTelnetConsole.cs +++ b/MySolution/ConsoleApp/TelnetSamples/AsyncTelnetConsole.cs @@ -20,23 +20,33 @@ namespace ConsoleApp.TelnetSamples try { _client.MessageCallback += On_Receive; + _client.ErrorCallback += On_ErrorCallback; _client.Connect(ip, port); while (true) { - string command = Console.ReadLine(); + string command = Console.ReadLine().ToLower(); if (command == "quit" || command == "exit") break; - - _client.SendCommand(command); + else if (command == "disconnect" || command == "disconn") + _client.Close(); + else if (command == "connect" || command == "conn") + _client.Connect(ip, port); + else + _client.SendCommand(command); } } - catch (Exception) + catch (Exception ex) { - throw; + Console.WriteLine($"[ERR] {ex.Message}"); } } + private void On_ErrorCallback(object? sender, Exception e) + { + Console.WriteLine(e.Message); + } + private void On_Receive(object? sender, string e) { Console.Write(e); diff --git a/MySolution/ConsoleApp/TelnetSamples/IAsyncTelnetClient.cs b/MySolution/ConsoleApp/TelnetSamples/IAsyncTelnetClient.cs index e40ee0f..65e40db 100644 --- a/MySolution/ConsoleApp/TelnetSamples/IAsyncTelnetClient.cs +++ b/MySolution/ConsoleApp/TelnetSamples/IAsyncTelnetClient.cs @@ -9,6 +9,7 @@ namespace ConsoleApp.TelnetSamples public interface IAsyncTelnetClient { public event EventHandler MessageCallback; + public event EventHandler ErrorCallback; void Connect(string ip, int port = 23); void SendCommand(string command); diff --git a/MySolution/ConsoleApp/TelnetSamples/TelnetConsole.cs b/MySolution/ConsoleApp/TelnetSamples/TelnetConsole.cs index 92658b8..a49bddf 100644 --- a/MySolution/ConsoleApp/TelnetSamples/TelnetConsole.cs +++ b/MySolution/ConsoleApp/TelnetSamples/TelnetConsole.cs @@ -24,11 +24,15 @@ namespace ConsoleApp.TelnetSamples while (true) { - string command = Console.ReadLine(); + string command = Console.ReadLine().ToLower(); if (command == "quit" || command == "exit") break; - - Console.Write(_client.SendCommand(command)); + else if (command == "disconnect" || command == "disconn") + _client.Close(); + else if (command == "connect" || command == "conn") + _client.Connect(ip, port); + else + Console.Write(_client.SendCommand(command)); } } catch (Exception ex) diff --git a/MySolution/SerialComApp/SerialCommApp.Designer.cs b/MySolution/SerialComApp/SerialCommApp.Designer.cs index f54a431..b933481 100644 --- a/MySolution/SerialComApp/SerialCommApp.Designer.cs +++ b/MySolution/SerialComApp/SerialCommApp.Designer.cs @@ -28,200 +28,200 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SerialCommApp)); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); - this.connectButton = new System.Windows.Forms.Button(); - this.panel1 = new System.Windows.Forms.Panel(); - this.settingButton = new System.Windows.Forms.Button(); - this.label1 = new System.Windows.Forms.Label(); - this.portComboBox = new System.Windows.Forms.ComboBox(); - this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); - this.sendButton = new System.Windows.Forms.Button(); - this.commandText = new System.Windows.Forms.TextBox(); - this.printText = new System.Windows.Forms.TextBox(); - this.portRefreshButton = new System.Windows.Forms.Button(); - this.tableLayoutPanel1.SuspendLayout(); - this.tableLayoutPanel2.SuspendLayout(); - this.panel1.SuspendLayout(); - this.tableLayoutPanel3.SuspendLayout(); - this.SuspendLayout(); - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.BackColor = System.Drawing.Color.White; - this.tableLayoutPanel1.ColumnCount = 1; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.printText, 0, 1); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 3; - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(583, 679); - this.tableLayoutPanel1.TabIndex = 6; - // - // tableLayoutPanel2 - // - this.tableLayoutPanel2.BackColor = System.Drawing.Color.White; - this.tableLayoutPanel2.ColumnCount = 3; - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 350F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); - this.tableLayoutPanel2.Controls.Add(this.connectButton, 2, 0); - this.tableLayoutPanel2.Controls.Add(this.panel1, 0, 0); - this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 4); - this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.tableLayoutPanel2.Name = "tableLayoutPanel2"; - this.tableLayoutPanel2.RowCount = 1; - this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.Size = new System.Drawing.Size(577, 32); - this.tableLayoutPanel2.TabIndex = 6; - // - // connectButton - // - this.connectButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.connectButton.Location = new System.Drawing.Point(480, 4); - this.connectButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.connectButton.Name = "connectButton"; - this.connectButton.Size = new System.Drawing.Size(94, 24); - this.connectButton.TabIndex = 1; - this.connectButton.Text = "Connect"; - this.connectButton.UseVisualStyleBackColor = true; - this.connectButton.Click += new System.EventHandler(this.connectButton_Click); - // - // panel1 - // - this.panel1.Controls.Add(this.portRefreshButton); - this.panel1.Controls.Add(this.settingButton); - this.panel1.Controls.Add(this.label1); - this.panel1.Controls.Add(this.portComboBox); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(0); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(350, 32); - this.panel1.TabIndex = 2; - // - // settingButton - // - this.settingButton.Location = new System.Drawing.Point(207, 3); - this.settingButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.settingButton.Name = "settingButton"; - this.settingButton.Size = new System.Drawing.Size(68, 24); - this.settingButton.TabIndex = 1; - this.settingButton.Text = "Setting"; - this.settingButton.UseVisualStyleBackColor = true; - this.settingButton.Click += new System.EventHandler(this.settingButton_Click); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(2, 9); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(29, 15); - this.label1.TabIndex = 0; - this.label1.Text = "Port"; - // - // portComboBox - // - this.portComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.portComboBox.FormattingEnabled = true; - this.portComboBox.Location = new System.Drawing.Point(37, 4); - this.portComboBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.portComboBox.Name = "portComboBox"; - this.portComboBox.Size = new System.Drawing.Size(116, 23); - this.portComboBox.TabIndex = 0; - // - // tableLayoutPanel3 - // - this.tableLayoutPanel3.BackColor = System.Drawing.Color.White; - this.tableLayoutPanel3.ColumnCount = 2; - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); - this.tableLayoutPanel3.Controls.Add(this.sendButton, 1, 0); - this.tableLayoutPanel3.Controls.Add(this.commandText, 0, 0); - this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 643); - this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.tableLayoutPanel3.Name = "tableLayoutPanel3"; - this.tableLayoutPanel3.RowCount = 1; - this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel3.Size = new System.Drawing.Size(577, 32); - this.tableLayoutPanel3.TabIndex = 6; - // - // sendButton - // - this.sendButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.sendButton.Location = new System.Drawing.Point(480, 4); - this.sendButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.sendButton.Name = "sendButton"; - this.sendButton.Size = new System.Drawing.Size(94, 24); - this.sendButton.TabIndex = 1; - this.sendButton.Text = "Send"; - this.sendButton.UseVisualStyleBackColor = true; - this.sendButton.Click += new System.EventHandler(this.sendButton_Click); - // - // commandText - // - this.commandText.Dock = System.Windows.Forms.DockStyle.Fill; - this.commandText.Location = new System.Drawing.Point(3, 4); - this.commandText.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.commandText.Name = "commandText"; - this.commandText.Size = new System.Drawing.Size(471, 23); - this.commandText.TabIndex = 0; - // - // printText - // - this.printText.BackColor = System.Drawing.Color.White; - this.printText.Dock = System.Windows.Forms.DockStyle.Fill; - this.printText.Location = new System.Drawing.Point(3, 44); - this.printText.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.printText.Multiline = true; - this.printText.Name = "printText"; - this.printText.ReadOnly = true; - this.printText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.printText.Size = new System.Drawing.Size(577, 591); - this.printText.TabIndex = 2; - this.printText.TabStop = false; - // - // portRefreshButton - // - this.portRefreshButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("portRefreshButton.BackgroundImage"))); - this.portRefreshButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.portRefreshButton.Location = new System.Drawing.Point(159, 4); - this.portRefreshButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.portRefreshButton.Name = "portRefreshButton"; - this.portRefreshButton.Size = new System.Drawing.Size(25, 24); - this.portRefreshButton.TabIndex = 2; - this.portRefreshButton.UseVisualStyleBackColor = true; - this.portRefreshButton.Click += new System.EventHandler(this.portRefreshButton_Click); - // - // SerialCommApp - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(583, 679); - this.Controls.Add(this.tableLayoutPanel1); - this.Font = new System.Drawing.Font("맑은 고딕", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Name = "SerialCommApp"; - this.Text = "Serial Communication Application"; - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.tableLayoutPanel2.ResumeLayout(false); - this.panel1.ResumeLayout(false); - this.panel1.PerformLayout(); - this.tableLayoutPanel3.ResumeLayout(false); - this.tableLayoutPanel3.PerformLayout(); - this.ResumeLayout(false); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SerialCommApp)); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.connectButton = new System.Windows.Forms.Button(); + this.panel1 = new System.Windows.Forms.Panel(); + this.portRefreshButton = new System.Windows.Forms.Button(); + this.settingButton = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.portComboBox = new System.Windows.Forms.ComboBox(); + this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.sendButton = new System.Windows.Forms.Button(); + this.commandText = new System.Windows.Forms.TextBox(); + this.printText = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + this.panel1.SuspendLayout(); + this.tableLayoutPanel3.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.BackColor = System.Drawing.Color.White; + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel3, 0, 2); + this.tableLayoutPanel1.Controls.Add(this.printText, 0, 1); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(583, 679); + this.tableLayoutPanel1.TabIndex = 6; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.BackColor = System.Drawing.Color.White; + this.tableLayoutPanel2.ColumnCount = 3; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 350F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); + this.tableLayoutPanel2.Controls.Add(this.connectButton, 2, 0); + this.tableLayoutPanel2.Controls.Add(this.panel1, 0, 0); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 4); + this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 1; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(577, 32); + this.tableLayoutPanel2.TabIndex = 6; + // + // connectButton + // + this.connectButton.Dock = System.Windows.Forms.DockStyle.Fill; + this.connectButton.Location = new System.Drawing.Point(480, 4); + this.connectButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.connectButton.Name = "connectButton"; + this.connectButton.Size = new System.Drawing.Size(94, 24); + this.connectButton.TabIndex = 1; + this.connectButton.Text = "Connect"; + this.connectButton.UseVisualStyleBackColor = true; + this.connectButton.Click += new System.EventHandler(this.connectButton_Click); + // + // panel1 + // + this.panel1.Controls.Add(this.portRefreshButton); + this.panel1.Controls.Add(this.settingButton); + this.panel1.Controls.Add(this.label1); + this.panel1.Controls.Add(this.portComboBox); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Margin = new System.Windows.Forms.Padding(0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(350, 32); + this.panel1.TabIndex = 2; + // + // portRefreshButton + // + this.portRefreshButton.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("portRefreshButton.BackgroundImage"))); + this.portRefreshButton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; + this.portRefreshButton.Location = new System.Drawing.Point(159, 4); + this.portRefreshButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.portRefreshButton.Name = "portRefreshButton"; + this.portRefreshButton.Size = new System.Drawing.Size(25, 24); + this.portRefreshButton.TabIndex = 2; + this.portRefreshButton.UseVisualStyleBackColor = true; + this.portRefreshButton.Click += new System.EventHandler(this.portRefreshButton_Click); + // + // settingButton + // + this.settingButton.Location = new System.Drawing.Point(207, 3); + this.settingButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.settingButton.Name = "settingButton"; + this.settingButton.Size = new System.Drawing.Size(68, 24); + this.settingButton.TabIndex = 1; + this.settingButton.Text = "Setting"; + this.settingButton.UseVisualStyleBackColor = true; + this.settingButton.Click += new System.EventHandler(this.settingButton_Click); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(2, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(29, 15); + this.label1.TabIndex = 0; + this.label1.Text = "Port"; + // + // portComboBox + // + this.portComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.portComboBox.FormattingEnabled = true; + this.portComboBox.Location = new System.Drawing.Point(37, 4); + this.portComboBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.portComboBox.Name = "portComboBox"; + this.portComboBox.Size = new System.Drawing.Size(116, 23); + this.portComboBox.TabIndex = 0; + // + // tableLayoutPanel3 + // + this.tableLayoutPanel3.BackColor = System.Drawing.Color.White; + this.tableLayoutPanel3.ColumnCount = 2; + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); + this.tableLayoutPanel3.Controls.Add(this.sendButton, 1, 0); + this.tableLayoutPanel3.Controls.Add(this.commandText, 0, 0); + this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel3.Location = new System.Drawing.Point(3, 643); + this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tableLayoutPanel3.Name = "tableLayoutPanel3"; + this.tableLayoutPanel3.RowCount = 1; + this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel3.Size = new System.Drawing.Size(577, 32); + this.tableLayoutPanel3.TabIndex = 6; + // + // sendButton + // + this.sendButton.Dock = System.Windows.Forms.DockStyle.Fill; + this.sendButton.Location = new System.Drawing.Point(480, 4); + this.sendButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.sendButton.Name = "sendButton"; + this.sendButton.Size = new System.Drawing.Size(94, 24); + this.sendButton.TabIndex = 1; + this.sendButton.Text = "Send"; + this.sendButton.UseVisualStyleBackColor = true; + this.sendButton.Click += new System.EventHandler(this.sendButton_Click); + // + // commandText + // + this.commandText.Dock = System.Windows.Forms.DockStyle.Fill; + this.commandText.Location = new System.Drawing.Point(3, 4); + this.commandText.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.commandText.Name = "commandText"; + this.commandText.Size = new System.Drawing.Size(471, 23); + this.commandText.TabIndex = 0; + // + // printText + // + this.printText.BackColor = System.Drawing.Color.White; + this.printText.Dock = System.Windows.Forms.DockStyle.Fill; + this.printText.Location = new System.Drawing.Point(3, 44); + this.printText.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.printText.Multiline = true; + this.printText.Name = "printText"; + this.printText.ReadOnly = true; + this.printText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.printText.Size = new System.Drawing.Size(577, 591); + this.printText.TabIndex = 2; + this.printText.TabStop = false; + // + // SerialCommApp + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(583, 679); + this.Controls.Add(this.tableLayoutPanel1); + this.Font = new System.Drawing.Font("맑은 고딕", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.Name = "SerialCommApp"; + this.Text = "Serial Communication Application"; + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.tableLayoutPanel2.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + this.tableLayoutPanel3.ResumeLayout(false); + this.tableLayoutPanel3.PerformLayout(); + this.ResumeLayout(false); } diff --git a/MySolution/SerialComApp/SerialCommApp.resx b/MySolution/SerialComApp/SerialCommApp.resx index 09cdc5d..4d53742 100644 --- a/MySolution/SerialComApp/SerialCommApp.resx +++ b/MySolution/SerialComApp/SerialCommApp.resx @@ -120,20 +120,20 @@ - iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAACxIAAAsSAdLdfvwAAALASURBVGhD7dnJy01xHMfxa8yQqYSdBdnYiGxEKJFhZ84Q - pchQeshCRM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