From f483997d33bc59fccfc2cb967d0bef2e29448a02 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 12 Feb 2017 20:13:06 -0500 Subject: New chat client-side. --- ShiftOS.WinForms/Applications/MUDControlCentre.cs | 75 +++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'ShiftOS.WinForms/Applications/MUDControlCentre.cs') diff --git a/ShiftOS.WinForms/Applications/MUDControlCentre.cs b/ShiftOS.WinForms/Applications/MUDControlCentre.cs index 6336718..f2d5e77 100644 --- a/ShiftOS.WinForms/Applications/MUDControlCentre.cs +++ b/ShiftOS.WinForms/Applications/MUDControlCentre.cs @@ -78,6 +78,13 @@ namespace ShiftOS.WinForms.Applications myLegionToolStripMenuItem_Click(this, EventArgs.Empty); })); } + else if(msg.Name == "chat_all") + { + this.Invoke(new Action(() => + { + this.ListAllChats(JsonConvert.DeserializeObject(msg.Contents)); + })); + } else if (msg.Name == "user_shop_check_result") { if (msg.Contents == "0") @@ -169,6 +176,69 @@ namespace ShiftOS.WinForms.Applications }; } + public void ListAllChats(Channel[] channels) + { + shop_all.BringToFront(); + + flshoplist.Controls.Clear(); + + foreach (var shop in channels) + { + var bnr = new Panel(); + bnr.Height = 100; + bnr.Tag = "keepbg"; + + bnr.Width = flshoplist.Width; + + var lTitle = new Label(); + lTitle.AutoSize = true; + lTitle.Tag = "keepbg header2"; + lTitle.Text = shop.Name; + lTitle.Location = new Point(18, 17); + bnr.Controls.Add(lTitle); + lTitle.Show(); + var desc = new Label(); + desc.Text = shop.Topic; + bnr.Controls.Add(desc); + desc.Show(); + + var flButtons = new FlowLayoutPanel(); + flButtons.AutoSize = true; + flButtons.AutoSizeMode = AutoSizeMode.GrowAndShrink; + flButtons.Tag = "keepbg"; + flButtons.FlowDirection = FlowDirection.RightToLeft; + flButtons.Anchor = AnchorStyles.Top | AnchorStyles.Right; + flButtons.Top = 2; + flButtons.Left = bnr.Width - flButtons.Width - 2; + bnr.Controls.Add(flButtons); + flButtons.Show(); + + var btn = new Button(); + btn.Text = "Browse"; + btn.Click += (o, a) => + { + OpenChat(shop.ID); + }; + flButtons.Controls.Add(btn); + btn.Show(); + + flshoplist.Controls.Add(bnr); + bnr.Show(); + ControlManager.SetupControls(bnr); + desc.Left = lTitle.Left; + desc.Width = (bnr.Width - desc.Left - desc.Left); + desc.Top = lTitle.Top + lTitle.Height; + desc.Height = (bnr.Height - lTitle.Top); + + } + + } + + public void OpenChat(string id) + { + AppearanceManager.SetupWindow(new Chat(id)); + } + private Shop editingShop = null; private string editingShopOldName = ""; @@ -782,5 +852,10 @@ Current legions: {legionname}"; shop_editor.BringToFront(); PopulateShopEditor(); } + + private void joinAChatToolStripMenuItem_Click(object sender, EventArgs e) + { + ServerManager.SendMessage("chat_getallchannels", ""); + } } } -- cgit v1.2.3