示例#1
0
 private void send_btn_Click(object sender, RoutedEventArgs e)
 {
     Message msg = new Message((byte)fontbox.SelectedIndex, (byte)colorbox.SelectedIndex, msgbox.Text);
     connection.send(msg);
     WriteHistory(msg, new Message(0, 0, "Do " + this.connection.ep.Address.ToString() + ": "));
     this.msghistory.ScrollToEnd();
     this.msgbox.Clear();
 }
示例#2
0
 public override void send(Message msg)
 {
     var ret = client.Send(msg.ToBytes(), msg.ToBytes().Length, ep);
 }
示例#3
0
        void WriteMessage(Message msg, Paragraph pg)
        {
            Message.Font font = (Message.Font)msg.font;
            Message.Color color = (Message.Color)msg.color;
            byte red = (byte)(color == Message.Color.Red ? 255 : 0);
            byte green = (byte)(color == Message.Color.Green ? 255 : 0);
            byte blue = (byte)(color == Message.Color.Blue ? 255 : 0);

            string emotes = "(:\\)|:\\()";
            string[] split = Regex.Split(msg.message, emotes);
            foreach( var str in split)
            {
                Run text;
                if( Regex.IsMatch(str, emotes) )
                {
                    switch(str)
                    {
                        case ":)":
                            text = new Run("J");
                            break;
                        default:
                        case ":(":
                            text = new Run("L");
                            break;
                    }
                    text.FontFamily = new FontFamily("Wingdings");
                }
                else
                {
                    text = new Run(str);
                    text.FontFamily = new FontFamily((string)((ComboBoxItem)this.fontbox.Items[(int)font]).Content);
                }
                text.Foreground = new SolidColorBrush(Color.FromRgb(red, green, blue));
                pg.Inlines.Add(text);
            }
        }
示例#4
0
 public abstract void send(Message msg);
示例#5
0
 void WriteHistory(Message msg, Message prefix = null)
 {
     var pg = new Paragraph();
     if( prefix != null )
     {
         WriteMessage(prefix, pg);
     }
     WriteMessage(msg, pg);
     this.msghistory.Document.Blocks.Add(pg);
 }