예제 #1
0
        private async void BT_TimeLine_Click(object sender, RoutedEventArgs e)
        {
            if (IsLoggedIn && !IsOffline)
            {
                if (TimeLineWindow == null)
                {
                    TimeLineWindow = new TimeLineWindow
                    {
                        fromMainMenu = true
                    };
                    TimeLineWindow.Show();
                    //timeLineWindow.Activate();
                }
                else
                {
                    await TimeLineWindow.RefreshTimeline(null, true);

                    TimeLineWindow.Show();
                    TimeLineWindow.Activate();
                }
            }
            else
            {
                GlobalHelper.ShowOfflineMessage();
            }
        }
예제 #2
0
        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;
        }
예제 #3
0
        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);
        }
예제 #4
0
 private void BT_Favorite_Click(object sender, RoutedEventArgs e)
 {
     if (!IsLoggedIn && !IsOffline)
     {
         GlobalHelper.ShowOfflineMessage();
     }
     else
     {
         TimeLineWindow.showBookmarkedGlobal = true;
         TimeLineWindow timeLineWindow = new TimeLineWindow(UserProfile.id);
         timeLineWindow.Show();
         timeLineWindow.Activate();
     }
 }
예제 #5
0
        public static void SubContentMouseEvent(object s, MouseButtonEventArgs e)
        {
            string id = (string)((FrameworkElement)s).Tag;

            try
            {
                TimeLineWindow tlw = new TimeLineWindow(id);
                tlw.Show();
                tlw.Activate();
            }
            catch (Exception)
            {
                MessageBox.Show("접근이 불가능한 스토리입니다.");
            }
            e.Handled = true;
        }
 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 MailReadWindow(string id)
        {
            InitializeComponent();
            this.id = id;

            RA_Loading.Visibility = Visibility.Visible;
            PR_Loading.Visibility = Visibility.Visible;

            Dispatcher.InvokeAsync(async() =>
            {
                var mail = await KakaoRequestClass.GetMailDetail(id);

                string imgUri = mail.sender.profile_thumbnail_url;
                if (Properties.Settings.Default.GIFProfile && mail.sender.profile_video_url_square_small != null)
                {
                    imgUri = mail.sender.profile_video_url_square_small;
                }
                GlobalHelper.AssignImage(IMG_Profile, imgUri);
                MainWindow.SetClickObject(IMG_Profile);
                IMG_Profile.PreviewMouseLeftButtonDown += (s, e) =>
                {
                    e.Handled = true;
                    try
                    {
                        TimeLineWindow tlw = new TimeLineWindow(mail.sender.id);
                        tlw.Show();
                        tlw.Activate();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("접근이 불가능한 스토리입니다.");
                    }
                };

                if (mail.@object?.background != null && [email protected]("image"))
                {
                    GlobalHelper.AssignImage(IMG_Main, [email protected]);
                }

                TB_Main.Text = mail.content;
                TB_Name.Text = mail.sender.display_name + "님으로부터";

                RA_Loading.Visibility = Visibility.Collapsed;
                PR_Loading.IsActive   = false;
            });
        }
예제 #9
0
        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));
        }
예제 #10
0
        private async void BT_MyProfile_Click(object sender, RoutedEventArgs e)
        {
            if (IsLoggedIn && !IsOffline)
            {
                if (ProfileTimeLineWindow == null)
                {
                    var window = new TimeLineWindow(UserProfile.id);
                    window.Show();
                }
                else
                {
                    await ProfileTimeLineWindow.RefreshTimeline(null, true);

                    ProfileTimeLineWindow.Show();
                    ProfileTimeLineWindow.Activate();
                }
            }
            else
            {
                GlobalHelper.ShowOfflineMessage();
            }
        }
 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);
     }
 }
