//Start tests items private void addImages() { string[] imageFilePaths = Directory.GetFiles(WhatsappProperties.Instance.DemoImageFolder, "*.*",SearchOption.AllDirectories); if (imageFilePaths != null && imageFilePaths.Length>0) { for (int i = 0; i < imageFilePaths.Length; i++) { string file = imageFilePaths[i]; if (file.EndsWith(".png") || file.EndsWith(".jpg")) { if (File.Exists(file)) { ImgView imgView = new ImgView("0524376464", "nickName", (ImageSource)new ImageSourceConverter().ConvertFromString(file), "10:10"); this.stackPanel1.Children.Add(imgView); string fullPath = System.IO.Path.GetFullPath(file); Queue.Enqueue(fullPath); } } } } this.stackPanelScroller.ScrollToBottom(); }
public static void buildImgView(ImgView imgView) { imgView.hourField.Foreground = WhatsappProperties.Instance.HourColor; if (WhatsappProperties.Instance.ImageMaxWidth != 0) { double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; double imageMaxWidth = (screenWidth * WhatsappProperties.Instance.ImageMaxWidth) / 100; if (!string.IsNullOrEmpty(WhatsappProperties.Instance.ImageMaxWidthType) && "pix".Equals(WhatsappProperties.Instance.ImageMaxWidthType)) { imageMaxWidth = WhatsappProperties.Instance.ImageMaxWidth; } imgView.imgField.MaxWidth = imageMaxWidth; } else { double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; double imageMaxWidth = ((screenWidth * WhatsappProperties.Instance.MsgSectionWidth) / 100); imageMaxWidth = imageMaxWidth - WhatsappProperties.Instance.PaddingLeft - 20; if (!string.IsNullOrEmpty(WhatsappProperties.Instance.ImageMaxWidthType) && "pix".Equals(WhatsappProperties.Instance.ImageMaxWidthType)) { imageMaxWidth = WhatsappProperties.Instance.MsgSectionWidth; } imgView.imgField.MaxWidth = imageMaxWidth; } imgView.phoneField.FontSize = WhatsappProperties.Instance.PhoneFontSize; imgView.hourField.FontSize = WhatsappProperties.Instance.HouerFontSize; imgView.Margin = new Thickness(WhatsappProperties.Instance.PaddingLeft, WhatsappProperties.Instance.PaddingTop, 0, 0); }
private void addImg(string phoneNumber,string nickName,string imgFileName, string hour) { phoneNumber = Helpers.filterFromNumber(phoneNumber); if (isCanShowMsgMet(phoneNumber, "IMG")) { phoneNumber = Helpers.formatPhoneNumber(phoneNumber); ImgView imgView = null; this.stackPanel1.Dispatcher.BeginInvoke(new Action(() => { imgView = new ImgView(phoneNumber,nickName, (ImageSource)new ImageSourceConverter().ConvertFromString(imgFileName), hour); })); this.stackPanel1.Dispatcher.Invoke((Action)(() => { this.stackPanel1.Children.Add(imgView); })); this.stackPanel1.Dispatcher.Invoke((Action)(() => { this.stackPanelScroller.ScrollToBottom(); })); Queue.Enqueue(Environment.CurrentDirectory + @"\" + imgFileName); } addTextInfoToLog("IMG", imgFileName, phoneNumber, isCanShowMsgMet(phoneNumber, "IMG")); }