This commit is contained in:
Jannick van Ballegooijen
2015-10-16 22:06:17 +02:00
5 changed files with 28 additions and 5 deletions
@@ -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,13 +57,13 @@ 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;
panelLogin.lblVerification.Visible = true;
}
if (password.Length >= 8)
if (password.Length >= 3)
{
/*
if(SerialPort.GetPortNames().Length <= 0)
@@ -72,9 +74,10 @@ namespace ErgometerApplication
}
else
{ */
if(true)//MainClient.Connect(SerialPort.GetPortNames()[0], username, password))
if(MainClient.Connect(SerialPort.GetPortNames()[0], username, password))
{
panelClientContainer.BringToFront();
chat = panelClientChat;
this.labelUsername.Text = panelLogin.textBoxUsername.Text;
panelTopBar.Visible = true;
updateTimer.Start();
@@ -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)
@@ -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();
@@ -10,7 +10,7 @@ namespace ErgometerApplication
public class PanelClientContainer:Panel
{
private PanelClientChat panelClientChat;
public PanelClientChat panelClientChat;
private PanelGraphView panelGraphView;
public PanelClientContainer() : base()