public Sc2tvChatSource() { LoadedMessages = new List <Message>(); Smiles = new SmilesDataDase(); SmilesUri = new Dictionary <string, string>(); //WebClient smile = new WebClient(); //smile.DownloadString(); }
public EmpireTvChatSource() { LoadedMessages = new List <Message>(); Smiles = new SmilesDataDase(); SmilesUri = new Dictionary <string, string>(); //WebClient smile = new WebClient(); //smile.DownloadString(); //_StreamerID = 9909; }
private bool CreateSmile(SmilesDataDase Db, string SmileId, WrapPanel TextPanel) { if (Properties.Settings.Default.hideSmiles) { return(false); } else { //int nn = SmileId.LastIndexOf(':'); //SmileId = SmileId.Substring(2, nn + 1 - 2) + " "; FrameworkElement s = Db.GetSmile(SmileId); if (s != null) { TextPanel.Children.Add(s); return(true); } } return(false); }
public void CreateChat(string ConfigPrefix, string SourceChatId) { if (!Sources.ContainsKey(SourceChatId)) { return; } RatChat.Core.IChatSource ichat = Activator.CreateInstance(Sources[SourceChatId]) as RatChat.Core.IChatSource; ichat.ConfigPrefix = ConfigPrefix; ichat.OnLoad(ChatConfigStorage); ichat.OnNewMessagesArrived += ichat_OnNewMessagesArrived; if (ichat.SmilesUri != null) { foreach (var smile in ichat.SmilesUri) { SmilesDataDase.AddSmileTuple(smile.Key, smile.Value); } } UserControl customView = ichat.CreateCustomView(); if (customView == null) { RatChat.Controls.VisualChatCtrl vchat = new Controls.VisualChatCtrl(); vchat.Manager = this; vchat.Tag = new Tuple <RatChat.Core.IChatSource, string>(ichat, SourceChatId); Chats.Add(vchat); vchat.ConnectToChatSource(ichat); } else { RatChat.Controls.CustomControlContainer vchat = new Controls.CustomControlContainer(); vchat.Manager = this; vchat.Tag = new Tuple <RatChat.Core.IChatSource, string>(ichat, SourceChatId); Chats.Add(vchat); vchat.ConnectToChatSource(customView, ichat); } RatChat.Core.IChatListener iListener = ichat as RatChat.Core.IChatListener; if (iListener != null) { // При добавлении Listener, ищу ВСЕ Source и подписываюсь foreach (FrameworkElement fe in Chats) { RatChat.Core.IChatSource i = ((Tuple <RatChat.Core.IChatSource, string>)fe.Tag).Item1; i.OnNewMessagesArrived += iListener.OnNewMessageReceived; } } else { // При добавлении Source, ищу ВСЕ Listeners и подписываю foreach (FrameworkElement fe in Chats) { RatChat.Core.IChatSource i = ((Tuple <RatChat.Core.IChatSource, string>)fe.Tag).Item1; RatChat.Core.IChatListener il = i as RatChat.Core.IChatListener; if (il != null) { ichat.OnNewMessagesArrived += il.OnNewMessageReceived; } //i.OnNewMessagesArrived += iListener.OnNewMessageReceived; } } }
public VisualMessage(IChatSource Source, 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); } this.ToMe = TalkTo == Source.StreamerNick; if (this.ToMe) { 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; ISmileCreator creator = Source as ISmileCreator; 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 (creator != null) { if (!creator.CreateSmile(ttt[j], wp)) { ttt[j] += ' '; AddWord(wp, ttt, j); } } else { ttt[j] += ' '; if (!CreateSmile(Db, ttt[j], wp)) { AddWord(wp, ttt, j); } } } } //} 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; }