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(); }
public override void send(Message msg) { var ret = client.Send(msg.ToBytes(), msg.ToBytes().Length, ep); }
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); } }
public abstract void send(Message msg);
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); }