예제 #12
0
        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"))));
                }
            }
        }
        public async Task Refresh()
        {
            PR_Loading.IsActive  = true;
            BT_Refresh.IsEnabled = false;
            TB_RefreshBT.Text    = "갱신중..";
            IC_Refresh.Kind      = MaterialDesignThemes.Wpf.PackIconKind.ProgressClock;
            List <CSNotification> notifications = await KakaoRequestClass.RequestNotification(true);

            SP_Content.Children.Clear();
            foreach (var notification in notifications)
            {
                string thumbnailURL = notification.actor?.profile_thumbnail_url ?? "";
                if (Properties.Settings.Default.GIFProfile && notification.actor?.profile_video_url_square_small != null)
                {
                    thumbnailURL = notification.actor?.profile_video_url_square_small;
                }
                string message              = notification.message;
                string timestamp            = PostWindow.GetTimeString(notification.created_at);
                NotificationControl content = new NotificationControl();
                MainWindow.SetClickObject(content);
                content.TB_Content.Text    = message;
                content.TB_Content.ToolTip = content.TB_Content.Text;
                string contentMessage = notification.content ?? "내용 없음";
                if (contentMessage.Contains("\n"))
                {
                    contentMessage = contentMessage.Split(new string[] { "\n" }, StringSplitOptions.None)[0];
                }

                content.TB_Message.Text    = contentMessage;
                content.TB_Message.ToolTip = content.TB_Message.Text;
                if (!notification.is_new)
                {
                    content.RA_Notify.Fill = Brushes.Transparent;
                }
                if (content.TB_Message.Text.Trim().Length == 0)
                {
                    content.TB_Message.Text = "내용 없음";
                }
                content.TB_Date.Text = timestamp;
                string uri = "https://story.kakao.com/";
                GlobalHelper.AssignImage(content.IMG_Thumbnail, thumbnailURL);
                MainWindow.SetClickObject(content.IMG_Thumbnail);
                content.IMG_Thumbnail.MouseLeftButtonDown += (s, e) =>
                {
                    try
                    {
                        TimeLineWindow tlw = new TimeLineWindow(notification.actor.id);
                        tlw.Show();
                        tlw.Activate();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("접근이 불가능한 스토리입니다.");
                    }
                    e.Handled = true;
                };
                if (notification.scheme.Contains("?profile_id="))
                {
                    var ObjStr   = notification.scheme.Split(new string[] { "?profile_id=" }, StringSplitOptions.None);
                    var Profile  = ObjStr[1];
                    var Identity = ObjStr[0].Split('.')[1];
                    uri += Profile + "/" + Identity + "!" + ObjStr[0];
                    var feedID = ObjStr[0].Split(new string[] { "activities/" }, StringSplitOptions.None)[1];
                    content.MouseLeftButtonDown += async(s, e) =>
                    {
                        string target = uri.Split(new string[] { "!" }, StringSplitOptions.None)[0];
                        try
                        {
                            var post = await KakaoRequestClass.GetPost(feedID);

                            PostWindow.ShowPostWindow(post, feedID);
                        }
                        catch (Exception) { }
                        content.RA_Notify.Fill = Brushes.Transparent;
                        e.Handled = true;
                    };
                }
                else if (notification.scheme.Contains("kakaostory://profiles/"))
                {
                    content.MouseLeftButtonDown += (s, e) =>
                    {
                        try
                        {
                            string         id  = notification.scheme.Replace("kakaostory://profiles/", "");
                            TimeLineWindow tlw = new TimeLineWindow(id);
                            tlw.Show();
                            tlw.Activate();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("접근할 수 없는 스토리입니다.");
                        }
                        e.Handled = true;
                    };
                }
                SP_Content.Children.Add(content);
            }
            BT_Refresh.IsEnabled = true;
            TB_RefreshBT.Text    = "새로고침";
            IC_Refresh.Kind      = MaterialDesignThemes.Wpf.PackIconKind.Refresh;

            SV_Content.ScrollToTop();
            RA_Loading.Visibility = Visibility.Collapsed;
            PR_Loading.IsActive   = false;
        }
