private void Eval_Emote(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); String text = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); AresFont font = null; if (u != null) { if (u.Ignored) { return; } if (u.Font != null) { font = u.Font; } } text = ScriptEvents.OnEmoteReceiving(this, name, text); if (!String.IsNullOrEmpty(text)) { this.Panel.EmoteText(name, text, font); this.Panel.CheckUnreadStatus(); ScriptEvents.OnEmoteReceived(this, name, text); } }
public void ShowPMText(String name, String text, AresFont font) { if (this.InvokeRequired) { this.BeginInvoke(new Action <String, String, AresFont>(this.ShowPMText), name, text, font); } else { if (this.IsPaused) { this.paused_items.Add(new PausedItem { Type = PausedItemType.PM, Name = name, Text = text }); return; } bool ts = Settings.GetReg <bool>("can_timestamp", false); AresFont name_font = null; if (font != null) { name_font = new AresFont(); name_font.FontName = font.FontName; name_font.NameColor = font.NameColor; name_font.TextColor = font.NameColor; name_font.Size = font.Size; } this.Render((ts ? (Helpers.Timestamp + name) : name) + ":", null, true, GlobalSettings.GetDefaultColorInt(GlobalSettings.DefaultColorType.Name, this.IsBlack), name_font); this.Render(" " + text, null, true, GlobalSettings.GetDefaultColorInt(GlobalSettings.DefaultColorType.PM, this.IsBlack), font); } }
public AresFont Copy() { AresFont f = new AresFont(); f.NameColor = "#" + this.NameColor; f.TextColor = "#" + this.TextColor; f.FontName = this.FontName; f.Size = this.Size; return(f); }
private void Eval_Font(TCPPacketReader packet) { String name = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); if (u != null) { if (packet.Remaining > 2) { AresFont f = new AresFont(); f.Size = (int)((byte)packet); f.FontName = packet.ReadString(this.crypto); byte oldN = packet; byte oldT = packet; if (oldN == 255 || oldT == 255) { u.Font = null; return; } if (this.new_sbot) { if (packet.Remaining > 0) { f.NameColor = packet.ReadString(this.crypto); } if (packet.Remaining > 0) { f.TextColor = packet.ReadString(this.crypto); } } if (String.IsNullOrEmpty(f.NameColor)) { f.NameColor = Helpers.AresColorToHTMLColor(oldN); } if (String.IsNullOrEmpty(f.TextColor)) { f.TextColor = Helpers.AresColorToHTMLColor(oldT); } if (ScriptEvents.OnUserFontChanging(this, u, f)) { u.Font = f; } } else { u.Font = null; } } }
public void MyPMText(String text, AresFont font) { this.tabControl1.BeginInvoke((Action)(() => { if (this.tabControl1.SelectedTab != null) { if (this.tabControl1.SelectedTab is PMTab) { ((PMTab)this.tabControl1.SelectedTab).PM(this.MyName, text, font); } } })); }
public void ShowEmoteText(String name, String text, AresFont font) { if (this.InvokeRequired) { this.BeginInvoke(new Action <String, String, AresFont>(this.ShowEmoteText), name, text, font); } else { if (this.IsPaused) { this.paused_items.Add(new PausedItem { Type = PausedItemType.Emote, Name = name, Text = text }); return; } this.cls_count = 0; bool ts = Settings.GetReg <bool>("can_timestamp", false); this.Render((ts ? Helpers.Timestamp : "") + "* " + name + " " + text, null, false, GlobalSettings.GetDefaultColorInt(GlobalSettings.DefaultColorType.Emote, this.IsBlack), font); } }
private void Eval_Private(TCPPacketReader packet) { if (!Settings.GetReg <bool>("can_receive_pms", true)) { return; } String name = packet.ReadString(this.crypto); String text = packet.ReadString(this.crypto); User u = this.users.Find(x => x.Name == name); if (u == null) { return; } AresFont font = null; if (u.Font != null) { font = u.Font; } if (u.Ignored) { return; } text = ScriptEvents.OnPmReceiving(this, u, text); if (!String.IsNullOrEmpty(text)) { this.Panel.PMTextReceived(this, u, name, text, font, PMTextReceivedType.Text); this.Panel.CheckUnreadStatus(); ScriptEvents.OnPmReceived(this, u, text); } }
private void Eval_cb0t_pm_msg(User user, byte[] data) { if (!Settings.GetReg <bool>("can_receive_pms", true)) { return; } String name = user.Name; String text = Encoding.UTF8.GetString(PMCrypto.SoftDecrypt(this.MyName, data)); User u = this.users.Find(x => x.Name == name); if (u == null) { return; } if (u.Ignored) { return; } AresFont font = null; if (u.Font != null) { font = u.Font; } text = ScriptEvents.OnPmReceiving(this, u, text); if (!String.IsNullOrEmpty(text)) { this.Panel.PMTextReceived(this, u, name, text, font, PMTextReceivedType.Text); this.Panel.CheckUnreadStatus(); ScriptEvents.OnPmReceived(this, u, text); } }
public void MyPMJSText(String target, String text, AresFont font) { if (this.tabControl1.InvokeRequired) { this.tabControl1.BeginInvoke(new MyPMJSTextHandler(this.MyPMJSText), target, text, font); } else { for (int i = 0; i < this.tabControl1.TabPages.Count; i++) { if (this.tabControl1.TabPages[i] is PMTab) { if (this.tabControl1.TabPages[i].Text == target) { PMTab tab = (PMTab)this.tabControl1.TabPages[i]; tab.PM(this.MyName, text, font); tab.SetRead(this.Mode == ScreenMode.PM && this.PMName == target); return; } } } PMTab new_tab = new PMTab(target, this.EndPoint); if (this.IsBlack) { new_tab.SetToBlack(); } new_tab.HashlinkClicked += this.LinkHashlinkClicked; new_tab.EditScribbleClicked += this.DoEditScribbleClicked; new_tab.ImageIndex = 2; this.tabControl1.TabPages.Add(new_tab); new_tab.PM(this.MyName, text, font); } }
private void Render(String txt, String name, bool can_col, int first_col, AresFont _ff) { String text = txt.Replace("\r\n", "\r").Replace("\n", "\r").Replace("", "").Replace("]̽", "").Replace(" ̽", "").Replace("͊", "").Replace("]͊", "").Replace("͠", "").Replace("̶", "").Replace("̅", ""); List <Color> cols = new List <Color>(); StringBuilder rtf = new StringBuilder(); int col_index; String bg_test; AresFont ff = _ff; if (!Settings.GetReg <bool>("receive_ppl_fonts", true)) { ff = null; } if (ff == null) { cols.Add(this.GetColorFromCode(first_col)); } else { bg_test = ff.TextColor.ToUpper().Replace("#", String.Empty); if (bg_test == "000000" && this.IsBlack) { bg_test = "#FFFFFF"; } else if (bg_test == "FFFFFF" && !this.IsBlack) { bg_test = "#000000"; } else { bg_test = ff.TextColor; } cols.Add(this.HTMLColorToColor(bg_test)); } rtf.Append("\\cf1 "); if (this.GetColorIndex(ref cols, this.IsBlack ? Color.Black : Color.White) == -1) { cols.Add(this.IsBlack ? Color.Black : Color.White); rtf.Append("\\highlight2 "); } else { rtf.Append("\\highlight1 "); } char[] letters = text.ToCharArray(); bool bold = false, italic = false, underline = false; bool can_emoticon = Settings.GetReg <bool>("can_emoticon", true); int emote_count = 0; Color back_color = this.IsBlack ? Color.Black : Color.White; bool bg_code_used = false; EmojiItem emojiitem; String tmp; int itmp; using (Graphics richtextbox = this.CreateGraphics()) { for (int i = 0; i < letters.Length; i++) { switch (letters[i]) { case '\x0006': bold = !bold; rtf.Append(bold ? "\\b" : "\\b0"); break; case '\x0007': underline = !underline; rtf.Append(underline ? "\\ul" : "\\ul0"); break; case '\x0009': italic = !italic; rtf.Append(italic ? "\\i" : "\\i0"); break; case '\x03': if (letters.Length >= (i + 8)) { tmp = text.Substring((i + 1), 7); if (Helpers.IsHexCode(tmp)) { if (!bg_code_used) { if (this.IsBlack && tmp == "#000000") { itmp = 0; } else if (!this.IsBlack && tmp.ToUpper() == "#FFFFFF") { itmp = 1; } } col_index = this.GetColorIndex(ref cols, this.HTMLColorToColor(tmp)); if (col_index > -1) { rtf.Append("\\cf0\\cf" + (col_index + 1) + " "); } else { cols.Add(this.HTMLColorToColor(tmp)); rtf.Append("\\cf0\\cf" + cols.Count + " "); } i += 7; break; } } if (letters.Length >= (i + 3)) { tmp = text.Substring((i + 1), 2); if (int.TryParse(tmp, out itmp)) { if (!bg_code_used) { if (this.IsBlack && itmp == 1) { itmp = 0; } else if (!this.IsBlack && itmp == 0) { itmp = 1; } } col_index = this.GetColorIndex(ref cols, this.GetColorFromCode(itmp)); if (col_index > -1) { rtf.Append("\\cf0\\cf" + (col_index + 1) + " "); } else { cols.Add(this.GetColorFromCode(itmp)); rtf.Append("\\cf0\\cf" + cols.Count + " "); } i += 2; break; } } goto default; case '\x05': if (letters.Length >= (i + 8)) { tmp = text.Substring((i + 1), 7); if (Helpers.IsHexCode(tmp)) { back_color = this.HTMLColorToColor(tmp); col_index = this.GetColorIndex(ref cols, back_color); if (col_index > -1) { rtf.Append("\\highlight0\\highlight" + (col_index + 1) + " "); } else { cols.Add(back_color); rtf.Append("\\highlight0\\highlight" + cols.Count + " "); } bg_code_used = true; i += 7; break; } } if (letters.Length >= (i + 3)) { tmp = text.Substring((i + 1), 2); if (int.TryParse(tmp, out itmp)) { back_color = this.GetColorFromCode(itmp); col_index = this.GetColorIndex(ref cols, back_color); if (col_index > -1) { rtf.Append("\\highlight0\\highlight" + (col_index + 1) + " "); } else { cols.Add(back_color); rtf.Append("\\highlight0\\highlight" + cols.Count + " "); } bg_code_used = true; i += 2; break; } } goto default; case (char)35: case (char)48: case (char)49: case (char)50: case (char)51: case (char)52: case (char)53: case (char)54: case (char)55: case (char)56: case (char)57: case (char)169: case (char)174: case (char)55356: case (char)55357: case (char)8252: case (char)8265: case (char)8482: case (char)8505: case (char)8596: case (char)8597: case (char)8598: case (char)8599: case (char)8600: case (char)8601: case (char)8617: case (char)8618: case (char)8986: case (char)8987: case (char)9193: case (char)9194: case (char)9195: case (char)9196: case (char)9200: case (char)9203: case (char)9410: case (char)9642: case (char)9643: case (char)9654: case (char)9664: case (char)9723: case (char)9724: case (char)9725: case (char)9726: case (char)9728: case (char)9729: case (char)9742: case (char)9745: case (char)9748: case (char)9749: case (char)9757: case (char)9786: case (char)9800: case (char)9801: case (char)9802: case (char)9803: case (char)9804: case (char)9805: case (char)9806: case (char)9807: case (char)9808: case (char)9809: case (char)9810: case (char)9811: case (char)9824: case (char)9827: case (char)9829: case (char)9830: case (char)9832: case (char)9851: case (char)9855: case (char)9875: case (char)9888: case (char)9889: case (char)9898: case (char)9899: case (char)9917: case (char)9918: case (char)9924: case (char)9925: case (char)9934: case (char)9940: case (char)9962: case (char)9970: case (char)9971: case (char)9973: case (char)9978: case (char)9981: case (char)9986: case (char)9989: case (char)9992: case (char)9993: case (char)9994: case (char)9995: case (char)9996: case (char)9999: case (char)10002: case (char)10004: case (char)10006: case (char)10024: case (char)10035: case (char)10036: case (char)10052: case (char)10055: case (char)10060: case (char)10062: case (char)10067: case (char)10068: case (char)10069: case (char)10071: case (char)10084: case (char)10133: case (char)10134: case (char)10135: case (char)10145: case (char)10160: case (char)10175: case (char)10548: case (char)10549: case (char)11013: case (char)11014: case (char)11015: case (char)11035: case (char)11036: case (char)11088: case (char)11093: case (char)12336: case (char)12349: case (char)12951: case (char)12953: if (can_emoticon) { emojiitem = Emoji.GetEmoji24(letters, i); if (emojiitem != null) { if (emote_count++ < 8) { rtf.Append(Emoticons.GetRTFEmoji(emojiitem.Image, back_color, richtextbox)); i += (emojiitem.Length - 1); break; } else { goto default; } } } goto default; case '(': case ':': case ';': if (can_emoticon) { Emotic em = Emoticons.FindEmoticon(text.ToString().Substring(i).ToUpper()); if (em != null) { if (emote_count++ < 8) { rtf.Append(Emoticons.GetRTFEmoticon(em.Index, back_color, richtextbox)); i += (em.Shortcut.Length - 1); break; } else { goto default; } } em = this.FindNewEmoticon(text.ToString().Substring(i).ToUpper()); if (em != null) { if (emote_count++ < 8) { rtf.Append(Emoticons.GetRTFExEmoticon(em.Index, back_color, richtextbox)); i += (em.Shortcut.Length - 1); break; } else { goto default; } } } goto default; default: rtf.Append("\\u" + ((int)letters[i]) + "?"); break; } } } if (underline) { rtf.Append("\\ul0"); } if (italic) { rtf.Append("\\i0"); } if (bold) { rtf.Append("\\b0"); } rtf.Append("\\highlight0\\cf0"); if (!String.IsNullOrEmpty(name)) { StringBuilder name_builder = new StringBuilder(); if (ff == null) { Color colfromcode = this.GetColorFromCode(GlobalSettings.GetDefaultColorInt(GlobalSettings.DefaultColorType.Name, this.IsBlack)); col_index = this.GetColorIndex(ref cols, colfromcode); if (col_index > -1) { name_builder.Append("\\cf" + (col_index + 1) + " "); } else { cols.Add(this.IsBlack ? Color.Yellow : Color.Black); name_builder.Append("\\cf" + cols.Count + " "); } } else { bg_test = ff.NameColor.ToUpper().Replace("#", String.Empty); if (bg_test == "000000" && this.IsBlack) { bg_test = "#FFFF00"; } else if (bg_test == "FFFFFF" && !this.IsBlack) { bg_test = "#000000"; } else { bg_test = ff.NameColor; } col_index = this.GetColorIndex(ref cols, this.HTMLColorToColor(bg_test)); if (col_index > -1) { name_builder.Append("\\cf" + (col_index + 1) + " "); } else { cols.Add(this.HTMLColorToColor(bg_test)); name_builder.Append("\\cf" + cols.Count + " "); } } col_index = this.GetColorIndex(ref cols, this.IsBlack ? Color.Black : Color.White); if (col_index > -1) { name_builder.Append("\\highlight" + (col_index + 1) + " "); } else { cols.Add(this.IsBlack ? Color.Black : Color.White); name_builder.Append("\\highlight" + cols.Count + " "); } char[] name_chrs = (name + "> ").ToCharArray(); for (int i = 0; i < name_chrs.Length; i++) { name_builder.Append("\\u" + ((int)name_chrs[i]) + "?"); } name_builder.Append("\\highlight0\\cf0"); rtf.Insert(0, name_builder.ToString()); name_builder = null; } if (this.Lines.Length > 0) { rtf.Insert(0, "\\par"); } if (ff == null) { rtf.Insert(0, "\\fs" + (Settings.GetReg <int>("global_font_size", 10) * 2)); } else { int org_size = Settings.GetReg <int>("global_font_size", 10); int difference = (org_size - 10); int user_size = ff.Size + difference; rtf.Insert(0, "\\fs" + (user_size * 2)); } StringBuilder header = new StringBuilder(); header.Append("\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1040{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0"); if (ff == null) { header.Append(Settings.GetReg <String>("global_font", "Tahoma") + ";}}"); } else { header.Append(ff.FontName + ";}}"); } header.Append(this.ColorsToRTFColorTable(cols.ToArray())); this.SelectionLength = 0; this.SelectionStart = this.Text.Length; this.TrimLines(); this.SelectedRtf = "{" + header + rtf + "}"; this.SelectionLength = 0; this.SelectionStart = this.Text.Length; cols.Clear(); cols = null; rtf = null; text = null; while (this.CanUndo) { this.ClearUndo(); } }
public void EmoteText(String name, String text, AresFont font) { this.webControl1.ShowEmoteText(name, text, font); }
internal void PMTextReceived(Room room, User user, String name, String text, AresFont font, PMTextReceivedType type) { this.tabControl1.BeginInvoke((Action)(() => { for (int i = 0; i < this.tabControl1.TabPages.Count; i++) { if (this.tabControl1.TabPages[i] is PMTab) { if (this.tabControl1.TabPages[i].Text == name) { PMTab tab = (PMTab)this.tabControl1.TabPages[i]; if (type == PMTextReceivedType.Announce) { tab.Announce(text); if (text.Contains("voice_clip")) { tab.SetRead(this.Mode == ScreenMode.PM && this.PMName == name); } } else { tab.PM(name, text, font); tab.SetRead(this.Mode == ScreenMode.PM && this.PMName == name); if (!tab.AutoReplySent) { if (Settings.GetReg <bool>("can_pm_reply", true)) { this.SendAutoReply(name, EventArgs.Empty); String[] lines = Settings.GetReg <String>("pm_reply", "Hello +n, please leave a message.").Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); AresFont f = null; if (Settings.MyFont != null) { f = Settings.MyFont.Copy(); } foreach (String str in lines) { String rtext = str.Replace("+n", name); if (!String.IsNullOrEmpty(rtext)) { while (Encoding.UTF8.GetByteCount(rtext) > 200) { rtext = rtext.Substring(0, rtext.Length - 1); } tab.PM(this.MyName, rtext, f); } } } tab.AutoReplySent = true; } } if (!tab.First) { tab.First = true; if (room != null && user != null) { ScriptEvents.OnPmFirstReceived(room, user); } } return; } } } PMTab new_tab = new PMTab(name, this.EndPoint); if (this.IsBlack) { new_tab.SetToBlack(); } new_tab.HashlinkClicked += this.LinkHashlinkClicked; new_tab.EditScribbleClicked += this.DoEditScribbleClicked; new_tab.ImageIndex = 2; this.tabControl1.TabPages.Add(new_tab); if (type == PMTextReceivedType.Announce) { new_tab.Announce(text); } else { new_tab.PM(name, text, font); if (Settings.GetReg <bool>("can_pm_reply", true)) { this.SendAutoReply(name, EventArgs.Empty); String[] lines = Settings.GetReg <String>("pm_reply", "Hello +n, please leave a message.").Split(new String[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); AresFont f = null; if (Settings.MyFont != null) { f = Settings.MyFont.Copy(); } foreach (String str in lines) { String rtext = str.Replace("+n", name); if (!String.IsNullOrEmpty(text)) { while (Encoding.UTF8.GetByteCount(rtext) > 200) { rtext = rtext.Substring(0, rtext.Length - 1); } new_tab.PM(this.MyName, rtext, f); } } } new_tab.AutoReplySent = true; new_tab.First = true; if (room != null && user != null) { ScriptEvents.OnPmFirstReceived(room, user); } } })); }
public void PM(String name, String text, AresFont font) { this.rtf.ShowPMText(name, text, font); }