Beispiel #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String currentNick = lbActiveUsers.SelectedItem.ToString();

            Console.WriteLine(currentNick);
            OneClient client = users.Find(user => user.nick == currentNick);

            client.writer.WriteLine("disconnect||");  //! TUTAJ
            client.writer.Flush();
            RemoveUser(client);
        }
Beispiel #2
0
 private void lbActiveUsers_Click(object sender, EventArgs e)
 {
     try {
         String currentNick = lbActiveUsers.SelectedItem.ToString();
         Console.WriteLine(currentNick);
         OneClient client = users.Find(user => user.nick == currentNick);
         String    room   = client.room;
         tbRoomName.Text = room;
     }catch {
         Console.WriteLine("USER DISCONECTED");
     }
 }
Beispiel #3
0
        private void changeRoomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            String currentNick = lbActiveUsers.SelectedItem.ToString();

            Console.WriteLine(currentNick);
            OneClient client = users.Find(user => user.nick == currentNick);

            client.room = tbRoomName.Text.ToString();
            Console.WriteLine("room|" + tbRoomName.Text + "|");
            client.writer.WriteLine("room|" + tbRoomName.Text.ToString() + "|"); //! TUTAJ
            client.writer.Flush();
        }
Beispiel #4
0
        public void RemoveUser(OneClient disconnectClient)
        {
            Console.WriteLine("Removing USER");
            usersNames.Remove(disconnectClient.nick);
            users.Remove(disconnectClient);

            lbActiveUsers.Invoke(new MethodInvoker(delegate { lbActiveUsers.Items.Clear(); }));

            foreach (String user in usersNames)
            {
                lbActiveUsers.Invoke(new MethodInvoker(delegate { lbActiveUsers.Items.Add(user); }));
            }

            disconnectClient.messages.Abort();
        }
Beispiel #5
0
        public void SendToAllUsers(List <OneClient> users, string message, String senderNick)
        {
            String currentTime = DateTime.Now.ToString("HH:mm:ss");

            Console.WriteLine(message);
            Console.WriteLine(users.Count);

            if (message.StartsWith("//p"))
            {
                String[]  words   = message.Split(' ');
                OneClient dstUser = users.SingleOrDefault(dst => dst.nick == words[1]);
                if (dstUser == null)
                {
                    Console.WriteLine("USER NOT EXIST");
                    dstUser = users.SingleOrDefault(dst => dst.nick == senderNick);
                    dstUser.writer.WriteLine("||this user NOT EXIST");
                    dstUser.writer.Flush();
                }
                else
                {
                    dstUser.writer.WriteLine(currentTime + "|PRIV " + senderNick + "|" + message);
                    dstUser.writer.Flush();
                }
            }
            else if (message.StartsWith("//users"))
            {
                String    sUsers  = string.Join(" ", usersNames);
                OneClient dstUser = users.SingleOrDefault(dst => dst.nick == senderNick);
                dstUser.writer.WriteLine("||Users Now Online: " + "<b>" + sUsers + "</b>");
                dstUser.writer.Flush();
            }
            else
            {
                OneClient sender = users.Find(user => user.nick == senderNick);

                foreach (OneClient client in users)
                {
                    if (sender.room == client.room)
                    {
                        Console.WriteLine(client.nick);
                        Console.WriteLine("userzy +++");

                        client.writer.WriteLine(currentTime + "|" + senderNick + "|" + message);
                        client.writer.Flush();  // clear buffers
                    }
                }
            }
        }
Beispiel #6
0
        public ChatForm(OneClient _user)
        {
            user = _user;

            InitializeComponent();

            String styleOfwb = @"<style>body {
                margin: 0;
                padding: 0;
                display: block;
                position: relative;
                background-color: #353535;
                overflow: hiden;
            }
            document{
                overflow: hiden;
            }
            .me {
                width: 30%;
                float: right;
                width: 60%;
                background-color: #252525;
                color: white;
            }
            .you {
                background-color: #e53935;
                width: 30%;
                float: left;
                width: 60%;
            }

            .message {
                margin: 0;
                word-wrap: break-word;
                width: 68%; 
                font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode',
                    Geneva, Verdana, sans-serif;
                font-size: 2.8vw;
                float: left;
                margin-left: 2%;
            }
            .nick {
                margin: 0;
                margin-left: 2%;
                box-sizing: border-box;
                word-wrap: break-word;
                width: 30%;
                font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode',
                    Geneva, Verdana, sans-serif;
                font-size: 2.8vw;
                float: left;
                font-weight: bold;
            }
            .me, .you {
                box-sizing: border-box;
                margin: 1% 0;
                border: 0px solid;
                border-radius: 22px;
                padding: 8px;
            }
            .time {
                font-size: 1.5vw;
                font-family: monospace;
                width: 100%;
                text-align: center;
                font-weight: bold;
            }
            img{
                width: 35px;
                height: 35px;
            }
        </style>";

            wbMessages.DocumentText = styleOfwb;



            MaterialSkinManager materialManager = MaterialSkinManager.Instance;

            materialManager.AddFormToManage(this);
            materialManager.Theme       = MaterialSkinManager.Themes.DARK;
            materialManager.ColorScheme = new ColorScheme(Primary.DeepPurple400,
                                                          Primary.DeepPurple500, Primary.DeepPurple500, Accent.Pink400, TextShade.WHITE);
            materialManager.ColorScheme = new ColorScheme(Primary.Red600, Primary.Red800, Primary.Red400, Accent.Pink400, TextShade.WHITE);
        }