private void addTexts() { TextView textView2 = new TextView("0524376464", "", "", "10:10"); this.stackPanel1.Children.Add(textView2); for (int i = 0; i < 5; i++) { TextView textView = new TextView("0524376464" + i, "","מזל טוב ומבורך וובדיקה לטקסט ארוך מאוד מאוד מאוד לבדיקה שהוא טקסט ארוך מאוד מאוד מאוד מאוד נראה איך הוא יהיה", "10:10"); this.stackPanel1.Children.Add(textView); } this.stackPanelScroller.ScrollToBottom(); }
public static void buildTextView(TextView textView) { string text = new TextRange(textView.fromField.Document.ContentStart, textView.fromField.Document.ContentEnd).Text; textView.fromField.Width = Helpers.MeasureString(text, textView.textMsgField.FontFamily, textView.textMsgField.FontStyle, textView.textMsgField.FontWeight, textView.textMsgField.FontStretch, textView.textMsgField.FontSize).Width; textView.textBorder.Background = WhatsappProperties.Instance.TextBackgroundColor; textView.Margin = new Thickness(WhatsappProperties.Instance.PaddingLeft, WhatsappProperties.Instance.PaddingTop, 0, 0); textView.textMsgField.FontSize = WhatsappProperties.Instance.TextFontSize; textView.fromField.FontSize = WhatsappProperties.Instance.PhoneFontSize; textView.hourField.FontSize = WhatsappProperties.Instance.HouerFontSize; textView.textMsgField.Foreground = WhatsappProperties.Instance.TextColor; textView.hourField.Foreground = WhatsappProperties.Instance.HourColor; if (WhatsappProperties.Instance.MaxTextWidth != 0) { double screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth; double textMaxWidth = (screenWidth * WhatsappProperties.Instance.MaxTextWidth) / 100; if (!string.IsNullOrEmpty(WhatsappProperties.Instance.TextMaxWidthType) && "pix".Equals(WhatsappProperties.Instance.TextMaxWidthType)) { textMaxWidth = WhatsappProperties.Instance.MaxTextWidth; } textView.textMsgField.MaxWidth = textMaxWidth; } 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; } textView.textMsgField.MaxWidth = imageMaxWidth; } }
private void addText(string phoneNumber,string nikeName ,string msgText, string hour) { bool isCanShowMsg = isCanShowMsgMet(phoneNumber, "TEXT"); phoneNumber = Helpers.filterFromNumber(phoneNumber); if (isCanShowMsg) { TextView textView2 = null; phoneNumber = Helpers.formatPhoneNumber(phoneNumber); this.stackPanel1.Dispatcher.BeginInvoke(new Action(() => { if (string.IsNullOrEmpty(nikeName)) { textView2 = new TextView(phoneNumber,"",msgText, hour); } else { textView2 = new TextView(phoneNumber,nikeName, msgText, hour); } this.stackPanel1.Children.Add(textView2); this.stackPanelScroller.ScrollToBottom(); })); } addTextInfoToLog("Text", msgText, phoneNumber, isCanShowMsgMet(phoneNumber, "TEXT")); }