void RegisterVote( ChatMessage Message ) { if (Result.ContainsKey(Message.Name)) return; int vote = -1; for (int j = 0; j < Variants.Count; ++j) if (Message.Text.Contains(Variants[j].Select)) { vote = j + 1; Variants[j].Votes++; Result[Message.Name] = vote; break; } //if (vote != -1) // for (int j = 0; j < Variants.Count; ++j) // Variants[j].History.Add(Variants[j].Votes); }
public VisualMessage( string StreamerNick, SmilesDataDase Db, ChatMessage Data ) { this.Data = Data; List<Uri> Urls = new List<Uri>(); string UserText = Data.Text;// HttpUtility.HtmlDecode(Data.Text.Replace(":s:", " :s:").Replace(" ", " ")); UserText = UriDetector.Replace( UserText, new MatchEvaluator(( m ) => { Urls.Add(new Uri(m.Value, UriKind.RelativeOrAbsolute)); return LinkReplacer + " "; }) ); // parse text WrapPanel wp = new WrapPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal, }; List<string> ttt = new List<string>(); // Тоже странный кусок: int nxd = UserText.IndexOf("<b>"); if (nxd >= 0) { int nxd2 = UserText.IndexOf("</b>"); TalkTo = UserText.Substring(nxd + 3, nxd2 - nxd - 3); if (UserText.Length <= (nxd2 + 6)) { UserText = ""; } else { UserText = UserText.Substring(nxd2 + 6); } if (TalkTo == StreamerNick) { wp.SetResourceReference(WrapPanel.StyleProperty, "StreamerContainer"); } else { wp.SetResourceReference(WrapPanel.StyleProperty, "NormalTextContainer"); } ttt.Add(TalkTo + ","); } else { TalkTo = ""; } ttt.AddRange(UserText.Split(' ')); // if (UseLabel) { Label name = new Label() { Content = Data.Name + ": " }; name.SetResourceReference(Label.StyleProperty, "LabelNameStyle"); wp.Children.Add(name); int linkIndex = 0; for (int j = 0; j < ttt.Count; ++j) { if (ttt[j] == LinkReplacer) { Label link = new Label() { Content = "link ", Cursor = Cursors.Hand, ToolTip = Urls[linkIndex], Tag = Urls[linkIndex] }; link.SetResourceReference(Label.StyleProperty, "LabelLinkStyle"); link.MouseLeftButtonUp += ( sender, b ) => { Uri u = ((Label)sender).Tag as Uri; System.Diagnostics.Process.Start(u.ToString()); }; wp.Children.Add(link); linkIndex++; } else { //if (j != (ttt.Count - 1)) ttt[j] += ' '; if (CreateSmile(Db, ttt[j], wp)) { // Ура смайл ебать есть } else { Label txt = new Label() { Content = ttt[j] }; if (TalkTo + ", " == ttt[j]) { txt.SetResourceReference(Label.StyleProperty, "LabelNameTextStyle"); } else { txt.SetResourceReference(Label.StyleProperty, "LabelTextStyle"); } wp.Children.Add(txt); } } } //} else { // TextBlock name = new TextBlock() { Text = Data.Name + ": " }; // name.SetResourceReference(TextBlock.StyleProperty, "NameStyle"); // wp.Children.Add(name); // int linkIndex = 0; // for (int j = 0; j < ttt.Count; ++j) { // if (ttt[j] == LinkReplacer) { // TextBlock link = new TextBlock() { // Text = "link ", // Cursor = Cursors.Hand, // ToolTip = Urls[linkIndex], // Tag = Urls[linkIndex] // }; // link.SetResourceReference(TextBlock.StyleProperty, "LinkStyle"); // link.MouseLeftButtonUp += ( sender, b ) => { // Uri u = ((TextBlock)sender).Tag as Uri; // System.Diagnostics.Process.Start(u.ToString()); // }; // wp.Children.Add(link); // linkIndex++; // } else { // //if (j != (ttt.Count - 1)) // ttt[j] += ' '; // if (CreateSmile(Db, ttt[j], wp)) { // // Ура смайл ебать есть // } else { // TextBlock txt = new TextBlock() { Text = ttt[j] }; // if (TalkTo + ", " == ttt[j]) { // txt.SetResourceReference(TextBlock.StyleProperty, "NameTextStyle"); // } else { // txt.SetResourceReference(TextBlock.StyleProperty, "TextStyle"); // } // wp.Children.Add(txt); // } // } // } //} Text = wp; }
internal void NewMessage( FluorineFx.ASObject msg ) { string ChatText = msg["text"].ToString(); DateTime time = DateTime.Parse(msg["time"].ToString()); var Name = msg["sender"] as FluorineFx.ASObject; string Sender = Name["name"].ToString(); Console.WriteLine(Sender + " [" + time.ToString() + "] - " + ChatText); ChatMessage chatMessage = new ChatMessage() { Date = time, Name = Sender, Text = ChatText }; if (OnNewMessagesArrived != null) { List<ChatMessage> l = new List<ChatMessage>(); l.Add(chatMessage); OnNewMessagesArrived(l); } }
public void OnChatMessate( ChatMessage Message ) { PekaCount += Message.Text.CountSubstring(":s:peka:"); Temperature -= 0.01; Temperature = Temperature + Message.Text.CountSubstring(":s:fire:") * 10; if (Message.Name == "Nalan") Temperature = -1000; Depth = Depth - Message.Text.CountSubstring(":s:crab:") * 5 - Message.Text.CountSubstring(":s:fp:") * 3 - Message.Text.CountSubstring(":s:fpl:") * 10 - Message.Text.CountSubstring(":s:mimo:") + Message.Text.CountSubstring(":s:fyeah:") * 10 + Message.Text.CountSubstring(":s:bm:") * 5 + Message.Text.CountSubstring(":s:notbad:") * 2; }