예제 #14
0
        public async Task Refresh()
        {
            BT_Refresh.IsEnabled = false;
            PR_Loading.IsActive  = true;
            TB_RefreshBT.Text    = "갱신중..";
            IC_Refresh.Kind      = MaterialDesignThemes.Wpf.PackIconKind.ProgressClock;
            var mails = await KakaoRequestClass.GetMails();

            SP_Main.Children.Clear();
            foreach (var mail in mails)
            {
                var mc = new MailControl();
                mc.TB_Name.Text    = mail.sender.display_name;
                mc.TB_Content.Text = mail.summary;
                mc.TB_Date.Text    = PostWindow.GetTimeString(mail.created_at);

                string imgUri = mail.sender.profile_thumbnail_url;
                if (Properties.Settings.Default.GIFProfile && mail.sender.profile_video_url_square_small != null)
                {
                    imgUri = mail.sender.profile_video_url_square_small;
                }
                GlobalHelper.AssignImage(mc.IMG_Profile, imgUri);
                MainWindow.SetClickObject(mc.IMG_Profile);
                mc.IMG_Profile.PreviewMouseLeftButtonDown += (s, e) =>
                {
                    e.Handled = true;
                    try
                    {
                        TimeLineWindow tlw = new TimeLineWindow(mail.sender.id);
                        tlw.Show();
                        tlw.Activate();
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("접근이 불가능한 스토리입니다.");
                    }
                };

                if (mail.read_at == null || mail.read_at.Value.Year < 1)
                {
                    mc.RA_BG.Fill = Brushes.Teal;
                }

                mc.Grid.MouseLeftButtonDown += (s, e) =>
                {
                    e.Handled     = true;
                    mc.RA_BG.Fill = Brushes.Transparent;
                    var window = new MailReadWindow(mail.id);
                    window.Show();
                };

                mc.IC_Reply.PreviewMouseLeftButtonDown += (s, e) =>
                {
                    e.Handled     = true;
                    mc.RA_BG.Fill = Brushes.Transparent;
                    var window = new MailWriteWindow(mail.sender.id, mail.sender.display_name);
                    window.Show();
                };

                MainWindow.SetClickObject(mc.Grid);

                SP_Main.Children.Add(mc);
                var sep = new Separator
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(221, 221, 221))
                };
                SP_Main.Children.Add(sep);
            }
            PR_Loading.IsActive  = false;
            BT_Refresh.IsEnabled = true;
            TB_RefreshBT.Text    = "새로고침";
            IC_Refresh.Kind      = MaterialDesignThemes.Wpf.PackIconKind.Refresh;
        }
 public static void ActivateHandler(string invokedArgs, NotificationUserInput userInput)
 {
     Application.Current.Dispatcher.Invoke(async delegate
     {
         if (!invokedArgs.Contains("default null string"))
         {
             try
             {
                 if (invokedArgs.Contains("LIKE!@#$%"))
                 {
                     string text       = invokedArgs.Substring(0, invokedArgs.IndexOf("LIKE!@#$%"));
                     string activityID = text.Split(new string[] { "activities/" }, StringSplitOptions.None)[1];
                     string commentID  = invokedArgs.Split(new string[] { "LIKE!@#$%" }, StringSplitOptions.None)[1];
                     await KakaoRequestClass.LikeComment(activityID, commentID, false);
                 }
                 else if (invokedArgs.Contains("REPLY!@#$%"))
                 {
                     string text       = invokedArgs.Substring(0, invokedArgs.IndexOf("REPLY!@#$%"));
                     string[] datas    = invokedArgs.Split(new string[] { "R!@=!!" }, StringSplitOptions.None);
                     string id         = datas[1];
                     string name       = datas[2];
                     string writer     = datas[3];
                     string identity   = datas[4];
                     string msg        = userInput["tbReply"];
                     string activityID = text.Split(new string[] { "activities/" }, StringSplitOptions.None)[1];
                     await KakaoRequestClass.ReplyToFeed(activityID, msg, id, name);
                 }
                 else
                 {
                     //MessageBox.Show(invokedArgs);
                     string text       = invokedArgs.Split(new string[] { "!" }, StringSplitOptions.None)[1];
                     string activityID = text.Split(new string[] { "activities/" }, StringSplitOptions.None)[1];
                     string url        = invokedArgs.Split(new string[] { "!" }, StringSplitOptions.None)[0];
                     try
                     {
                         PostData data = await KakaoRequestClass.GetPost(activityID);
                         if (data != null && activityID != null)
                         {
                             PostWindow.ShowPostWindow(data, activityID);
                         }
                     }
                     catch (Exception) { }
                 }
             }
             catch (Exception)
             {
                 try
                 {
                     string id = invokedArgs.Replace("https://story.kakao.com/", "");
                     if (id.Length > 0)
                     {
                         TimeLineWindow tlw = new TimeLineWindow(id);
                         tlw.Show();
                         tlw.Activate();
                     }
                     else
                     {
                         throw new InvalidDataException();
                     }
                 }
                 catch (Exception)
                 {
                     System.Diagnostics.Process.Start(invokedArgs.Split(new string[] { "!" }, StringSplitOptions.None)[0]);
                 }
             }
         }
     });
 }