From c73352bf8be1e73d480cf6a40b3b5d1c66bafbd5 Mon Sep 17 00:00:00 2001 From: Aareschluchtje Date: Fri, 16 Oct 2015 11:55:37 +0200 Subject: [PATCH 1/2] Fixed a little problem --- ErgometerApplication/ErgometerApplication/ClientApplicatie.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs b/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs index 0dc9c5a..7d92501 100644 --- a/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs +++ b/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs @@ -61,7 +61,7 @@ namespace ErgometerApplication panelLogin.lblVerification.ForeColor = Color.Red; panelLogin.lblVerification.Visible = true; } - if (password.Length >= 8) + if (password.Length >= 3) { /* if(SerialPort.GetPortNames().Length <= 0) @@ -72,7 +72,7 @@ namespace ErgometerApplication } else { */ - if(true)//MainClient.Connect(SerialPort.GetPortNames()[0], username, password)) + if(MainClient.Connect(SerialPort.GetPortNames()[0], username, password)) { panelClientContainer.BringToFront(); this.labelUsername.Text = panelLogin.textBoxUsername.Text; From 4c78826a2a8812e28ad153dfef91d76d58c54230 Mon Sep 17 00:00:00 2001 From: Aareschluchtje Date: Fri, 16 Oct 2015 13:15:16 +0200 Subject: [PATCH 2/2] Sends messages to server, but can't display them. --- .../.vs/ErgometerApplication/v14/.suo | Bin 101376 -> 101376 bytes .../ErgometerApplication/ClientApplicatie.cs | 5 ++++- .../ErgometerApplication/MainClient.cs | 13 +++++++++++++ .../ErgometerApplication/PanelClientChat.cs | 9 ++++++++- .../PanelClientContainer.cs | 2 +- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ErgometerApplication/.vs/ErgometerApplication/v14/.suo b/ErgometerApplication/.vs/ErgometerApplication/v14/.suo index 910d56e0f20230346ebee2eeb754311f6ecaf5dd..d55e72b20c2da078adf1ee18a1a0baf20fc7fc8d 100644 GIT binary patch delta 651 zcmZpe!PYQ?Z9@(dpF>Mu-(U8NjNuFn3=PSXtC*@7dpCb&if3e0pB&1fKe>fNKvoAR zHwlQjf!Gp=`G8m#i2nn@zsVa}+9wvMOpamYVAR;0%F52jx1iwnCzzQBAZGS${>rA$ z$f6C@HCclr##9f;kON{hApQ$72M9n`fM{eZ{(%I5U^-Ave==jD`s4>35pe4!r*iJ+ z>|$hK=mz4R&9YpV87J{5i1Y$^a8V!|WXNU(t}~3A_7=KK@xLtqpgY7btk8HOA(h6W~z{G-$ze&oOo0q`{=puQjizf$)sBA7#Jul76 z;Ef^d*u%F;zHUy&wS6&)NypOOnec1vxNYn(P?1f4V>&qsVkI6-Jeb1snorcR1{8 zn6rdG((zW#bRk*RiHRGgOK~yEY?g_6!nn!DfsyeESW}EXqndPvQ(@}$yPVl9nYgY5@S$YVV-{ delta 627 zcmZpe!PYQ?Z9@(d-+|LS`X5;@GKMoSFf=4hu41ZU?A-j7DV~v$dvYj?zOFh@Tn>oU zfcWo!2$%$9YXI>-AeRqF>jE)YX7Wasc1FvIfy$F(SUDK|Hm9<(Gx8PmJb!~}1Dif0 z3rPQD4UU+}Ei3}E+CW1<21Bes7z|SMA84@tUn8w!j3(Bi+q?SAJFHT z%oSxO(C+x@g4fxz`lVJKo-XU>AKDz?vw?9@2+O1>2TVCft__Tnd=6kpOrGGfOmNQ( zuYf80E6#jT|GWIM_Vwco69a`Ozw#8DY``RdspF!A!SqAfj53>LVxBNgcZg)vo4k%+ zXtIOLH^Hd#W}h1m^>#$`S{~%yeD?*|peWZB;;_Jj(5*nq2FsMq_U^vsEY z>W;I3oY_FE2Nj$Lq~`c V;sZc@5QzUxO#I!Hv@D5H3jkmF{uuxO diff --git a/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs b/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs index 7d92501..68ecbb5 100644 --- a/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs +++ b/ErgometerApplication/ErgometerApplication/ClientApplicatie.cs @@ -20,9 +20,11 @@ namespace ErgometerApplication { public partial class ClientApplicatie : Form { + public PanelClientChat chat; public ClientApplicatie() { InitializeComponent(); + MainClient.Init(this); } private void updateTimer_Tick(object sender, EventArgs e) @@ -55,7 +57,7 @@ namespace ErgometerApplication panelLogin.lblVerification.ForeColor = Color.Red; panelLogin.lblVerification.Visible = true; } - if (password.Length > 0 && password.Length < 8) + if (password.Length > 0 && password.Length < 4) { panelLogin.lblVerification.Text = "Vul een wachtwoord in van minimaal 8 karakters."; panelLogin.lblVerification.ForeColor = Color.Red; @@ -75,6 +77,7 @@ namespace ErgometerApplication if(MainClient.Connect(SerialPort.GetPortNames()[0], username, password)) { panelClientContainer.BringToFront(); + chat = panelClientChat; this.labelUsername.Text = panelLogin.textBoxUsername.Text; panelTopBar.Visible = true; updateTimer.Start(); diff --git a/ErgometerApplication/ErgometerApplication/MainClient.cs b/ErgometerApplication/ErgometerApplication/MainClient.cs index f3109d7..ef6215e 100644 --- a/ErgometerApplication/ErgometerApplication/MainClient.cs +++ b/ErgometerApplication/ErgometerApplication/MainClient.cs @@ -28,6 +28,8 @@ namespace ErgometerApplication public static string HOST = "127.0.0.1"; public static int PORT = 8888; + public static ClientApplicatie Client; + static MainClient() { ComPort = new ComPort(); @@ -42,6 +44,11 @@ namespace ErgometerApplication Loggedin = false; } + public static void Init(ClientApplicatie client) + { + Client = client; + } + public static bool Connect(string comport, string name, string password) { if (!Doctor.Connected) @@ -153,6 +160,7 @@ namespace ErgometerApplication break; case NetCommand.CommandType.CHAT: Chat.Add(new ChatMessage(Name, command.ChatMessage)); + Client.chat.AddChatItem(command.ChatMessage); break; case NetCommand.CommandType.RESPONSE: Console.WriteLine(command.Response.ToString()); @@ -165,6 +173,11 @@ namespace ErgometerApplication } } + public static void SendNetCommand(NetCommand command) + { + NetHelper.SendNetCommand(Doctor, command); + } + private static void ParseValueSet(NetCommand command) { switch(command.Value) diff --git a/ErgometerApplication/ErgometerApplication/PanelClientChat.cs b/ErgometerApplication/ErgometerApplication/PanelClientChat.cs index 28d4405..700a850 100644 --- a/ErgometerApplication/ErgometerApplication/PanelClientChat.cs +++ b/ErgometerApplication/ErgometerApplication/PanelClientChat.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using ErgometerLibrary; namespace ErgometerApplication { @@ -144,12 +145,18 @@ namespace ErgometerApplication { if (richTextBox1.TextLength > 1) { - flowLayoutPanel1.Controls.Add(new ChatItem(richTextBox1.Text, DateTime.Now.ToString("h:mm:ss tt"), true)); flowLayoutPanel1.Controls.Add(new ChatItem(richTextBox1.Text, DateTime.Now.ToString("h:mm:ss tt"), false)); + MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, MainClient.Session)); richTextBox1.ResetText(); } } + public void AddChatItem(string text) + { + flowLayoutPanel1.Controls.Add(new ChatItem(text, DateTime.Now.ToString("h:mm:ss tt"), false)); + } + + private void panel3_MouseWheel(object sender, MouseEventArgs e) { panel3.Focus(); diff --git a/ErgometerApplication/ErgometerApplication/PanelClientContainer.cs b/ErgometerApplication/ErgometerApplication/PanelClientContainer.cs index 74bf85d..f2e40ef 100644 --- a/ErgometerApplication/ErgometerApplication/PanelClientContainer.cs +++ b/ErgometerApplication/ErgometerApplication/PanelClientContainer.cs @@ -10,7 +10,7 @@ namespace ErgometerApplication public class PanelClientContainer:Panel { - private PanelClientChat panelClientChat; + public PanelClientChat panelClientChat; private PanelGraphView panelGraphView; public PanelClientContainer() : base()