Пример #1
0
 private void chatWindowToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (_Controller != null)
         {
             ChatDialog c = new ChatDialog(_Controller);
             List<string> dm_list = DDD_Global.Instance.DM_List;
             dm_list.Remove(DDD_Global.Instance.PlayerID);
             c.Members = dm_list;
             if (c.ShowProperties() == DialogResult.OK)
             {
                 List<string> selected = c.SelectedMembers;
                 if (selected != null)
                 {
                     if (selected.Count > 0)
                     {
                         selected.Add(DDD_Global.Instance.PlayerID);
                         _Controller.RequestChatRoomCreate(c.GroupId, selected, DDD_Global.Instance.PlayerID);
                     }
                     else
                     {
                         MessageBox.Show("At least one DM is necessary to create a chat room.", "Chat Room Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                 }
             }
             c.Dispose();
         }
     }
     catch (Exception exc)
     {
         throw new Exception(exc.Message);
     }
 }
Пример #2
0
        public void CreateChatRoom(string tab_name, string room_name, List<string> membership_list)
        {
            try
            {
                if (!IsDisposed)
                {
                    if (!InvokeRequired)
                    {
                        try
                        {
                            if (_Controller != null && !(TabControls.TabPages.ContainsKey(room_name)))
                            {
                                ChatDialog c = new ChatDialog(_Controller);
                                c.GroupId = tab_name;
                                c.Channel = room_name;
                                c.Members = membership_list;
                                c.AllowPropertyChanges = false;
                                TabControls.TabPages.Add(room_name, tab_name);
                                TabControls.TabPages[room_name].Controls.Add(c);
                            }
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show(e.Message, "Unable to create chat room.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                    }
                    else
                    {
                        BeginInvoke(new CreateChatRoomDelegate(CreateChatRoom), tab_name, room_name, membership_list);
                    }
                }
            }
            catch (Exception exc)
            {
                throw new Exception(exc.Message);
            }
        }