Beispiel #1
0
        private void sendMessage()
        {
            string s;

            s  = "$sm$";
            s += mailRemote;
            s += "$sm$";

            for (int i = 0; i < richTextBoxMessage.Text.Length; i++)
            {
                if (richTextBoxMessage.Text[i] == ' ')
                {
                    richTextBoxMessage.Select(i, 1);
                    if ((richTextBoxMessage.SelectionType & RichTextBoxSelectionTypes.Object) == RichTextBoxSelectionTypes.Object)
                    {
                        Clipboard.Clear();
                        richTextBoxMessage.Copy();
                        Bitmap temp = (Bitmap)Clipboard.GetData("Bitmap");
                        foreach (Bitmap b in emotions.Values)
                        {
                            if (temp.GetPixel(17, 19) == b.GetPixel(17, 19) &&
                                temp.GetPixel(6, 12) == b.GetPixel(6, 12))
                            {
                                s += emotions.FirstOrDefault(x => x.Value == b).Key;
                            }
                        }
                    }
                    else
                    {
                        s += richTextBoxMessage.Text[i];
                    }
                }
                else
                {
                    s += richTextBoxMessage.Text[i];
                }
            }

            wc.SendString(s + "$$$$");
            s = s.Substring(4);
            s = s.Substring(s.IndexOf("$sm$") + 4);
            richTextBoxChat.AppendText("\nTú: " + s);
            foreach (string emote in emotions.Keys)
            {
                while (richTextBoxChat.Text.Contains(emote))
                {
                    int ind = richTextBoxChat.Text.IndexOf(emote);
                    richTextBoxChat.Select(ind, emote.Length);
                    Clipboard.SetImage((Image)emotions[emote]);
                    richTextBoxChat.Paste();
                }
            }
            richTextBoxChat.ScrollToCaret();
            richTextBoxMessage.Text = "";
            richTextBoxMessage.Focus();
        }
Beispiel #2
0
        public WindowChat(string s)
        {
            InitializeComponent();

            sp = new SoundPlayer(Properties.Resources.zumbido);


            foreach (WindowContacts f in Application.OpenForms.OfType <WindowContacts>())
            {
                wc = f;
            }

            mail.From  = new MailAddress("*****@*****.**");
            mailRemote = s;

            wc.SendString("$ip$" + s
                          + "$ip$" + wc.myUdpIp + "$$$$");


            labelClientReceiver.Text = s;
            labelUserName.Text       = globals.username;

            this.Text = s;

            globals.receivedText = null;
            wc.SendString("$gm$" + s + "$$$$");

            BuscarDispositivos();


            emotions = new Dictionary <string, Bitmap>(16);
            emotions.Add(":)", Properties.Resources.emoticons01);
            emotions.Add(":D", Properties.Resources.emoticons02);
            emotions.Add(";)", Properties.Resources.emoticons03);
            emotions.Add(":o", Properties.Resources.emoticons04);
            emotions.Add(":p", Properties.Resources.emoticons05);
            emotions.Add("8)", Properties.Resources.emoticons06);
            emotions.Add(">:(", Properties.Resources.emoticons07);
            emotions.Add(":s", Properties.Resources.emoticons08);
            emotions.Add(":$", Properties.Resources.emoticons09);
            emotions.Add(":(", Properties.Resources.emoticons10);
            emotions.Add(":'(", Properties.Resources.emoticons11);
            emotions.Add(":|", Properties.Resources.emoticons12);
            emotions.Add("<3", Properties.Resources.emoticons13);
            emotions.Add("</3", Properties.Resources.emoticons14);
            emotions.Add(":3", Properties.Resources.emoticons15);
            emotions.Add(":*", Properties.Resources.emoticons16);
            groupBoxEmoticons.Visible = false;
        }
Beispiel #3
0
        public GroupChat(List <string> users)
        {
            InitializeComponent();

            foreach (WindowContacts f in Application.OpenForms.OfType <WindowContacts>())
            {
                wc = f;
            }

            labelContactName.Text = "";

            labelUserName.Text = globals.username;

            if (users == null)
            {
                participants = new List <string>();
                participants.Add(globals.username);
            }
            else
            {
                participants = users;
            }

            participants.Sort();

            this.Text = "Integrantes: ";

            bool isFrist = true;

            foreach (string user in participants)
            {
                if (isFrist)
                {
                    isFrist    = false;
                    this.Text += user;
                }
                else
                {
                    this.Text += ", " + user;
                }

                if (!user.Equals(globals.username))
                {
                    wc.SendString("$ip$" + user + "$ip$" + wc.myUdpIp + "$$$$");
                }
            }

            globals.receivedText = null;
            emotions             = new Dictionary <string, Bitmap>(16);
            emotions.Add(":)", Properties.Resources.emoticons01);
            emotions.Add(":D", Properties.Resources.emoticons02);
            emotions.Add(";)", Properties.Resources.emoticons03);
            emotions.Add(":o", Properties.Resources.emoticons04);
            emotions.Add(":p", Properties.Resources.emoticons05);
            emotions.Add("8)", Properties.Resources.emoticons06);
            emotions.Add(">:(", Properties.Resources.emoticons07);
            emotions.Add(":s", Properties.Resources.emoticons08);
            emotions.Add(":$", Properties.Resources.emoticons09);
            emotions.Add(":(", Properties.Resources.emoticons10);
            emotions.Add(":'(", Properties.Resources.emoticons11);
            emotions.Add(":|", Properties.Resources.emoticons12);
            emotions.Add("<3", Properties.Resources.emoticons13);
            emotions.Add("</3", Properties.Resources.emoticons14);
            emotions.Add(":3", Properties.Resources.emoticons15);
            emotions.Add(":*", Properties.Resources.emoticons16);
            groupBoxEmoticons.Visible = false;
        }