From 3d52e6d36abe0c6894df458248ecb97d779efe45 Mon Sep 17 00:00:00 2001 From: Aareschluchtje Date: Mon, 19 Oct 2015 22:21:16 +0200 Subject: [PATCH] Added new ugly table --- .../ConActiveSessions.cs | 50 +++++++++++-------- ErgometerDoctorApplication/MainWindow.cs | 4 +- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/ErgometerDoctorApplication/ConActiveSessions.cs b/ErgometerDoctorApplication/ConActiveSessions.cs index 52a8552..fbd8412 100644 --- a/ErgometerDoctorApplication/ConActiveSessions.cs +++ b/ErgometerDoctorApplication/ConActiveSessions.cs @@ -10,31 +10,39 @@ namespace ErgometerDoctorApplication { public class ConActiveSessions : Panel { - public DataGridView data; public ConActiveSessions() : base() { this.data = new DataGridView(); + this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.sessionId = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.data)).BeginInit(); - this.labelActiveSessions = new System.Windows.Forms.Label(); + this.SuspendLayout(); // // SongsTableView // this.data.AllowUserToAddRows = false; + this.data.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.name, this.sessionId}); this.data.AllowUserToDeleteRows = false; this.data.AllowUserToResizeRows = false; - this.data.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.data.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.data.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.data.Location = new System.Drawing.Point(0, 0); this.data.MultiSelect = false; this.data.Name = "Active Sessions"; - this.data.ReadOnly = true; - this.data.RowHeadersVisible = false; this.data.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.data.Size = new System.Drawing.Size(760, 172); this.data.TabIndex = 0; + this.data.CellContentClick += new DataGridViewCellEventHandler(this.data_CellContentClick); + // + // name + // + this.name.HeaderText = "Name"; + this.name.Name = "Name"; + // + // sessionId + // + this.sessionId.HeaderText = "Session ID"; + this.sessionId.Name = "Session ID"; // // ConActiveSessions // @@ -43,21 +51,19 @@ namespace ErgometerDoctorApplication this.Name = "ConActiveSessions"; this.Size = new System.Drawing.Size(584, 459); this.TabIndex = 0; - // - // labelActiveSessions - // - this.labelActiveSessions.Anchor = System.Windows.Forms.AnchorStyles.None; - this.labelActiveSessions.AutoSize = true; - this.labelActiveSessions.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.labelActiveSessions.Location = new System.Drawing.Point(0, 0); - this.labelActiveSessions.Name = "labelActiveSessions"; - this.labelActiveSessions.Size = new System.Drawing.Size(103, 21); - this.labelActiveSessions.TabIndex = 3; - this.labelActiveSessions.Text = "Geen actieve sessies."; - - this.Controls.Add(labelActiveSessions); + this.Controls.Add(data); } - public System.Windows.Forms.Label labelActiveSessions; + private void data_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + if (data.Rows[e.RowIndex].Cells[1].Value != null) + { + MainClient.StartNewCLient(data.Rows[e.RowIndex].Cells[0].Value + "", int.Parse(data.Rows[e.RowIndex].Cells[1].Value + "")); + } + } + + public System.Windows.Forms.DataGridViewTextBoxColumn name; + public System.Windows.Forms.DataGridViewTextBoxColumn sessionId; + public System.Windows.Forms.DataGridView data; } } diff --git a/ErgometerDoctorApplication/MainWindow.cs b/ErgometerDoctorApplication/MainWindow.cs index c037572..a51781f 100644 --- a/ErgometerDoctorApplication/MainWindow.cs +++ b/ErgometerDoctorApplication/MainWindow.cs @@ -24,14 +24,16 @@ namespace ErgometerDoctorApplication { this.HeaderLabel.Text = "Actieve Sessies"; conActiveSessions.BringToFront(); + conActiveSessions.data.Rows.Clear(); string str = ""; foreach(KeyValuePair client in MainClient.activesessions) { str += client.Value + ", "; MainClient.StartNewCLient(client.Value, client.Key); + conActiveSessions.data.Rows.Add(client.Value, client.Key); } - conActiveSessions.labelActiveSessions.Text = str; + //conActiveSessions.labelActiveSessions.Text = str; Console.WriteLine(str); }