public async void OnGridClick(object s, MouseButtonEventArgs e) { FriendSelectControl fsc = (FriendSelectControl)s; if (!isFriendList) { string id = (string)fsc.Grid.Tag; if (!DoesUserExists(id)) { var user = await KakaoRequestClass.GetProfile(id); ProfileData profileData = new ProfileData() { id = id, name = user.profile.display_name }; UserNameWithCloseButton control = new UserNameWithCloseButton(); control.TB_Name.Text = user.profile.display_name; profileData.control = control; control.Margin = new Thickness(0, 0, 5, 0); control.IC_Close.MouseLeftButtonDown += profileData.Remove; withProfiles.Add(profileData); SP_WithFriends.Children.Add(control); SV_WithFriends.ScrollToRightEnd(); } } else { string id = (string)fsc.Grid.Tag; TimeLineWindow tlw = new TimeLineWindow(id); tlw.Show(); tlw.Focus(); } e.Handled = true; }
public static TextBlock GetWithFriendTB(CommentData.PostData data) { TextBlock TB_Closest_With = new TextBlock(); CommentData.ClosestWithTag first = data.closest_with_tags.First(); string headStr; string tailStr = "과 함께"; if (data.closest_with_tags.Count > 1) { headStr = $"{first.display_name}님 외 {(data.closest_with_tags.Count - 1).ToString()}명"; } else { headStr = $"{first.display_name}님"; } Bold boldContent = new Bold(new Run(headStr)); MainWindow.SetClickObject(boldContent); List <string> ids = new List <string>(); foreach (var tag in data.closest_with_tags) { ids.Add(tag.id); } boldContent.PreviewMouseLeftButtonDown += (s, e) => { if (data.closest_with_tags.Count > 1) { UserInfoWindow userInfoWindow = new UserInfoWindow(ids) { Title = "함께하는 친구 목록" }; userInfoWindow.Show(); userInfoWindow.Focus(); } else { TimeLineWindow tlw = new TimeLineWindow(first.id); tlw.Show(); tlw.Focus(); e.Handled = true; } e.Handled = true; }; TB_Closest_With.Inlines.Add(boldContent); TB_Closest_With.Inlines.Add(new Run(tailStr)); return(TB_Closest_With); }
private void AddProfile(List <ProfileData.Profile> profiles) { foreach (var profile in profiles) { FriendSelectControl fsc = new FriendSelectControl(); AssignProfile(fsc, profile); fsc.Grid.MouseLeftButtonDown += (s, e) => { TimeLineWindow tlw = new TimeLineWindow(profile.id); tlw.Show(); tlw.Focus(); e.Handled = true; }; SP_Main.Children.Add(fsc); } }
private void AddUps(List <ShareData.Share> ups) { foreach (var up in ups) { FriendSelectControl fsc = new FriendSelectControl(); AssignProfile(fsc, up.actor, this); fsc.Grid.MouseLeftButtonDown += (s, e) => { TimeLineWindow tlw = new TimeLineWindow(up.actor.id); tlw.Show(); tlw.Focus(); e.Handled = true; }; SP_UP.Children.Add(fsc); } }
public static void SetShareFriendsTB(TextBlock textBlock, List <TimeLineData.TitleDecorator> decorator) { Bold idContent = new Bold(new Run(decorator[0].text)); MainWindow.SetClickObject(idContent); idContent.PreviewMouseLeftButtonDown += (s, e) => { TimeLineWindow tlw = new TimeLineWindow(decorator[0].id); tlw.Show(); tlw.Focus(); e.Handled = true; }; textBlock.Inlines.Add(idContent); textBlock.Inlines.Add(new Run(decorator[1].text)); textBlock.Inlines.Add(new Bold(new Run(decorator[2].text))); textBlock.Inlines.Add(new Run(decorator[3].text)); }
private void AddLikes(List <ShareData.Share> likes) { foreach (var like in likes) { FriendSelectControl fsc = new FriendSelectControl(); fsc.GD_Emotion.Visibility = Visibility.Visible; if (like.emotion.Equals("like")) { fsc.EM_Like.Visibility = Visibility.Visible; } else if (like.emotion.Equals("good")) { fsc.EM_Cool.Visibility = Visibility.Visible; } else if (like.emotion.Equals("pleasure")) { fsc.EM_Pleasure.Visibility = Visibility.Visible; } else if (like.emotion.Equals("sad")) { fsc.EM_Sad.Visibility = Visibility.Visible; } else if (like.emotion.Equals("cheerup")) { fsc.EM_Cheer.Visibility = Visibility.Visible; } AssignProfile(fsc, like.actor, this, like.id); MainWindow.SetClickObject(fsc.Grid); fsc.Grid.MouseLeftButtonDown += (s, e) => { TimeLineWindow tlw = new TimeLineWindow(like.actor.id); tlw.Show(); tlw.Focus(); e.Handled = true; }; SP_Emotions.Children.Add(fsc); } }
public static void RefreshContent(List <QuoteData> content_decorators, string content, TextBlock TB_Content) { TB_Content.Tag = new object[] { content_decorators, content }; TB_Content.Inlines.Clear(); if (content.Length == 0) { TB_Content.Visibility = Visibility.Collapsed; } else { TB_Content.Visibility = Visibility.Visible; } foreach (var decorator in content_decorators) { if (decorator.type.Equals("profile")) { Bold content2 = new Bold(new Run(decorator.text)); MainWindow.SetClickObject(content2); content2.MouseLeftButtonDown += (s, e) => { TimeLineWindow tlw = new TimeLineWindow(decorator.id); tlw.Show(); tlw.Focus(); e.Handled = true; }; TB_Content.Inlines.Add(content2); } else if (decorator.type.Equals("text") || decorator.type.Equals("emoticon")) { string text = decorator.text.Replace("\r\n", "\n"); text = decorator.text.Replace("\\n", "\n"); if (text.Contains("http://") || text.Contains("https://")) { int count = 0; string[] splitted = SplitWithDelimiters(text, new List <string> { "http://", "https://" }); string lastDelimiter = null; foreach (string splittedText in splitted) { count++; if (splittedText.Equals("https://") || splittedText.Equals("http://")) { lastDelimiter = splittedText; } else if (lastDelimiter != null && splittedText.Length > 0) { int endPos = splittedText.IndexOf(" "); if (endPos < 0) { endPos = splittedText.IndexOf("\n"); } else if (splittedText.IndexOf("\n") > 0 && splittedText.IndexOf("\n") < endPos) { endPos = splittedText.IndexOf("\n"); } if (endPos < 0) { endPos = splittedText.Length - 1; if (count == splitted.Length) { endPos++; } } string uriText = lastDelimiter + splittedText.Substring(0, endPos); lastDelimiter = null; var uriSpan = new Bold(new Underline(new Run(uriText))) { Foreground = Brushes.Blue }; MainWindow.SetClickObject(uriSpan); uriSpan.PreviewMouseLeftButtonDown += (s, e) => { e.Handled = true; System.Diagnostics.Process.Start(uriText); }; TB_Content.Inlines.Add(uriSpan); TB_Content.Inlines.Add(new Run(splittedText.Substring(endPos))); } else { TB_Content.Inlines.Add(new Run(splittedText)); } } } else { TB_Content.Inlines.Add(new Run(text)); } } else if (decorator.type.Equals("hashtag")) { TB_Content.Inlines.Add(new Bold(new Run(decorator.text.Replace("\\n", "\n")))); } } }