diff --git a/.vs/MacManagerForTemPatch/v16/.suo b/.vs/MacManagerForTemPatch/v16/.suo index 16e4d33..b81f29e 100644 Binary files a/.vs/MacManagerForTemPatch/v16/.suo and b/.vs/MacManagerForTemPatch/v16/.suo differ diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 2041583..dca925e 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -40,10 +40,10 @@ namespace MacManagerForTemPatch this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.button_add_test = new System.Windows.Forms.Button(); this.button_removeAll = new System.Windows.Forms.Button(); this.button_save_csv = new System.Windows.Forms.Button(); this.serialPort = new System.IO.Ports.SerialPort(this.components); - this.button_add_test = new System.Windows.Forms.Button(); this.label_lastmac = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -140,6 +140,16 @@ namespace MacManagerForTemPatch this.groupBox2.TabStop = false; this.groupBox2.Text = "관리"; // + // button_add_test + // + this.button_add_test.Location = new System.Drawing.Point(564, 173); + this.button_add_test.Name = "button_add_test"; + this.button_add_test.Size = new System.Drawing.Size(79, 40); + this.button_add_test.TabIndex = 4; + this.button_add_test.Text = "Test"; + this.button_add_test.UseVisualStyleBackColor = true; + this.button_add_test.Click += new System.EventHandler(this.button_add_test_Click); + // // button_removeAll // this.button_removeAll.Location = new System.Drawing.Point(564, 20); @@ -160,17 +170,6 @@ namespace MacManagerForTemPatch this.button_save_csv.UseVisualStyleBackColor = true; this.button_save_csv.Click += new System.EventHandler(this.button_save_csv_Click); // - // button_add_test - // - this.button_add_test.Location = new System.Drawing.Point(564, 173); - this.button_add_test.Name = "button_add_test"; - this.button_add_test.Size = new System.Drawing.Size(79, 40); - this.button_add_test.TabIndex = 4; - this.button_add_test.Text = "Test"; - this.button_add_test.UseVisualStyleBackColor = true; - this.button_add_test.Visible = false; - this.button_add_test.Click += new System.EventHandler(this.button_add_test_Click); - // // label_lastmac // this.label_lastmac.AutoSize = true; diff --git a/Form1.cs b/Form1.cs index b347703..07988d4 100644 --- a/Form1.cs +++ b/Form1.cs @@ -7,6 +7,7 @@ using System.Drawing; using System.IO; using System.IO.Ports; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -30,7 +31,7 @@ namespace MacManagerForTemPatch { InitializeComponent(); runTimeData = new StringCollection(); - comboBox_comport.DataSource = SerialPort.GetPortNames(); + //comboBox_comport.DataSource = SerialPort.GetPortNames(); mSerial_Buff = new byte[4096]; mSerial_Buff_idx = 0; @@ -70,9 +71,60 @@ namespace MacManagerForTemPatch } } - + GetSerialPort(); + + } + + private void GetSerialPort() + { + // comboBox_comport.DataSource = SerialPort.GetPortNames(); + + comboBox_comport.Items.Clear(); + + try + { + foreach (string str in SerialPort.GetPortNames()) + { + comboBox_comport.Items.Add(str); + } + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } } + protected override void WndProc(ref Message m) + { + UInt32 WM_DEVICECHANGE = 0x0219; + UInt32 DBT_DEVTUP_VOLUME = 0x02; + UInt32 DBT_DEVICEARRIVAL = 0x8000; + UInt32 DBT_DEVICEREMOVECOMPLETE = 0x8004; + + if ((m.Msg == WM_DEVICECHANGE) && (m.WParam.ToInt32() == DBT_DEVICEARRIVAL))//디바이스 연결 + { + //int m_Count = 0; + int devType = Marshal.ReadInt32(m.LParam, 4); + + if (devType == DBT_DEVTUP_VOLUME) + { + GetSerialPort(); + } + } + + if ((m.Msg == WM_DEVICECHANGE) && (m.WParam.ToInt32() == DBT_DEVICEREMOVECOMPLETE)) //디바이스 연결 해제 + { + int devType = Marshal.ReadInt32(m.LParam, 4); + if (devType == DBT_DEVTUP_VOLUME) + { + GetSerialPort(); + } + } + + base.WndProc(ref m); + } + private void button_save_csv_Click(object sender, EventArgs e) { @@ -273,7 +325,7 @@ namespace MacManagerForTemPatch if (MessageBox.Show("저장이 완료되었습니다. 목록을 삭제할까요? ", "데이터 삭제", MessageBoxButtons.YesNo) == DialogResult.Yes) { macList.Clear(); - listView.Clear(); + listView_maclist.Items.Clear(); Properties.Settings.Default.savedmaclist.Clear(); Properties.Settings.Default.Save(); diff --git a/bin/Debug/MacManagerForTemPatch.exe b/bin/Debug/MacManagerForTemPatch.exe index aa05c6c..09fe6b2 100644 Binary files a/bin/Debug/MacManagerForTemPatch.exe and b/bin/Debug/MacManagerForTemPatch.exe differ diff --git a/bin/Debug/MacManagerForTemPatch.pdb b/bin/Debug/MacManagerForTemPatch.pdb index d0f8e77..fb29191 100644 Binary files a/bin/Debug/MacManagerForTemPatch.pdb and b/bin/Debug/MacManagerForTemPatch.pdb differ diff --git a/obj/Debug/MacManagerForTemPatch.csproj.GenerateResource.cache b/obj/Debug/MacManagerForTemPatch.csproj.GenerateResource.cache index 574ce23..2c79a1c 100644 Binary files a/obj/Debug/MacManagerForTemPatch.csproj.GenerateResource.cache and b/obj/Debug/MacManagerForTemPatch.csproj.GenerateResource.cache differ diff --git a/obj/Debug/MacManagerForTemPatch.csprojAssemblyReference.cache b/obj/Debug/MacManagerForTemPatch.csprojAssemblyReference.cache index 050502c..5485901 100644 Binary files a/obj/Debug/MacManagerForTemPatch.csprojAssemblyReference.cache and b/obj/Debug/MacManagerForTemPatch.csprojAssemblyReference.cache differ diff --git a/obj/Debug/MacManagerForTemPatch.exe b/obj/Debug/MacManagerForTemPatch.exe index aa05c6c..09fe6b2 100644 Binary files a/obj/Debug/MacManagerForTemPatch.exe and b/obj/Debug/MacManagerForTemPatch.exe differ diff --git a/obj/Debug/MacManagerForTemPatch.pdb b/obj/Debug/MacManagerForTemPatch.pdb index d0f8e77..fb29191 100644 Binary files a/obj/Debug/MacManagerForTemPatch.pdb and b/obj/Debug/MacManagerForTemPatch.pdb differ