From 9d7555c0bc77e9c32292f15a6bbb86e73d82fff6 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 13 Feb 2017 17:24:15 -0500 Subject: My hands are fixing bugs. --- ShiftOS.WinForms/Applications/Chat.cs | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'ShiftOS.WinForms/Applications/Chat.cs') diff --git a/ShiftOS.WinForms/Applications/Chat.cs b/ShiftOS.WinForms/Applications/Chat.cs index da68fc6..6c7528c 100644 --- a/ShiftOS.WinForms/Applications/Chat.cs +++ b/ShiftOS.WinForms/Applications/Chat.cs @@ -70,20 +70,30 @@ namespace ShiftOS.WinForms.Applications public void SendMessage(string msg) { - rtbchat.AppendText($"[{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}] {msg}{Environment.NewLine}"); + if (!string.IsNullOrWhiteSpace(msg)) + { + rtbchat.AppendText($"[{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}] {msg}{Environment.NewLine}"); - ServerManager.SendMessage("chat_send", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatMessage(SaveSystem.CurrentSave.Username, SaveSystem.CurrentSave.SystemName, msg, id))); + ServerManager.SendMessage("chat_send", JsonConvert.SerializeObject(new ShiftOS.Objects.ChatMessage(SaveSystem.CurrentSave.Username, SaveSystem.CurrentSave.SystemName, msg, id))); + } + else + { + rtbchat.AppendText($"[sys@multiuserdomain] You can't send blank messages. (only you can see this)"); + } } + private string id = ""; public void OnLoad() { SendMessage("User has joined the chat."); + RefreshUserInput(); } public void OnSkinLoad() { + RefreshUserInput(); } public bool OnUnload() @@ -95,6 +105,12 @@ namespace ShiftOS.WinForms.Applications public void OnUpgrade() { + RefreshUserInput(); + } + + public void RefreshUserInput() + { + txtuserinput.Width = (tsbottombar.Width) - (btnsend.Width) - 15; } private void richTextBox1_KeyDown(object sender, KeyEventArgs e) @@ -108,10 +124,7 @@ namespace ShiftOS.WinForms.Applications { e.SuppressKeyPress = true; - var save = SaveSystem.CurrentSave; - - SendMessage(txtuserinput.Text); - txtuserinput.Text = ""; + btnsend_Click(sender, EventArgs.Empty); } } @@ -119,6 +132,15 @@ namespace ShiftOS.WinForms.Applications { rtbchat.SelectionStart = rtbchat.Text.Length; rtbchat.ScrollToCaret(); + tschatid.Text = id; + tsuserdata.Text = $"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}"; + RefreshUserInput(); + } + + private void btnsend_Click(object sender, EventArgs e) + { + SendMessage(txtuserinput.Text); + txtuserinput.Text = ""; } } } -- cgit v1.2.3