From dfc4ab9b42972639eccb4a56f7194f7730daa621 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Tue, 20 Oct 2015 12:57:47 +0200 Subject: [PATCH 1/3] Send chat with old session --- ErgometerDoctorApplication/Client/ClientThread.cs | 2 +- ErgometerDoctorApplication/Client/PanelClientChat.cs | 6 +++--- ErgometerDoctorApplication/Client/SessionWindow.cs | 7 +++++-- ErgometerDoctorApplication/MainClient.cs | 3 ++- ErgometerDoctorApplication/MainWindow.cs | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ErgometerDoctorApplication/Client/ClientThread.cs b/ErgometerDoctorApplication/Client/ClientThread.cs index 19025af..92aae43 100644 --- a/ErgometerDoctorApplication/Client/ClientThread.cs +++ b/ErgometerDoctorApplication/Client/ClientThread.cs @@ -50,7 +50,7 @@ namespace ErgometerDoctorApplication window.Invoke(window.updateMetingen, new Object[] { command.Meting }); break; case NetCommand.CommandType.CHAT: - ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, false); + ChatMessage chat = new ChatMessage(command.DisplayName, command.ChatMessage, command.IsDoctor); Chat.Add(chat); window.panelClientChat.Invoke(window.panelClientChat.passChatMessage, new Object[] { chat }); break; diff --git a/ErgometerDoctorApplication/Client/PanelClientChat.cs b/ErgometerDoctorApplication/Client/PanelClientChat.cs index ec0f685..3cf4c66 100644 --- a/ErgometerDoctorApplication/Client/PanelClientChat.cs +++ b/ErgometerDoctorApplication/Client/PanelClientChat.cs @@ -17,8 +17,8 @@ namespace ErgometerDoctorApplication private System.Windows.Forms.Panel panel2; private System.Windows.Forms.Label label1; private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.Button button1; - private System.Windows.Forms.RichTextBox richTextBox1; + public System.Windows.Forms.Button button1; + public System.Windows.Forms.RichTextBox richTextBox1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Panel panel3; private System.Windows.Forms.Label connectionLabel; @@ -153,7 +153,7 @@ namespace ErgometerDoctorApplication if (richTextBox1.TextLength > 1) { AddChatItem(new ChatMessage("Doctor", richTextBox1.Text, true)); - MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, Session)); + MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, true, Session)); richTextBox1.ResetText(); } } diff --git a/ErgometerDoctorApplication/Client/SessionWindow.cs b/ErgometerDoctorApplication/Client/SessionWindow.cs index 1b9f811..aa469fc 100644 --- a/ErgometerDoctorApplication/Client/SessionWindow.cs +++ b/ErgometerDoctorApplication/Client/SessionWindow.cs @@ -42,8 +42,11 @@ namespace ErgometerDoctorApplication InitializeComponent(); - if (!ActiveSession) - panelClientChat.Visible = false; + if(! ActiveSession) + { + panelClientChat.richTextBox1.Enabled = false; + panelClientChat.button1.Enabled = false; + } } public void ClientApplicatie_Resize(object sender, EventArgs e) diff --git a/ErgometerDoctorApplication/MainClient.cs b/ErgometerDoctorApplication/MainClient.cs index e164262..187de47 100644 --- a/ErgometerDoctorApplication/MainClient.cs +++ b/ErgometerDoctorApplication/MainClient.cs @@ -96,7 +96,7 @@ namespace ErgometerDoctorApplication loggedin = true; } - SendNetCommand(new NetCommand(NetCommand.RequestType.USERS, Session)); + //SendNetCommand(new NetCommand(NetCommand.RequestType.USERS, Session)); SendNetCommand(new NetCommand(NetCommand.RequestType.SESSIONDATA, Session)); return true; @@ -256,6 +256,7 @@ namespace ErgometerDoctorApplication return; SendNetCommand(new NetCommand(NetCommand.RequestType.OLDDATA, session)); + SendNetCommand(new NetCommand(NetCommand.RequestType.CHAT, session)); //Start new client ClientThread cl = new ClientThread(name, session, true); diff --git a/ErgometerDoctorApplication/MainWindow.cs b/ErgometerDoctorApplication/MainWindow.cs index 2892d86..f3b0cbd 100644 --- a/ErgometerDoctorApplication/MainWindow.cs +++ b/ErgometerDoctorApplication/MainWindow.cs @@ -67,7 +67,7 @@ namespace ErgometerDoctorApplication this.HeaderLabel.Text = "Sessie geschiedenis"; conSessionHistory.BringToFront(); - MainClient.StartOldCLient("Test", 1148735907); + MainClient.StartOldCLient("Test", 1907047993); } public void validateLogin() { From 91a659b6fbd8d86a82126a1f3ab93a95932b84d4 Mon Sep 17 00:00:00 2001 From: Aareschluchtje Date: Tue, 20 Oct 2015 13:43:34 +0200 Subject: [PATCH 2/3] Added history --- .../ConSessionHistory.cs | 47 +++++++++++++++++-- .../ErgometerDoctorApplication.csproj | 4 +- ErgometerDoctorApplication/MainClient.cs | 22 ++++----- ErgometerDoctorApplication/MainWindow.cs | 29 +++++++++--- 4 files changed, 78 insertions(+), 24 deletions(-) diff --git a/ErgometerDoctorApplication/ConSessionHistory.cs b/ErgometerDoctorApplication/ConSessionHistory.cs index 590f17a..784b78b 100644 --- a/ErgometerDoctorApplication/ConSessionHistory.cs +++ b/ErgometerDoctorApplication/ConSessionHistory.cs @@ -9,18 +9,57 @@ namespace ErgometerDoctorApplication { public class ConSessionHistory : Panel { + private FlowLayoutPanel flowlayout; + public ConSessionHistory() : base() { - // - // ConSessionLibrary - // + labelSessionHistory = new Label(); + this.Dock = System.Windows.Forms.DockStyle.Fill; this.Location = new System.Drawing.Point(0, 0); this.Name = "ConSessionHistory"; this.Size = new System.Drawing.Size(584, 459); this.TabIndex = 0; + // + // labelSessionHistory + // + this.labelSessionHistory.Anchor = System.Windows.Forms.AnchorStyles.None; + this.labelSessionHistory.AutoSize = true; + this.labelSessionHistory.Font = new System.Drawing.Font("Segoe UI Semibold", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelSessionHistory.Location = new System.Drawing.Point(0, 50); + this.labelSessionHistory.Name = "labelSessionHistory"; + this.labelSessionHistory.Size = new System.Drawing.Size(103, 21); + this.labelSessionHistory.TabIndex = 3; + this.labelSessionHistory.Text = "Er zijn geen oude sessies."; - this.BackColor = System.Drawing.Color.Yellow; + flowlayout = new FlowLayoutPanel(); + + flowlayout.Dock = DockStyle.Fill; + flowlayout.BackColor = System.Drawing.Color.DarkGray; + flowlayout.Location = new System.Drawing.Point(0, 0); + flowlayout.Name = "flowlayout"; + flowlayout.Padding = new Padding(15); + flowlayout.AutoScroll = true; + + this.Controls.Add(labelSessionHistory); + this.Controls.Add(flowlayout); + + //this.Controls.Add(data); + + updateHistory(MainClient.oldSessionsData); + + } + + public System.Windows.Forms.Label labelSessionHistory; + + public void updateHistory(List> actives) + { + flowlayout.Controls.Clear(); + + foreach (Tuple sessiondata in actives) + { + flowlayout.Controls.Add(new SessionPanel(sessiondata.Item3, sessiondata.Item1)); + } } } } diff --git a/ErgometerDoctorApplication/ErgometerDoctorApplication.csproj b/ErgometerDoctorApplication/ErgometerDoctorApplication.csproj index a4e925d..0f23c1c 100644 --- a/ErgometerDoctorApplication/ErgometerDoctorApplication.csproj +++ b/ErgometerDoctorApplication/ErgometerDoctorApplication.csproj @@ -33,9 +33,9 @@ 4 - + False - ..\..\..\ErgometerLibrary\ErgometerLibrary\ErgometerLibrary\bin\Debug\ErgometerLibrary.dll + ..\..\ErgometerLibrary\ErgometerLibrary\bin\Debug\ErgometerLibrary.dll diff --git a/ErgometerDoctorApplication/MainClient.cs b/ErgometerDoctorApplication/MainClient.cs index e164262..63c2363 100644 --- a/ErgometerDoctorApplication/MainClient.cs +++ b/ErgometerDoctorApplication/MainClient.cs @@ -28,7 +28,7 @@ namespace ErgometerDoctorApplication //Server information public static List clients; public static Dictionary users; - public static List oldsessions; + public static List> oldSessionsData; public static void RemoveActiveClient(ClientThread clientThread) { @@ -45,8 +45,8 @@ namespace ErgometerDoctorApplication clients = new List(); users = new Dictionary(); - oldsessions = new List(); activesessions = new Dictionary(); + oldSessionsData = new List>(); } public static bool Connect(string password, out string error) @@ -157,7 +157,7 @@ namespace ErgometerDoctorApplication UsersLength = command.LengthValue; break; case NetCommand.LengthType.SESSIONS: - oldsessions.Clear(); + oldSessionsData.Clear(); SessionsBeingSent = true; SessionsSent = 0; SessionsLength = command.LengthValue; @@ -184,15 +184,6 @@ namespace ErgometerDoctorApplication UsersBeingSent = false; } break; - case NetCommand.CommandType.SESSION: - if (SessionsBeingSent) - { - oldsessions.Add(command.Session); - SessionsSent++; - if (SessionsSent >= SessionsLength) - SessionsBeingSent = false; - } - break; case NetCommand.CommandType.SESSIONDATA: if (ActiveSessionsBeingSent) { @@ -201,6 +192,13 @@ namespace ErgometerDoctorApplication if (ActiveSessionsSent >= ActiveSessionsLength) ActiveSessionsBeingSent = false; } + if (SessionsBeingSent) + { + oldSessionsData.Add(new Tuple(command.DisplayName, command.Timestamp, command.Session)); + SessionsSent++; + if (SessionsSent >= SessionsLength) + SessionsBeingSent = false; + } break; default: HandToClient(command); diff --git a/ErgometerDoctorApplication/MainWindow.cs b/ErgometerDoctorApplication/MainWindow.cs index 2892d86..7694da5 100644 --- a/ErgometerDoctorApplication/MainWindow.cs +++ b/ErgometerDoctorApplication/MainWindow.cs @@ -13,13 +13,13 @@ namespace ErgometerDoctorApplication { public partial class MainWindow : Form { - private bool request; + private int request; public MainWindow() { InitializeComponent(); conPanelLogin.BringToFront(); - request = false; + request = 0; updateTimer.Start(); } @@ -67,7 +67,18 @@ namespace ErgometerDoctorApplication this.HeaderLabel.Text = "Sessie geschiedenis"; conSessionHistory.BringToFront(); - MainClient.StartOldCLient("Test", 1148735907); + //MainClient.StartOldCLient("Test", 1148735907); + + if (MainClient.oldSessionsData.Count > 0) + { + conSessionHistory.labelSessionHistory.Text = ""; + conSessionHistory.updateHistory(MainClient.oldSessionsData); + } + else + { + conSessionHistory.updateHistory(MainClient.oldSessionsData); + conSessionHistory.labelSessionHistory.Text = "Er zijn geen oude sessies."; + } } public void validateLogin() { @@ -114,12 +125,18 @@ namespace ErgometerDoctorApplication private void updateTimer_tick(object sender, EventArgs e) { - if (request) + if (request == 0) MainClient.SendNetCommand(new NetCommand(NetCommand.RequestType.USERS, MainClient.Session)); - else + else if (request == 1) MainClient.SendNetCommand(new NetCommand(NetCommand.RequestType.SESSIONDATA, MainClient.Session)); + else if(request == 2) + MainClient.SendNetCommand(new NetCommand(NetCommand.RequestType.ALLSESSIONS, MainClient.Session)); - request = !request; + request ++; + if (request > 2) + { + request = 0; + } } } } From 38f5ee9ee4d37f7ef7ffa12733e558638940903c Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Tue, 20 Oct 2015 13:43:55 +0200 Subject: [PATCH 3/3] Changed size --- ErgometerDoctorApplication/Client/ChartPanel.cs | 4 ++-- ErgometerDoctorApplication/MainWindow.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ErgometerDoctorApplication/Client/ChartPanel.cs b/ErgometerDoctorApplication/Client/ChartPanel.cs index 5639ef1..43a0315 100644 --- a/ErgometerDoctorApplication/Client/ChartPanel.cs +++ b/ErgometerDoctorApplication/Client/ChartPanel.cs @@ -28,13 +28,13 @@ namespace ErgometerDoctorApplication this.Location = new System.Drawing.Point(0, 0); - this.Size = new System.Drawing.Size(250, 200); + this.Size = new System.Drawing.Size(400, 250); this.Controls.Add(chart); this.series = createSerie(); this.chartArea.Name = "chartArea"; - this.chart.Size = new System.Drawing.Size(250, 200); + this.chart.Size = new System.Drawing.Size(400, 250); this.chart.Dock = DockStyle.Fill; this.chart.Series.Add(series); diff --git a/ErgometerDoctorApplication/MainWindow.cs b/ErgometerDoctorApplication/MainWindow.cs index f3b0cbd..c8b33c9 100644 --- a/ErgometerDoctorApplication/MainWindow.cs +++ b/ErgometerDoctorApplication/MainWindow.cs @@ -67,7 +67,7 @@ namespace ErgometerDoctorApplication this.HeaderLabel.Text = "Sessie geschiedenis"; conSessionHistory.BringToFront(); - MainClient.StartOldCLient("Test", 1907047993); + MainClient.StartOldCLient("Test", 315896171); } public void validateLogin() {