diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs index 1279d5d..289c3d2 100644 --- a/MainForm.Designer.cs +++ b/MainForm.Designer.cs @@ -55,7 +55,6 @@ private void InitializeComponent() this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.MainListView = new System.Windows.Forms.ListView(); - this.handle = new System.Windows.Forms.ColumnHeader(); this.name = new System.Windows.Forms.ColumnHeader(); this.type = new System.Windows.Forms.ColumnHeader(); this.rights = new System.Windows.Forms.ColumnHeader(); @@ -63,6 +62,7 @@ private void InitializeComponent() this.quality = new System.Windows.Forms.ColumnHeader(); this.error = new System.Windows.Forms.ColumnHeader(); this.timestamp = new System.Windows.Forms.ColumnHeader(); + this.handle = new System.Windows.Forms.ColumnHeader(); this.NotifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.menuStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout(); @@ -75,7 +75,7 @@ private void InitializeComponent() this.ReadButton.Margin = new System.Windows.Forms.Padding(2); this.ReadButton.Name = "ReadButton"; this.ReadButton.Size = new System.Drawing.Size(112, 34); - this.ReadButton.TabIndex = 0; + this.ReadButton.TabIndex = 2; this.ReadButton.Text = "Connect"; this.ReadButton.UseVisualStyleBackColor = true; this.ReadButton.Click += new System.EventHandler(this.ReadButton_Click); @@ -86,7 +86,7 @@ private void InitializeComponent() this.UAPortTextBox.Margin = new System.Windows.Forms.Padding(2); this.UAPortTextBox.Name = "UAPortTextBox"; this.UAPortTextBox.Size = new System.Drawing.Size(200, 30); - this.UAPortTextBox.TabIndex = 2; + this.UAPortTextBox.TabIndex = 3; // // menuStrip1 // @@ -196,7 +196,7 @@ private void InitializeComponent() this.UAPasswordTextBox.Location = new System.Drawing.Point(739, 72); this.UAPasswordTextBox.Name = "UAPasswordTextBox"; this.UAPasswordTextBox.Size = new System.Drawing.Size(180, 30); - this.UAPasswordTextBox.TabIndex = 16; + this.UAPasswordTextBox.TabIndex = 5; // // label5 // @@ -212,7 +212,7 @@ private void InitializeComponent() this.UAUserTextBox.Location = new System.Drawing.Point(421, 72); this.UAUserTextBox.Name = "UAUserTextBox"; this.UAUserTextBox.Size = new System.Drawing.Size(180, 30); - this.UAUserTextBox.TabIndex = 14; + this.UAUserTextBox.TabIndex = 4; // // label4 // @@ -229,7 +229,7 @@ private void InitializeComponent() this.DAHostComboBox.Location = new System.Drawing.Point(108, 32); this.DAHostComboBox.Name = "DAHostComboBox"; this.DAHostComboBox.Size = new System.Drawing.Size(200, 32); - this.DAHostComboBox.TabIndex = 12; + this.DAHostComboBox.TabIndex = 0; this.DAHostComboBox.DropDown += new System.EventHandler(this.DAHostComboBox_DropDown); // // DAServerComboBox @@ -238,7 +238,7 @@ private void InitializeComponent() this.DAServerComboBox.Location = new System.Drawing.Point(421, 32); this.DAServerComboBox.Name = "DAServerComboBox"; this.DAServerComboBox.Size = new System.Drawing.Size(498, 32); - this.DAServerComboBox.TabIndex = 11; + this.DAServerComboBox.TabIndex = 1; this.DAServerComboBox.DropDown += new System.EventHandler(this.DAServerComboBox_DropDown); // // RunButton @@ -246,7 +246,7 @@ private void InitializeComponent() this.RunButton.Location = new System.Drawing.Point(924, 71); this.RunButton.Name = "RunButton"; this.RunButton.Size = new System.Drawing.Size(112, 34); - this.RunButton.TabIndex = 9; + this.RunButton.TabIndex = 6; this.RunButton.Text = "Run"; this.RunButton.UseVisualStyleBackColor = true; this.RunButton.Click += new System.EventHandler(this.RunButton_Click); @@ -287,26 +287,22 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.MainListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.handle, this.name, this.type, this.rights, this.value, this.quality, this.error, - this.timestamp}); + this.timestamp, + this.handle}); this.MainListView.HideSelection = false; this.MainListView.Location = new System.Drawing.Point(13, 166); this.MainListView.Name = "MainListView"; this.MainListView.Size = new System.Drawing.Size(1103, 491); - this.MainListView.TabIndex = 6; + this.MainListView.TabIndex = 7; this.MainListView.UseCompatibleStateImageBehavior = false; this.MainListView.View = System.Windows.Forms.View.Details; - // - // handle - // - this.handle.Text = "Index"; - this.handle.Width = 0; + this.MainListView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.MainListView_MouseDoubleClick); // // name // @@ -343,6 +339,11 @@ private void InitializeComponent() this.timestamp.Text = "Timestamp"; this.timestamp.Width = 200; // + // handle + // + this.handle.Text = "Index"; + this.handle.Width = 0; + // // NotifyIcon // this.NotifyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon.Icon"))); diff --git a/MainForm.cs b/MainForm.cs index 4e3b4d9..5226975 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -40,10 +40,10 @@ private void UpdateListView(List list) int index = data.ClientHandle; var items = MainListView.Items; var item = items[index]; - var subItemValue = item.SubItems[4]; - var subItemQuality = item.SubItems[5]; - var subItemError = item.SubItems[6]; - var subItemTs = item.SubItems[7]; + var subItemValue = item.SubItems[3]; + var subItemQuality = item.SubItems[4]; + var subItemError = item.SubItems[5]; + var subItemTs = item.SubItems[6]; subItemValue.Text = Convert.ToString(data.Value); subItemQuality.Text = data.Quality.ToString(); @@ -96,14 +96,14 @@ private void ResetListView(List list) for (int i = 0; i < data.Count; i++) { ListViewItem lvi = new ListViewItem(); - lvi.Text = data[i].ClientHandle.ToString(); // handle - lvi.SubItems.Add(data[i].Name.ToString()); // name + lvi.Text = data[i].Name.ToString(); // handle lvi.SubItems.Add(data[i].Type.ToString()); // type lvi.SubItems.Add(data[i].Rights.ToString()); // rights lvi.SubItems.Add(""); // value lvi.SubItems.Add(""); // quality lvi.SubItems.Add(""); // error lvi.SubItems.Add(""); // timestamp + lvi.SubItems.Add(data[i].ClientHandle.ToString()); // handle MainListView.Items.Add(lvi); } MainListView.EndUpdate(); @@ -182,7 +182,7 @@ private void DAHostComboBox_DropDown(object sender, EventArgs e) private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { - var result = MessageBox.Show("Do you want to exit the program?", "warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); + var result = MessageBox.Show("Do you want to exit the program?", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (DialogResult.Cancel == result) { e.Cancel = true; @@ -207,5 +207,23 @@ private void RunButton_Click(object sender, EventArgs e) UAUserTextBox.Enabled = false; UAPasswordTextBox.Enabled = false; } + + private void MainListView_MouseDoubleClick(object sender, MouseEventArgs e) + { + ListView listView = (ListView)sender; + ListViewItem row = listView.GetItemAt(e.X, e.Y); + ListViewItem.ListViewSubItem col = row.GetSubItemAt(e.X, e.Y); + string strText = col.Text; + try + { + Clipboard.SetDataObject(strText); + string info = $"The content [{strText}] has been copied to the clipboard"; + MessageBox.Show(info, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (System.Exception ex) + { + MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } } diff --git a/Program.cs b/Program.cs index 9245aef..27abf33 100644 --- a/Program.cs +++ b/Program.cs @@ -22,7 +22,7 @@ static void Main() Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.Console() - .WriteTo.File("neuopc.log", rollingInterval: RollingInterval.Day) + .WriteTo.File("log/neuopc.log", rollingInterval: RollingInterval.Day) .CreateLogger(); Register.Setup();