private void OnImageHyperLinkAdd(IMMessage imMessage, ImageHyperlink hyperlink) { Guid guid = hyperlink.Guid; if (guid.Equals(MessageElementTags.GuidLinkSafePage) || guid.Equals(MessageElementTags.GuidLinkHttp)) { TXGrayURLMgr grayURLMgr = ComponentManager.GetGrayURLMgr(); ITXDataRead txData = grayURLMgr.QueryURLInfo(hyperlink.SoureUrl); if (txData != null) { this.SetURLInfo(hyperlink, txData); } else { GrayURL.QueryType eQueryType = GrayURL.QueryType.QueryType_Unknown; uint uin = 0; if (imMessage.Sender != null) { uin = imMessage.Sender.Uin; } if (uin == 0) { eQueryType = GrayURL.QueryType.QueryType_Unknown; } else if (Util_Buddy.GetCurrentBuddy().Uin == uin) { eQueryType = GrayURL.QueryType.QueryType_Sender; } else { eQueryType = GrayURL.QueryType.QueryType_Reciver; } GrayURL.MSGType msgType = this.IsCommunity ? GrayURL.MSGType.MSGType_Group : GrayURL.MSGType.MSGType_Buddy; grayURLMgr.UpdateURLInfoEx(msgType, hyperlink.SoureUrl, eQueryType); this.AddToUrlInfoDownloadingList(hyperlink.SoureUrl, hyperlink); } } }
public void AddMsgToOutputBox(IMMessage imMessage, string senderName, AddMsgToOutputBoxCallBackHandler callBack) { this.CheckMsgPiece(); InputBox box = this; MessagePack messagePack = imMessage.MessagePack; if (messagePack != null) { if (messagePack.NeedShowHeader && (imMessage.Sender == null)) { messagePack.NeedShowHeader = false; } if (messagePack.NeedShowHeader && string.IsNullOrEmpty(senderName)) { senderName = imMessage.SenderName; if (string.IsNullOrEmpty(senderName)) { senderName = imMessage.Sender.NickName; } } uint elemCount = messagePack.GetElemCount(); Section newItem = new Section(); Block lastBlock = box.Document.Blocks.LastBlock; if ((lastBlock != null) && (string.Compare(lastBlock.Tag as string, "LastTag") != 0)) { lastBlock = null; } if (lastBlock == null) { Paragraph paragraph = new Paragraph { Tag = "LastTag", Margin = new Thickness(0.0) }; lastBlock = paragraph; box.Document.Blocks.Add(lastBlock); } if (messagePack.NeedShowHeader) { if ((imMessage.Sender != null) && (imMessage.Sender.Uin == Util_Buddy.GetCurrentBuddy().Uin)) { newItem.Tag = "me"; } else { newItem.Tag = "other"; } } else { newItem.Tag = "info"; } box.Document.Blocks.InsertBefore(lastBlock, newItem); Paragraph item = new Paragraph(); if (messagePack.NeedShowHeader) { string str; Paragraph paragraph3 = new Paragraph { Foreground = new SolidColorBrush((imMessage.Sender.Uin == Util_Buddy.GetCurrentBuddy().Uin) ? this._selfColor : this._oppColor) }; if (this.IsMsgRecord) { str = senderName + " " + imMessage.DateTime.ToLocalTime().ToString(); } else { str = senderName + " " + imMessage.DateTime.ToLocalTime().ToLongTimeString(); item.Margin = new Thickness(13.0, 0.0, 0.0, 0.0); } paragraph3.Inlines.Add(str); newItem.Blocks.Add(paragraph3); } SetDateTime(newItem, imMessage.DateTime); Paragraph paragraph4 = new Paragraph { Margin = new Thickness(13.0, 0.0, 0.0, 0.0) }; string fontName = messagePack.Header.FontName; if ((string.IsNullOrEmpty(fontName) || (fontName == "宋体")) || (((fontName == "新宋体") || (fontName == "仿宋")) || (fontName == "黑体"))) { fontName = "Microsoft YaHei"; } if (messagePack.Header.FontSize == 0) { messagePack.Header.FontSize = 9; } item.FontFamily = new FontFamily(fontName); item.FontSize = messagePack.Header.FontSize + 3; item.Foreground = new SolidColorBrush(messagePack.Header.FontColor); paragraph4.FontFamily = new FontFamily(messagePack.Header.FontName); paragraph4.FontSize = messagePack.Header.FontSize + 3; paragraph4.Foreground = new SolidColorBrush(messagePack.Header.FontColor); Dictionary<string, bool> imagelist = new Dictionary<string, bool>(); Paragraph paragraph5 = item; bool flag = false; for (uint i = 0; i < elemCount; i++) { ImageElement element4; string path; ImageEx ex2; MessageElement elem = messagePack.GetElem(i); switch (elem.Category) { case MsgPackCat.ELEMTYPE_TEXT: { Guid guid; Guid guid2; TextElement element2 = (TextElement)elem; string text = element2.GetText(); if (!flag && element2.NeedIndent) { Span lastInline = item.Inlines.LastInline as Span; if (lastInline != null) { Run run = lastInline.Inlines.LastInline as Run; if (run != null) { run.Text = run.Text.Replace("\r", "").Replace("\n", ""); } } paragraph5 = paragraph4; } string url = element2.GetUrl(out guid, out guid2); Span span2 = new Span(); Span span3 = span2; paragraph5.Inlines.Add(span3); if ((messagePack.Header.FontEffect & 2) != 0) { span2.FontStyle = FontStyles.Italic; } if ((messagePack.Header.FontEffect & 1) != 0) { span2.FontWeight = FontWeights.Bold; } if (string.IsNullOrEmpty(url)) { if ((messagePack.Header.FontEffect & 4) != 0) { Underline underline = new Underline(); span2.Inlines.Add(underline); span2 = underline; } span2.Inlines.Add(text); } else { ImageHyperlink hyperlink = new ImageHyperlink { Guid = guid, SoureUrl = url }; span2.Inlines.Add(hyperlink); span2 = hyperlink; hyperlink.AddText(text); this.OnImageHyperLinkAdd(imMessage, hyperlink); } continue; } case MsgPackCat.ELEMTYPE_SYSFACE: { SysFaceElement element = (SysFaceElement)elem; ImageEx uiElement = ReplaceControls.CreateImageExWithId(element.FileName, element.Index.ToString()); uiElement.Width = element.FaceWidth; uiElement.Height = element.FaceHeight; paragraph5.Inlines.Add(uiElement); if (callBack != null) { callBack(imMessage, element); } continue; } case MsgPackCat.ELEMTYPE_IMAGE: case MsgPackCat.ELEMTYPE_OFFLINEPIC: element4 = (ImageElement)elem; path = element4.Path; if (string.IsNullOrEmpty(path)) { continue; } ex2 = new ImageEx { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Stretch = Stretch.None, SnapsToDevicePixels = true, Tag = element4 }; path = path.ToLower(); if (!CheckFileExists(imagelist, path)) { break; } ex2.Source = path; goto Label_0710; case MsgPackCat.ELEMTYPE_FILE: { FileElement element5 = (FileElement)elem; string str7 = Helper_Icon.MakeSysIconFileByFileName(element5.Path); string fileSize = element5.GetFileSize(); string fileName = element5.GetFileName(); if (!string.IsNullOrEmpty(str7)) { ImageEx ex3 = new ImageEx { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top, Stretch = Stretch.Uniform, SnapsToDevicePixels = true, Width = 32.0, Height = 32.0 }; if (!string.IsNullOrEmpty(element5.Tip)) { ex3.ToolTip = element5.Tip; } ex3.Source = str7; StackPanel panel = new StackPanel { Margin = new Thickness(0.0, 2.0, 0.0, 2.0), Orientation = Orientation.Horizontal }; panel.Children.Add(ex3); TextBlock block2 = new TextBlock(new Run(fileName + "\n" + fileSize)) { Margin = new Thickness(0.0, 4.0, 0.0, 0.0) }; panel.Children.Add(block2); paragraph5.Inlines.Add(panel); } continue; } default: goto Label_087B; } if (this.IsMsgRecord) { ex2.Source = CoreMessenger.Instance.GetAppPath(KernelWrapper.APP_PATH_TYPE.APP_PATH_DATA) + "errorBmp.gif"; } else if (MsgPackCat.ELEMTYPE_IMAGE == elem.Category) { TXLog.TXLogImage(string.Concat(new object[] { "收到图片文件需要下载:", element4.Id, " ", path })); ex2.Source = CoreMessenger.Instance.GetAppPath(KernelWrapper.APP_PATH_TYPE.APP_PATH_DATA) + "sendingBmp.gif"; this.AddToImagesDownloadingList(element4.Id, ex2); } else if (MsgPackCat.ELEMTYPE_OFFLINEPIC == elem.Category) { TXLog.TXLogImage(string.Concat(new object[] { "收到离线图片文件需要下载:", element4.Id, " ", path })); ex2.IsEnabledClick = true; ex2.Source = CoreMessenger.Instance.GetAppPath(KernelWrapper.APP_PATH_TYPE.APP_PATH_DATA) + "OfflinepicManualGet.png"; ex2.ToolTip = "点击获取图片"; ex2.Cursor = Cursors.Hand; } Label_0710: paragraph5.Inlines.Add(ex2); continue; Label_087B: TXLog.TXLog3("Msg", "AIO 未处理的消息类型, "); } if (item.Inlines.Count > 0) { newItem.Blocks.Add(item); } if (paragraph4.Inlines.Count > 0) { newItem.Blocks.Add(paragraph4); } box.ScrollToEnd(); } }
private void SetURLInfo(ImageHyperlink hyperlink, KernelWrapper.ITXDataRead txData) { GrayURL.URLType dWord = (GrayURL.URLType)TXDataHelper.GetDWord(txData, "eURLType"); bool @bool = TXDataHelper.GetBool(txData, "bShowURLReportNum"); string appPath = CoreMessenger.Instance.GetAppPath(KernelWrapper.APP_PATH_TYPE.GlobalSys_Path_Misc); string path = null; bool flag2 = false; switch (dWord) { case GrayURL.URLType.URLType_Gray: if (!@bool) { path = appPath + @"Safe\main_QQdoctortip14_help.png"; flag2 = true; } else { path = appPath + @"Safe\main_QQdoctortip14_attention.png"; } break; case GrayURL.URLType.URLType_Black: path = appPath + @"Safe\main_QQdoctortip14_alert.png"; break; case GrayURL.URLType.URLType_TencentWhite: path = appPath + @"Safe\main_tencent14_normal.png"; flag2 = true; break; case GrayURL.URLType.URLType_NonTencentWhite: path = appPath + @"Safe\main_QQdoctortip14_good.png"; flag2 = true; break; default: path = appPath + @"Safe\main_QQdoctortip14_help.png"; break; } if (!flag2) { hyperlink.DisabledHyperLink(); } ushort word = TXDataHelper.GetWord(txData, "wURLTipsID"); string tips = ComponentManager.GetGrayURLMgr().QueryURLTips(word); hyperlink.InsertImage(path); hyperlink.SetToolTip(tips); }
private void AddToUrlInfoDownloadingList(string url, ImageHyperlink imageHyperlink) { if (this.urlInfoDownloading.ContainsKey(url)) { this.urlInfoDownloading[url].Add(imageHyperlink); } else { List<ImageHyperlink> list2 = new List<ImageHyperlink> { imageHyperlink }; this.urlInfoDownloading.Add(url, list2); } }
public static string ReplaceGUIWithClipboardControl(string xaml, TextPointer start, TextPointer end) { List <DependencyObject> userControls = GetUserControls(start, end); if (userControls.Count == 0) { return(xaml); } string input = xaml; foreach (DependencyObject obj2 in userControls) { string str2 = null; UIElement child = null; if (obj2 is BlockUIContainer) { str2 = "BlockUIContainer"; child = (obj2 as BlockUIContainer).Child; } else if (obj2 is InlineUIContainer) { str2 = "InlineUIContainer"; child = (obj2 as InlineUIContainer).Child; } string replacement = null; if (child is ImageEx) { ImageEx ex = child as ImageEx; EmoticonItem tag = ex.Tag as EmoticonItem; string id = ""; if ((tag != null) && tag.IsSysEmoticon) { id = tag.Id; } if (ImageHyperlink.GetEnableCopy(ex)) { ex.Source.Replace("$", "$$"); string str5 = string.Format("<wpfgui:ClipboardControl ControlType=\"{0}\" ImagePath=\"{1}\" SysId=\"{2}\"/>", typeof(ImageEx).FullName, ex.Source, id); string str6 = "Bama.Controls"; string str7 = "Bama.Controls"; string str8 = string.Format("xmlns:wpfgui=\"clr-namespace:{0};assembly={1}\"", str6, str7); replacement = string.Format("<{0} {1}>{2}</{0}>", str2, str8, str5); } else { replacement = ""; } } if (replacement != null) { if (obj2 is BlockUIContainer) { input = blockEmptyUIContainerRegex.Replace(input, replacement, 1); } else { input = inlineEmptyUIContainerRegex.Replace(input, replacement, 1); } } } return(input); }