Fixed chat

This commit is contained in:
2015-10-19 17:29:47 +02:00
parent 520a6f61ff
commit 96b15eb85a
5 changed files with 18 additions and 10 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ namespace ErgometerDoctorApplication
this.setAppearance(isDoctor);
this.Controls.Add(this.messageLabel);
this.Controls.Add(this.timeLabel);
this.MinimumSize = new System.Drawing.Size(100, 40);
this.MinimumSize = new System.Drawing.Size(150, 60);
this.Name = "messageContainer";
this.Padding = new System.Windows.Forms.Padding(6);
@@ -31,7 +31,7 @@ namespace ErgometerDoctorApplication
this.messageLabel.Dock = System.Windows.Forms.DockStyle.Fill;
this.messageLabel.Font = new System.Drawing.Font("Segoe UI Semibold", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.messageLabel.Location = new System.Drawing.Point(6, 6);
this.messageLabel.MaximumSize = new System.Drawing.Size(190, 0);
this.messageLabel.MaximumSize = new System.Drawing.Size(250, 0);
this.messageLabel.Size = new System.Drawing.Size(121, 20);
this.messageLabel.Text = message;
//
+3 -3
View File
@@ -23,7 +23,7 @@ namespace ErgometerDoctorApplication
Name = name;
Session = session;
window = new SessionWindow(Name, true);
window = new SessionWindow(Name, true, Session);
window.FormClosed += Window_FormClosed;
Metingen = new List<Meting>();
@@ -37,14 +37,14 @@ namespace ErgometerDoctorApplication
public void HandleCommand(NetCommand command)
{
switch(command.Type)
switch (command.Type)
{
case NetCommand.CommandType.DATA:
SaveMeting(command.Meting);
break;
case NetCommand.CommandType.CHAT:
Chat.Add(new ChatMessage(Name, command.ChatMessage, false));
window.panelClientChat.AddChatItem(command.ChatMessage);
window.panelClientChat.Invoke(window.panelClientChat.passChatMessage, new Object[] { command.ChatMessage, Helper.MillisecondsToTime(command.Timestamp), false });
break;
}
}
@@ -21,8 +21,9 @@ namespace ErgometerDoctorApplication
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Label connectionLabel;
private int session;
public PanelClientChat() : base()
public PanelClientChat(int session) : base()
{
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.panel2 = new System.Windows.Forms.Panel();
@@ -32,6 +33,7 @@ namespace ErgometerDoctorApplication
this.panel1 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.session = session;
this.panel3 = new System.Windows.Forms.Panel();
//
@@ -140,7 +142,7 @@ namespace ErgometerDoctorApplication
this.Name = "container";
this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseWheel);
Form.CheckForIllegalCrossThreadCalls = false;
passChatMessage = new ChatDelegate(this.AddChatItem);
}
private void button1_Click(object sender, EventArgs e)
@@ -148,7 +150,7 @@ namespace ErgometerDoctorApplication
if (richTextBox1.TextLength > 1)
{
AddChatItem(richTextBox1.Text, Helper.MillisecondsToTime(Helper.Now), true);
MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, MainClient.Session));
MainClient.SendNetCommand(new NetCommand(richTextBox1.Text, session));
richTextBox1.ResetText();
}
}
@@ -203,5 +205,8 @@ namespace ErgometerDoctorApplication
button1_Click(this, new EventArgs());
}
}
public delegate void ChatDelegate(string message, string time, bool isDoctor);
public ChatDelegate passChatMessage;
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ namespace ErgometerDoctorApplication
this.panelClientContainer = new System.Windows.Forms.Panel();
this.panelDataViewLeft = new System.Windows.Forms.Panel();
this.panelGraphView = new ErgometerDoctorApplication.PanelGraphView();
this.panelClientChat = new ErgometerDoctorApplication.PanelClientChat();
this.panelClientChat = new ErgometerDoctorApplication.PanelClientChat(Session);
this.panelTopBar = new System.Windows.Forms.Panel();
this.labelUsername = new System.Windows.Forms.Label();
this.labelHallo = new System.Windows.Forms.Label();
+4 -1
View File
@@ -15,10 +15,13 @@ namespace ErgometerDoctorApplication
private bool ActiveSession { get; }
private string ClientName { get; set; }
public SessionWindow(string ClientName, bool ActiveSession)
public int Session { get; }
public SessionWindow(string ClientName, bool ActiveSessionm, int session)
{
this.ActiveSession = ActiveSession;
this.ClientName = ClientName;
Session = session;
InitializeComponent();
Form.CheckForIllegalCrossThreadCalls = false;