From d75419d92e3cbb267d4ed7119b293eebdc8d3184 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Mon, 19 Oct 2015 18:53:10 +0200 Subject: [PATCH] Move ChatItem to library --- ErgometerLibrary/Chat/ChatItem.cs | 63 ++++++++++++++++++++++++ ErgometerLibrary/ErgometerLibrary.csproj | 5 ++ 2 files changed, 68 insertions(+) create mode 100644 ErgometerLibrary/Chat/ChatItem.cs diff --git a/ErgometerLibrary/Chat/ChatItem.cs b/ErgometerLibrary/Chat/ChatItem.cs new file mode 100644 index 0000000..55da46f --- /dev/null +++ b/ErgometerLibrary/Chat/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 ErgometerLibrary.Chat +{ + public class ChatItem : Panel + { + private Label messageLabel, timeLabel; + + public ChatItem(ChatMessage chat) : base() + { + this.messageLabel = new Label(); + this.timeLabel = new Label(); + + this.AutoSize = true; + this.setAppearance(chat.IsDoctor); + this.Controls.Add(this.messageLabel); + this.Controls.Add(this.timeLabel); + this.MinimumSize = new System.Drawing.Size(150, 60); + 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(250, 0); + this.messageLabel.Size = new System.Drawing.Size(121, 20); + this.messageLabel.Text = chat.Message.Replace("\n", ""); + // + // 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 = Helper.MillisecondsToTime(chat.TimeStamp); + } + + 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/ErgometerLibrary/ErgometerLibrary.csproj b/ErgometerLibrary/ErgometerLibrary.csproj index f53e6dc..a1c062a 100644 --- a/ErgometerLibrary/ErgometerLibrary.csproj +++ b/ErgometerLibrary/ErgometerLibrary.csproj @@ -36,6 +36,8 @@ + + @@ -45,6 +47,9 @@ + + Component +