Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            txtUsername.Text = "Username";
            txtPassword.Text = "Password";
            User user_Dajana    = new User("dajana", "Dajana Stojchevska", "lala", "*****@*****.**", "female", "17/01/1996", "I love chocolates.");
            User user_Viktorija = new User("viki", "Viktorija Velinovska", "viktorija", "*****@*****.**", "female", "27/01/1996", "I love rainbow colors.");

            user_Dajana.AddMessage(user_Viktorija, new Message("Dajana", "Hi!"));
            user_Viktorija.AddMessage(user_Dajana, new Message("Dajana", "Hi!"));
            user_Viktorija.AddMessage(user_Dajana, new Message("Viktorija", "Hey"));
            user_Dajana.AddMessage(user_Viktorija, new Message("Viktorija", "Hey"));
            user_Viktorija.AddMessage(user_Dajana, new Message("Viktorija", "What's up?"));
            user_Dajana.AddMessage(user_Viktorija, new Message("Viktorija", "What's up?"));
            if (!users.ContainsKey(user_Dajana.username))
            {
                users.Add(user_Dajana.username, user_Dajana);
            }
            if (!users.ContainsKey(user_Viktorija.username))
            {
                users.Add(user_Viktorija.username, user_Viktorija);
            }
            if (!users.ContainsKey("bot1"))
            {
                users.Add("bot1", new User("bot1", "Bot Robot", "pas", "email", "male", "15/03/2005", "I love me."));
            }
            if (!users.ContainsKey("bot2"))
            {
                users.Add("bot2", new User("bot2", "Superbot Botovski", "pas", "email", "female", "15/12/1985", "I love me."));
            }
        }
Exemple #2
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            lstMessages.Items.Add(txtChat.Text);
            List <Message> inbox;

            if (!active.inbox.TryGetValue(selected.username, out inbox))
            {
                inbox = new List <Message>();
            }
            string[] n   = active.fullname.Split(' ');
            Message  msg = new Message(n[0], txtChat.Text);

            if (users.TryGetValue(selected.username, out selected))
            {
                selected.AddMessage(active, msg);
            }
            if (users.TryGetValue(active.username, out active))
            {
                active.AddMessage(selected, msg);
            }
            Load_Messages();
            txtChat.Clear();
        }