diff --git a/ErgometerApplication/ErgometerApplication/ChatItem.cs b/ErgometerApplication/ErgometerApplication/ChatItem.cs new file mode 100644 index 0000000..5cd9cd4 --- /dev/null +++ b/ErgometerApplication/ErgometerApplication/ChatItem.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ErgometerApplication +{ + public class ChatItem : Panel + { + private Label messageLabel, timeLabel; + + public ChatItem(string message, string time, bool isDoctor) : base() + { + this.messageLabel = new Label(); + this.timeLabel = new Label(); + + this.AutoSize = true; + this.setAppearance(isDoctor); + this.Controls.Add(this.messageLabel); + this.Controls.Add(this.timeLabel); + this.MinimumSize = new System.Drawing.Size(100, 40); + this.Name = "messageContainer"; + this.Padding = new System.Windows.Forms.Padding(6); + + // + // Message Label + // + this.messageLabel.AutoSize = true; + 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.Size = new System.Drawing.Size(121, 20); + this.messageLabel.Text = message; + // + // Time Label + // + this.timeLabel.AutoSize = true; + this.timeLabel.Dock = System.Windows.Forms.DockStyle.Bottom; + this.timeLabel.Font = new System.Drawing.Font("Segoe UI Semilight", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.timeLabel.Location = new System.Drawing.Point(6, 26); + this.timeLabel.Margin = new System.Windows.Forms.Padding(6); + this.timeLabel.Size = new System.Drawing.Size(32, 13); + this.timeLabel.Text = "Time:" + time; + } + + private void setAppearance(bool isDoctor) + { + if (isDoctor) + { + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.Dock = DockStyle.Right; + } + else + { + this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240))))); + this.Dock = DockStyle.Left; + } + } + } +} diff --git a/ErgometerApplication/ErgometerApplication/PanelClientChat.cs b/ErgometerApplication/ErgometerApplication/PanelClientChat.cs index 57dfc8f..93f6d14 100644 --- a/ErgometerApplication/ErgometerApplication/PanelClientChat.cs +++ b/ErgometerApplication/ErgometerApplication/PanelClientChat.cs @@ -9,18 +9,171 @@ namespace ErgometerApplication { public class PanelClientChat : Panel { + + + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + 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; + private System.Windows.Forms.BindingSource bindingSource1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Panel panel3; + private System.Windows.Forms.Panel container; + private System.Windows.Forms.Label connectionLabel; + public PanelClientChat() : base() { - // - // panelClientChat - // - this.BackColor = System.Drawing.SystemColors.ButtonHighlight; - this.Dock = System.Windows.Forms.DockStyle.Left; - this.Location = new System.Drawing.Point(0, 0); - this.Name = "panelClientChat"; - this.Size = new System.Drawing.Size(400, 600); - this.TabIndex = 2; + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.panel2 = new System.Windows.Forms.Panel(); + this.connectionLabel = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.button1 = new System.Windows.Forms.Button(); + this.richTextBox1 = new System.Windows.Forms.RichTextBox(); + this.panel3 = new System.Windows.Forms.Panel(); + this.container = new System.Windows.Forms.Panel(); + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.AutoSize = true; + this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.flowLayoutPanel1.Controls.Add(this.panel2); + this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Padding = new System.Windows.Forms.Padding(3); + this.flowLayoutPanel1.Size = new System.Drawing.Size(421, 36); + this.flowLayoutPanel1.TabIndex = 0; + this.flowLayoutPanel1.WrapContents = false; + this.flowLayoutPanel1.SizeChanged += new System.EventHandler(this.FlowLayoutPanel1_SizeChanged); + // + // panel2 + // + this.panel2.Controls.Add(this.connectionLabel); + this.panel2.Dock = System.Windows.Forms.DockStyle.Left; + this.panel2.Location = new System.Drawing.Point(6, 6); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(409, 24); + this.panel2.TabIndex = 0; + // + // connectionLabel + // + this.connectionLabel.AutoSize = true; + this.connectionLabel.Font = new System.Drawing.Font("Segoe UI Semibold", 8F, System.Drawing.FontStyle.Bold); + this.connectionLabel.Location = new System.Drawing.Point(4, 4); + this.connectionLabel.Name = "connectionLabel"; + this.connectionLabel.Size = new System.Drawing.Size(112, 13); + this.connectionLabel.TabIndex = 0; + this.connectionLabel.Text = "Now connected with:"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(0, 0); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(100, 23); + this.label2.TabIndex = 0; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(100, 23); + this.label1.TabIndex = 0; + // + // panel1 + // + this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); + this.panel1.Controls.Add(this.button1); + this.panel1.Controls.Add(this.richTextBox1); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 461); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(421, 100); + this.panel1.TabIndex = 1; + // + // button1 + // + this.button1.BackColor = System.Drawing.Color.White; + this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.button1.Location = new System.Drawing.Point(331, 4); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(85, 90); + this.button1.TabIndex = 1; + this.button1.Text = "Verstuur"; + this.button1.UseVisualStyleBackColor = false; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // richTextBox1 + // + this.richTextBox1.BackColor = System.Drawing.Color.White; + this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.richTextBox1.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.richTextBox1.Location = new System.Drawing.Point(4, 4); + this.richTextBox1.MaxLength = 250; + this.richTextBox1.Name = "richTextBox1"; + this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None; + this.richTextBox1.Size = new System.Drawing.Size(321, 90); + this.richTextBox1.TabIndex = 0; + this.richTextBox1.Text = ""; + this.richTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBox_KeyDown); + // + // panel3 + // + this.panel3.AutoScroll = true; + this.panel3.BackColor = System.Drawing.Color.White; + this.panel3.Controls.Add(this.flowLayoutPanel1); + this.panel3.Dock = System.Windows.Forms.DockStyle.Top; + this.panel3.Location = new System.Drawing.Point(0, 0); + this.panel3.Name = "panel3"; + this.panel3.Size = new System.Drawing.Size(421, 459); + this.panel3.TabIndex = 2; + // + // container + // + this.container.Controls.Add(this.panel1); + this.container.Controls.Add(this.panel3); + this.container.Dock = System.Windows.Forms.DockStyle.Fill; + this.container.Location = new System.Drawing.Point(0, 0); + this.container.Name = "container"; + this.container.Size = new System.Drawing.Size(421, 561); + this.container.TabIndex = 3; + this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.panel3_MouseWheel); + } + + private void button1_Click(object sender, EventArgs e) + { + 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)); + richTextBox1.ResetText(); + } + } + + private void panel3_MouseWheel(object sender, MouseEventArgs e) + { + panel3.Focus(); + } + + private void FlowLayoutPanel1_SizeChanged(object sender, System.EventArgs e) + { + if (flowLayoutPanel1.Size.Height > panel3.Size.Height) + { + panel2.Width = 390; + panel3.VerticalScroll.Value = panel3.VerticalScroll.Maximum; + } + } + + private void TextBox_KeyDown(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Enter) + { + button1_Click(this, new EventArgs()); + } } } }