Example #1
0
        public ProgressWindow(List <FriendData.Profile> blinded)
        {
            InitializeComponent();
            cts = new CancellationTokenSource();
            CancellationToken token = cts.Token;

            deleteTask = Task.Factory.StartNew(async() =>
            {
                try
                {
                    int count = 0;
                    foreach (var blindedFriend in blinded)
                    {
                        await Task.Delay(1000);
                        await KakaoRequestClass.DeleteFriend(blindedFriend.id);
                        TB_Content.Dispatcher.Invoke(() =>
                        {
                            count++;
                            TB_Content.Text = $"삭제중... {count.ToString()}/{blinded.Count}";
                            PB_Main.Value   = (double)count / blinded.Count * 100.0;
                        });
                    }
                    await Dispatcher.Invoke(async() =>
                    {
                        await MainWindow.UpdateProfile();
                        Close();
                        MessageBox.Show("제한된 사용자의 삭제가 완료됐습니다.");
                    });
                }
                catch (OperationCanceledException)
                {
                    MessageBox.Show("삭제 작업이 취소됐습니다.");
                }
            }, token);
        }
Example #2
0
        private async void BT_Link_Click(object sender, RoutedEventArgs e)
        {
            if (linkData == null)
            {
                string url = TB_Link.Text;
                BT_Link.Kind      = MaterialDesignThemes.Wpf.PackIconKind.ProgressUpload;
                BT_Link.IsEnabled = false;
                linkData          = await KakaoRequestClass.GetScrapData(url);

                if (linkData != null)
                {
                    BT_Link.Kind      = MaterialDesignThemes.Wpf.PackIconKind.Delete;
                    BT_Pic.IsEnabled  = false;
                    BT_Pic.Foreground = Brushes.LightGray;
                }
                else
                {
                    MessageBox.Show("오류가 발생했습니다.\n다시 시도해보세요.");
                    BT_Link.Kind = MaterialDesignThemes.Wpf.PackIconKind.Add;
                }
                BT_Link.IsEnabled = true;
            }
            else
            {
                linkData          = null;
                BT_Link.Kind      = MaterialDesignThemes.Wpf.PackIconKind.Add;
                BT_Pic.IsEnabled  = true;
                BT_Pic.Foreground = Brushes.Gray;
            }
        }
Example #3
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;
        }
Example #4
0
        public static async Task <bool> UpdateProfile()
        {
            string friendRawData = await KakaoRequestClass.GetFriendData();

            string profileRawData = await KakaoRequestClass.GetProfileData();

            UserFriends = JsonConvert.DeserializeObject <FriendData.Friends>(friendRawData);
            UserProfile = JsonConvert.DeserializeObject <UserProfile.ProfileData>(profileRawData);
            return(true);
        }
        private async void BT_CompareFriends_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new System.Windows.Forms.OpenFileDialog()
            {
                Filter = "Kakao Friend Data V2|*.kfd2",
                Title  = "친구 목록 불러오기"
            };

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var    reader = new System.IO.StreamReader(ofd.FileName);
                string str    = reader.ReadToEnd();
                reader.Close();
                var                loadedFriends      = JsonConvert.DeserializeObject <List <string[]> >(str);
                StringBuilder      builder            = new StringBuilder("삭제된 친구 목록 : \n");
                int                count              = 0;
                int                countExpire        = 0;
                ProgressShowWindow progressShowWindow = new ProgressShowWindow();
                progressShowWindow.Show();
                progressShowWindow.Topmost = true;
                progressShowWindow.Title   = "삭제된 친구 조회";
                int progressCount = 0;
                foreach (string[] friendData in loadedFriends)
                {
                    try
                    {
                        KakaoRequestClass.notShowError = true;
                        var relationship = await KakaoRequestClass.GetProfileRelationship(friendData[1]);

                        KakaoRequestClass.notShowError = false;
                        if (!(relationship.relationship.Equals("F") || relationship.relationship.Equals("FE")))
                        {
                            KakaoRequestClass.notShowError = true;
                            var profile = await KakaoRequestClass.GetProfileFeed(friendData[1], null, true);

                            KakaoRequestClass.notShowError = false;
                            builder.Append(profile.profile.display_name);
                            builder.Append("(저장 당시 닉네임 : ");
                            builder.Append(friendData[2]);
                            builder.Append(") : ");
                            builder.Append(profile.profile.permalink);
                            builder.Append("\n");
                            count++;
                        }
                    }
                    catch (Exception) { countExpire++; }
                    progressCount++;
                    progressShowWindow.PB_Main.Value = ((double)progressCount / loadedFriends.Count) * 100.0;
                }
                Clipboard.SetDataObject(builder.ToString());
                progressShowWindow.isFinish = true;
                progressShowWindow.Close();
                MessageBox.Show($"삭제된 친구 목록이 클립보드에 복사되었습니다.\n삭제된 친구 수 : {count.ToString()}\n탈퇴한 친구 수 : {countExpire.ToString()}", "안내");
            }
        }
        public static void AssignProfile(FriendSelectControl fsc, ShareData.Actor actor, PostInfoWindow instance, string likeID = null)
        {
            fsc.MouseEnter += (s, e) =>
            {
                fsc.Background = Brushes.LightGray;
            };
            fsc.MouseLeave += (s, e) =>
            {
                fsc.Background = Brushes.Transparent;
            };
            fsc.TB_Name.Text = actor.display_name;
            string imgUri = actor.profile_thumbnail_url;

            if (Properties.Settings.Default.GIFProfile && actor.profile_video_url_square_small != null)
            {
                imgUri = actor.profile_video_url_square_small;
            }
            GlobalHelper.AssignImage(fsc.IMG_Profile, imgUri);
            fsc.IMG_Profile.Tag = actor.id;
            fsc.IMG_Profile.MouseLeftButtonDown += GlobalHelper.SubContentMouseEvent;

            MainWindow.SetClickObject(fsc.Grid);
            if (actor.relationship.Equals("N"))
            {
                fsc.IC_Friend.Visibility = Visibility.Visible;
                MainWindow.SetClickObject(fsc.IC_Friend);
                fsc.IC_Friend.MouseLeftButtonDown += async(s, e) =>
                {
                    fsc.IC_Friend.Kind = MaterialDesignThemes.Wpf.PackIconKind.ProgressClock;
                    await KakaoRequestClass.FriendRequest(actor.id, false);

                    fsc.IC_Friend.Kind      = MaterialDesignThemes.Wpf.PackIconKind.ProgressCheck;
                    fsc.IC_Friend.IsEnabled = false;
                    e.Handled = true;
                };
            }
            if (actor.relationship.Equals("R"))
            {
                fsc.IC_Friend.Visibility = Visibility.Visible;
                fsc.IC_Friend.Kind       = MaterialDesignThemes.Wpf.PackIconKind.PersonAdd;
                fsc.IC_Friend.Foreground = Brushes.OrangeRed;
            }
            if (likeID != null && instance.data.actor.id.Equals(MainWindow.UserProfile.id))
            {
                fsc.IC_Delete.Visibility = Visibility.Visible;
                fsc.IC_Delete.PreviewMouseLeftButtonDown += async(s, e) =>
                {
                    e.Handled = true;
                    await KakaoRequestClass.DeleteLike(instance.data.id, likeID);

                    instance.SP_Emotions.Children.Remove(fsc);
                };
            }
        }
        private async void BT_Delete_Click(object sender, RoutedEventArgs e)
        {
            await KakaoRequestClass.DeleteMail(id);

            if (MainWindow.MailWindow != null)
            {
                await MainWindow.MailWindow.Refresh();
            }

            MessageBox.Show("쪽지 삭제가 완료되었습니다.");
            Close();
        }
        private async void MainContentMouseEvent(object s, MouseButtonEventArgs e)
        {
            string id = (string)((FrameworkElement)s).Tag;

            try
            {
                CommentData.PostData data = await KakaoRequestClass.GetPost(id);

                PostWindow.ShowPostWindow(data, id);
            }
            catch (Exception) { }
            e.Handled = true;
        }
        private async void BT_BackupFriends_Click(object sender, RoutedEventArgs e)
        {
            StringBuilder      builder            = new StringBuilder();
            List <string[]>    ids                = new List <string[]>();
            var                friends            = JsonConvert.DeserializeObject <FriendData.Friends>(await KakaoRequestClass.GetFriendData());
            ProgressShowWindow progressShowWindow = new ProgressShowWindow();

            progressShowWindow.Show();
            progressShowWindow.Topmost = true;
            progressShowWindow.Title   = "친구 목록 백업중";
            int progressCount = 0;

            foreach (var friend in friends.profiles)
            {
                try
                {
                    KakaoRequestClass.notShowError = true;
                    var profile = await KakaoRequestClass.GetProfileFeed(friend.id, null, true);

                    KakaoRequestClass.notShowError = false;
                    builder.Append(profile.profile.display_name);
                    builder.Append(" : ");
                    builder.Append(profile.profile.permalink);
                    builder.Append("\n");
                    ids.Add(new string[] { profile.profile.permalink, profile.profile.id, profile.profile.display_name });
                }
                catch (Exception) { }
                progressCount++;
                progressShowWindow.PB_Main.Value = ((double)progressCount / friends.profiles.Count) * 100.0;
            }
            Clipboard.SetDataObject(builder.ToString());
            progressShowWindow.isFinish = true;
            progressShowWindow.Close();
            var sfd = new System.Windows.Forms.SaveFileDialog()
            {
                FileName = DateTime.Now.ToShortDateString() + ".kfd2",
                Filter   = "Kakao Friend Data V2|*.kfd2",
                Title    = "친구 목록 저장"
            };

            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                var str    = JsonConvert.SerializeObject(ids);
                var writer = new System.IO.StreamWriter(sfd.FileName);
                writer.Write(str);
                writer.Close();
            }
            MessageBox.Show("클립보드에 친구 정보가 복사됐습니다.");
        }
Example #10
0
 private async void BT_Send_Click(object sender, RoutedEventArgs e)
 {
     if (TBX_Main.Text.Length > 0 && reciver != null)
     {
         await KakaoRequestClass.SendMail(TBX_Main.Text, reciver, false);
     }
     else if (TBX_Main.Text.Length == 0)
     {
         MessageBox.Show("쪽지 내용을 입력해주세요.", "오류");
     }
     else if (reciver == null)
     {
         MessageBox.Show("쪽지를 받는 친구를 선택해주세요.", "오류");
     }
 }
        private async void SV_Emotions_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            GlobalHelper.HandleScroll(sender, e);
            if (SV_Emotions.VerticalOffset == SV_Emotions.ScrollableHeight && e.Delta < 0 && !isEmotionWorking)
            {
                isEmotionWorking = true;
                var likes = await KakaoRequestClass.GetLikes(data, lastLikeID);

                if (likes.Count > 0)
                {
                    lastLikeID = likes.Last().id;
                    AddLikes(likes);
                }
                isEmotionWorking = false;
            }
        }
        private async void SV_Shares_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            GlobalHelper.HandleScroll(sender, e);
            if (SV_Shares.VerticalOffset == SV_Shares.ScrollableHeight && e.Delta < 0 && lastShareID != null && !isShareWorking)
            {
                isShareWorking = true;
                var shares = await KakaoRequestClass.GetShares(false, data, lastShareID);

                if (shares.Count > 0)
                {
                    AddShares(shares);
                    lastShareID = shares.Last().id;
                }
                isShareWorking = false;
            }
        }
        private async void SV_UP_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            GlobalHelper.HandleScroll(sender, e);
            if (SV_UP.VerticalOffset == SV_UP.ScrollableHeight && e.Delta < 0 && !isUPWorking)
            {
                isUPWorking = true;
                var ups = await KakaoRequestClass.GetShares(true, data, lastUPID);

                if (ups.Count > 0)
                {
                    lastUPID = ups.Last().id;
                    AddUps(ups);
                }
                isUPWorking = false;
            }
        }
        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;
            });
        }
        private async void BT_Submit_Click(object sender, RoutedEventArgs e)
        {
            BT_Submit.IsEnabled = false;
            BT_Submit.Content   = "업로드중...";

            if (IsNameChanged())
            {
                await KakaoRequestClass.SetProfileName(TBX_Name.Text);

                MainWindow.Instance.TB_Name.Text = TBX_Name.Text;
            }

            if (IsStatusMessageChanged())
            {
                await KakaoRequestClass.SetStatusMessage(TBX_Desc.Text);
            }

            if (IsBirthdayChanged())
            {
                if (!isBirthdayExists)
                {
                    await KakaoRequestClass.DeleteBirthday();
                }
                else
                {
                    await KakaoRequestClass.SetBirthday((DateTime)DP_Birthday.SelectedDate, CB_SunDate.IsChecked == false, CB_LeapType.IsChecked == true);
                }
            }
            if (IsGenderChanged())
            {
                if (!isGenderExists)
                {
                    await KakaoRequestClass.DeleteGender();
                }
                else
                {
                    await KakaoRequestClass.SetGender(GetCurrentGenderString(), CB_PublicSex.IsChecked == true? "A" : "F");
                }
            }

            string profileRawData = await KakaoRequestClass.GetProfileData();

            MainWindow.UserProfile = JsonConvert.DeserializeObject <UserProfile.ProfileData>(profileRawData);
            Close();
        }
        private void AddShares(List <ShareData.Share> shares)
        {
            foreach (var share in shares)
            {
                FriendSelectControl fsc = new FriendSelectControl();
                AssignProfile(fsc, share.actor, this);
                fsc.Grid.MouseLeftButtonDown += async(s, e) =>
                {
                    try
                    {
                        PostData pd = await KakaoRequestClass.GetPost(share.activity_id);

                        PostWindow.ShowPostWindow(pd, share.activity_id);
                    }
                    catch (Exception) {}
                    e.Handled = true;
                };
                SP_Shares.Children.Add(fsc);
            }
        }
        public UserInfoWindow(List <string> ids)
        {
            InitializeComponent();

            if (!Properties.Settings.Default.HideScrollBar)
            {
                SV_Main.VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
            }

            Dispatcher.Invoke(async() =>
            {
                List <ProfileData.Profile> profiles = new List <ProfileData.Profile>();
                foreach (string id in ids)
                {
                    var user = await KakaoRequestClass.GetProfile(id);
                    profiles.Add(user.profile);
                }
                AddProfile(profiles);
            });
        }
Example #18
0
        private async Task ChangePostRange(CommentData.PostData post)
        {
            string toPerm = null;

            if (CB_Range.SelectedIndex == 0)
            {
                toPerm = "A";
            }
            else if (CB_Range.SelectedIndex == 1)
            {
                toPerm = "F";
            }
            else if (CB_Range.SelectedIndex == 2)
            {
                toPerm = "M";
            }

            await KakaoRequestClass.SetActivityProfile(post.id, toPerm, post.sharable, post.comment_all_writable, post.is_must_read);

            return;
        }
 private async void IC_Friend_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (relationship.relationship.Equals("F"))
     {
         bool isDelete = MessageBox.Show("친구를 삭제하시겠습니까?", "안내", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;
         if (isDelete)
         {
             await KakaoRequestClass.DeleteFriend(relationship.id);
             await RefreshTimeline(null, true);
         }
     }
     else if (relationship.relationship.Equals("R"))
     {
         bool isRequest = MessageBox.Show("이 사용자에게 친구 신청을 보내시겠습니까?", "안내", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes;
         if (isRequest)
         {
             await KakaoRequestClass.FriendRequest(relationship.id, true);
             await RefreshTimeline(null, true);
         }
     }
     else if (relationship.relationship.Equals("C"))
     {
         var question = MessageBox.Show("친구 신청을 수락하시겠습니까?", "안내", MessageBoxButton.YesNo, MessageBoxImage.Question);
         if (question != MessageBoxResult.Cancel && question != MessageBoxResult.None)
         {
             bool isDelete = question == MessageBoxResult.No;
             await KakaoRequestClass.FriendAccept(relationship.id, isDelete);
             await RefreshTimeline(null, true);
         }
     }
     else if (relationship.relationship.Equals("N"))
     {
         await KakaoRequestClass.FriendRequest(relationship.id, false);
         await RefreshTimeline(null, true);
     }
 }
Example #20
0
        private async void BT_Confirm_Click(object sender, RoutedEventArgs e)
        {
            BT_Confirm.IsEnabled = false;
            if (MainWindow.IsLoggedIn && !MainWindow.IsOffline)
            {
                int deleted = 0;
                int counted = 0;
                var feed    = await KakaoRequestClass.GetProfileFeed(MainWindow.UserProfile.id, null);

                if (feed.activities.Count == 0)
                {
                    MessageBox.Show("삭제할 게시글이 존재하지 않습니다.");
                    BT_Confirm.IsEnabled = true;
                    return;
                }
                else
                {
                    if (MessageBox.Show("조건에 맞는 게시글을 전부 삭제하시겠습니까?\n이 작업은 되돌릴 수 없습니다!", "경고", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                    {
                        CB_Category.IsEnabled  = false;
                        CB_Exclude.IsEnabled   = false;
                        CB_Include.IsEnabled   = false;
                        CB_Favorite.IsEnabled  = false;
                        TB_Filter.IsEnabled    = false;
                        SP_Progress.Visibility = Visibility.Visible;
                        TB_Progress.Text       = "삭제 준비중...";
                        try
                        {
                            MainWindow.IsLoggedIn = false;
                            async void Delete()
                            {
                                foreach (var activity in feed.activities)
                                {
                                    bool     willDelete = true;
                                    string[] shareIndex = { null, "A", "F", "P", "M" };
                                    if (CB_Category.SelectedIndex == 5)
                                    {
                                        if (!activity.blinded)
                                        {
                                            willDelete = false;
                                        }
                                    }
                                    else if (CB_Category.SelectedIndex > 0 && !activity.permission.Equals(shareIndex[CB_Category.SelectedIndex]))
                                    {
                                        willDelete = false;
                                    }
                                    if (CB_Include.IsChecked == true && !activity.content.Contains(TB_Filter.Text))
                                    {
                                        willDelete = false;
                                    }
                                    if (CB_Exclude.IsChecked == true && activity.content.Contains(TB_Filter.Text))
                                    {
                                        willDelete = false;
                                    }
                                    if (CB_Favorite.IsChecked == true && activity.pinned)
                                    {
                                        willDelete = false;
                                    }

                                    if (willDelete)
                                    {
                                        await Task.Delay(100);

                                        await KakaoRequestClass.DeletePost(activity.id);

                                        deleted++;
                                    }
                                    counted++;
                                    TB_Progress.Text = $"삭제된 게시글/전체 게시글 : {deleted}/{counted}";
                                    if (!activate)
                                    {
                                        break;
                                    }
                                }
                                if (!activate)
                                {
                                    MessageBox.Show("게시글 삭제가 취소됐습니다.", "안내");
                                    MainWindow.IsLoggedIn = true;
                                    await MainWindow.UpdateProfile();

                                    return;
                                }
                                feed = await KakaoRequestClass.GetProfileFeed(MainWindow.UserProfile.id, feed.activities[feed.activities.Count - 1].id);

                                if (feed != null && (feed.activities?.Count ?? 0) > 0)
                                {
                                    Delete();
                                }
                                else
                                {
                                    MessageBox.Show("삭제가 모두 완료됐습니다.", "안내");
                                    MainWindow.IsLoggedIn = true;
                                    await MainWindow.UpdateProfile();

                                    Close();
                                }
                            }
                            Delete();
                        } catch (Exception e2) { MessageBox.Show("작업 도중 알 수 없는 오류가 발생했습니다.\n" + e2.Message); }
                    }
                }
            }
        }
        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;
        }
        public async Task RefreshTimeline(string from, bool isClear)
        {
            if (from == null)
            {
                lastOffset = -1;
            }
            BT_Refresh.IsEnabled = false;
            PR_Loading.IsActive  = true;
            TB_RefreshBT.Text    = "갱신중...";
            IC_Refresh.Kind      = MaterialDesignThemes.Wpf.PackIconKind.ProgressClock;

            List <CommentData.PostData> feeds;

            if (!isProfile)
            {
                TimeLineData.TimeLine feedData = await KakaoRequestClass.GetFeed(from);

                nextRequest = feedData.next_since;
                feeds       = feedData.feeds;
            }
            else
            {
                string from2 = from;
                if (showBookmarked)
                {
                    from2 = null;
                }
                var profile = await KakaoRequestClass.GetProfileFeed(profileID, from2);

                relationship = await KakaoRequestClass.GetProfileRelationship(profileID);

                if (profile.profile.bg_image_url != null)
                {
                    string imgUri = profile.profile.profile_video_url_square_small ?? profile.profile.profile_image_url2;
                    if (Properties.Settings.Default.GIFProfile && profile.profile.profile_video_url_square_small != null)
                    {
                        imgUri = profile.profile.profile_video_url_square_small;
                    }
                    GlobalHelper.AssignImage(IMG_Profile, imgUri);
                    GlobalHelper.AssignImage(IMG_ProfileBG, profile.profile.bg_image_url);
                    IMG_Profile.MouseLeftButtonDown   += GlobalHelper.SaveImageHandler;
                    IMG_ProfileBG.MouseLeftButtonDown += GlobalHelper.SaveImageHandler;

                    TB_Name.Text = profile.profile.display_name;

                    if (profile.profile.status_objects?.Count > 0)
                    {
                        TB_Desc.Text = profile.profile.status_objects?[0]?.message ?? "한줄 소개 없음";
                    }
                    else
                    {
                        TB_Desc.Text = "한줄 소개 없음";
                    }

                    TB_Desc2.Text  = profile.mutual_friend?.message ?? "함께 아는 친구 없음";
                    TB_Desc2.Text += "/ " + profile.profile.activity_count.ToString() + "개의 스토리";
                }
                GD_Favorite.Visibility = Visibility.Collapsed;
                if (relationship.relationship.Equals("F"))
                {
                    IC_Friend.Kind         = MaterialDesignThemes.Wpf.PackIconKind.AccountMinus;
                    IC_Friend.ToolTip      = "친구 삭제";
                    GD_Favorite.Visibility = Visibility.Visible;
                    if (profile.profile.is_favorite)
                    {
                        IC_Favorite.Fill = Brushes.OrangeRed;
                    }
                    else
                    {
                        IC_Favorite.Fill = Brushes.Gray;
                    }
                    MainWindow.SetClickObject(IC_Favorite);
                    ICP_Favorite.MouseEnter += (s, e) =>
                    {
                        Mouse.OverrideCursor = Cursors.Hand;
                        e.Handled            = true;
                    };
                    async void onMouseDown(object s, MouseButtonEventArgs e)
                    {
                        await KakaoRequestClass.FavoriteRequest(profile.profile.id, profile.profile.is_favorite);

                        await RefreshTimeline(null, true);

                        e.Handled = true;
                    }

                    IC_Favorite.MouseLeftButtonDown  += onMouseDown;
                    ICP_Favorite.MouseLeftButtonDown += onMouseDown;
                }
                else if (relationship.relationship.Equals("R"))
                {
                    IC_Friend.Kind    = MaterialDesignThemes.Wpf.PackIconKind.AccountRemove;
                    IC_Friend.ToolTip = "친구 신청 취소";
                }
                else if (relationship.relationship.Equals("C"))
                {
                    IC_Friend.Kind    = MaterialDesignThemes.Wpf.PackIconKind.AccountQuestionMark;
                    IC_Friend.ToolTip = "친구 신청 처리";
                }
                else if (relationship.relationship.Equals("N"))
                {
                    IC_Friend.Kind    = MaterialDesignThemes.Wpf.PackIconKind.AccountPlus;
                    IC_Friend.ToolTip = "친구 추가";
                }
                else
                {
                    IC_Friend.Visibility = Visibility.Collapsed;
                }

                BT_Write.Visibility = Visibility.Collapsed;
                if (profile.activities.Count > 15)
                {
                    nextRequest = profile.activities.Last().id;
                }

                if (MainWindow.UserProfile.id.Equals(profileID) && showBookmarked != true)
                {
                    Title         = "내 프로필";
                    TB_Desc2.Text = profile.profile.activity_count.ToString() + "개의 스토리";
                }
                else
                {
                    Title = profile.profile.display_name + "님의 프로필";
                }
                if (showBookmarked)
                {
                    Title = "관심글 조회";
                    var bookmarks = await KakaoRequestClass.GetBookmark(profileID, from);

                    var feedsNow = new List <CommentData.PostData>();
                    foreach (var bookmark in bookmarks.bookmarks)
                    {
                        if (bookmark.status == 0)
                        {
                            feedsNow.Add(bookmark.activity);
                        }
                    }
                    feeds       = feedsNow;
                    nextRequest = bookmarks.bookmarks.Last().id;
                }
                else
                {
                    feeds = profile.activities;
                }
            }

            if (isProfile && feeds.Count != 18)
            {
                scrollEnd = true;
            }

            if (isClear)
            {
                SP_Content.Children.Clear();
                SV_Content.ScrollToVerticalOffset(0);
            }
            foreach (var feed in feeds)
            {
                if (feed.verb.Equals("post") || feed.verb.Equals("share"))
                {
                    TimeLinePageControl tlp = GenerateTimeLinePageControl(feed);
                    SP_Content.Children.Add(tlp);
                    SP_Content.Children.Add(new Rectangle()
                    {
                        Height = 10,
                        Fill   = Brushes.Transparent
                    });
                }
                else if (feed.verb.Equals("bundled_feed"))
                {
                    try
                    {
                        if (feed.bundled_feed != null && feed.bundled_feed.type.Equals("share"))
                        {
                            CommentData.PostData feedNow = feed.bundled_feed.activities?[0];
                            if (feedNow != null)
                            {
                                feedNow.@object = feed.bundled_feed.original_activity;
                                TimeLinePageControl tlp = GenerateTimeLinePageControl(feedNow);
                                GlobalHelper.SetShareFriendsTB(tlp.TB_Title, feed.bundled_feed.title_decorators);
                                tlp.TB_Title.Visibility    = Visibility.Visible;
                                tlp.TB_TitleSep.Visibility = Visibility.Visible;
                                SP_Content.Children.Add(tlp);
                                SP_Content.Children.Add(new Rectangle()
                                {
                                    Height = 10,
                                    Fill   = Brushes.Transparent
                                });
                            }
                        }
                        else if (feed.bundled_feed != null && feed.bundled_feed.type.Equals("up"))
                        {
                            CommentData.PostData feedNow = feed.bundled_feed.original_activity;
                            if (feedNow != null)
                            {
                                TimeLinePageControl tlp = GenerateTimeLinePageControl(feedNow);
                                GlobalHelper.SetShareFriendsTB(tlp.TB_Title, feed.bundled_feed.title_decorators);
                                tlp.TB_Title.Visibility    = Visibility.Visible;
                                tlp.TB_TitleSep.Visibility = Visibility.Visible;
                                SP_Content.Children.Add(tlp);
                                SP_Content.Children.Add(new Rectangle()
                                {
                                    Height = 10,
                                    Fill   = Brushes.Transparent
                                });
                            }
                        }
                    }
                    catch (Exception) { }
                }
            }
            BT_Refresh.IsEnabled = true;
            TB_RefreshBT.Text    = "새로고침";
            IC_Refresh.Kind      = MaterialDesignThemes.Wpf.PackIconKind.Refresh;

            PR_Loading.IsActive = false;
            return;
        }
        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;
        }
Example #24
0
        public static async void ShowNotification(string title, string message, string URL, string commentID, string id, string name, string writer, string identity, string thumbnailURL)
        {
            if (MainWindow.IsDND != true)
            {
                if (Environment.OSVersion.Version.Major == 10)
                {
                    try
                    {
                        var Visual = new Microsoft.Toolkit.Uwp.Notifications.ToastVisual()
                        {
                            BindingGeneric = new Microsoft.Toolkit.Uwp.Notifications.ToastBindingGeneric()
                            {
                                Children =
                                {
                                    new Microsoft.Toolkit.Uwp.Notifications.AdaptiveText()
                                    {
                                        Text = title
                                    },

                                    new Microsoft.Toolkit.Uwp.Notifications.AdaptiveText()
                                    {
                                        Text = message
                                    }
                                }
                            }
                        };
                        try
                        {
                            bool   isThumbnailReplaced = false;
                            string text       = URL.Split(new string[] { "!" }, StringSplitOptions.None)[1];
                            string activityID = text.Split(new string[] { "activities/" }, StringSplitOptions.None)[1];
                            var    post       = await KakaoRequestClass.GetPost(activityID);

                            if (commentID != null)
                            {
                                foreach (var comment in post.comments)
                                {
                                    if (comment.id.Equals(commentID))
                                    {
                                        thumbnailURL = comment.decorators?[0]?.media?.url;
                                        if (thumbnailURL != null)
                                        {
                                            isThumbnailReplaced = true;
                                        }
                                        break;
                                    }
                                }
                            }

                            if (!isThumbnailReplaced)
                            {
                                if (post.@object != null)
                                {
                                    if ([email protected]_type?.Equals("video") == true)
                                    {
                                        thumbnailURL = [email protected][0]?.preview_url_hq;
                                    }
                                    else
                                    {
                                        thumbnailURL = [email protected]?[0]?.url;
                                    }
                                }
                                else
                                {
                                    if (post.media_type?.Equals("video") == true)
                                    {
                                        thumbnailURL = post.media[0]?.preview_url_hq;
                                    }
                                    else
                                    {
                                        thumbnailURL = post.media?[0]?.url;
                                    }
                                }
                            }

                            if (thumbnailURL != null)
                            {
                                Visual.BindingGeneric.HeroImage = new Microsoft.Toolkit.Uwp.Notifications.ToastGenericHeroImage()
                                {
                                    Source = thumbnailURL,
                                };
                            }
                        }
                        catch (Exception) { }
                        Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom Action;
                        if (URL == null)
                        {
                            Action = new Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom();
                        }
                        else
                        {
                            if (commentID != null)
                            {
                                Action = new Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom()
                                {
                                    Inputs =
                                    {
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastTextBox("tbReply")
                                        {
                                            PlaceholderContent = "답장 작성하기",
                                        },
                                    },
                                    Buttons =
                                    {
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("보내기", URL + "REPLY!@#$%" + "R!@=!!" + id + "R!@=!!" + name + "R!@=!!" + writer + "R!@=!!" + identity)
                                        {
                                            ActivationType = Microsoft.Toolkit.Uwp.Notifications.ToastActivationType.Background,
                                            TextBoxId      = "tbReply"
                                        },
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("열기",  URL),
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("좋아요", URL + "LIKE!@#$%" + commentID),
                                    },
                                };
                            }
                            else
                            {
                                Action = new Microsoft.Toolkit.Uwp.Notifications.ToastActionsCustom()
                                {
                                    Buttons =
                                    {
                                        new Microsoft.Toolkit.Uwp.Notifications.ToastButton("열기", URL)
                                    }
                                };
                            }
                        }
                        var toastContent = new Microsoft.Toolkit.Uwp.Notifications.ToastContent()
                        {
                            Visual  = Visual,
                            Actions = Action,
                        };
                        var toastXml = new Windows.Data.Xml.Dom.XmlDocument();
                        toastXml.LoadXml(toastContent.GetContent());
                        var toast = new Windows.UI.Notifications.ToastNotification(toastXml);
                        //toast.Activated += (s, e) =>
                        //{
                        //    KSPNotificationActivator.ActivateHandler(URL, null);
                        //};
                        toast.ExpirationTime = DateTimeOffset.MaxValue;
                        DesktopNotificationManagerCompat.CreateToastNotifier().Show(toast);
                    }
                    catch (Exception) { }
                }
            }
        }
 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]);
                 }
             }
         }
     });
 }
Example #26
0
        private async void FeedLoop(List <CommentData.PostData> posts)
        {
            StringBuilder extractedLink = new StringBuilder();

            TB_Progress.Text = "작업중...";
            int failCount = 0;
            await Dispatcher.Invoke(async() =>
            {
                for (int i = 0; i < posts.Count; i++)
                {
                    if (isClosed)
                    {
                        break;
                    }
                    var post = posts[i];
                    if (CB_Target.SelectedIndex == 1 && !post.permission.Equals("A"))
                    {
                        continue;
                    }
                    else if (CB_Target.SelectedIndex == 2 && !post.permission.Equals("F"))
                    {
                        continue;
                    }
                    else if (CB_Target.SelectedIndex == 3 && !post.permission.Equals("P"))
                    {
                        continue;
                    }
                    else if (CB_Target.SelectedIndex == 4 && !post.permission.Equals("M"))
                    {
                        continue;
                    }
                    else if (CB_Target.SelectedIndex == 5 && !post.bookmarked)
                    {
                        continue;
                    }

                    if (CB_Task.SelectedIndex == 0)
                    {
                        try
                        {
                            await ChangePostRange(post);
                        }
                        catch (Exception) { failCount++; }
                        await Task.Delay(100);
                    }
                    if (CB_Task.SelectedIndex == 1)
                    {
                        extractedLink.Append(post.permalink);
                        extractedLink.Append("\n");
                    }
                    if (CB_Task.SelectedIndex == 2)
                    {
                        try
                        {
                            if (CB_Target.SelectedIndex == 5)
                            {
                                await KakaoRequestClass.PinPost(post.id, true);
                            }
                            else
                            {
                                await KakaoRequestClass.PinPost(post.id, false);
                            }
                        } catch (Exception) { failCount++; }
                        await Task.Delay(100);
                    }
                    TB_Progress.Text = $"작업중... ({i}/{posts.Count})";
                    PB_Main.Value    = (double)i / posts.Count * 100.0;
                }

                if (!isClosed)
                {
                    Dispatcher.Invoke(() =>
                    {
                        if (extractedLink.Length > 0)
                        {
                            Clipboard.SetDataObject(extractedLink.ToString());
                            MessageBox.Show("링크 추출 완료\n추출된 링크는 클립보드에 복사되었습니다. Ctrl+V를 사용하여 붙여넣기하세요.", "안내");
                        }
                        else
                        {
                            MessageBox.Show($"작업 완료.\n작업에 실패한 게시글 수 : {failCount.ToString()}\n(제한된 게시글과 같은 이유로 작업에 실패하는 경우가 있습니다)", "안내");
                        }
                        SP_Progress.Visibility = Visibility.Collapsed;
                        Close();
                    });
                }
            });
        }
Example #27
0
        public MainWindow()
        {
            InitializeComponent();
            TSW_DarkMode.IsChecked = Properties.Settings.Default.DarkMode;
            TSW_DarkMode_Click(null, null);

            Dispatcher.InvokeAsync(async() =>
            {
                if (Environment.OSVersion.Version.Major != 10)
                {
                    bool isLatest = await GlobalHelper.CheckUpdate();
                    if (!isLatest)
                    {
                        if (MessageBox.Show("새로운 업데이트를 확인했습니다.\n 업데이트를 받으시겠습니까?", "안내", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
                        {
                            System.Diagnostics.Process.Start("https://kagamine-rin.com/?p=186");
                        }
                    }
                }
            });

            CB_AutoLogin.IsChecked = Properties.Settings.Default.AutoLogin;

            Environment.CurrentDirectory = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
            TrayNotifyIcon = new NotifyIcon
            {
                Icon    = new Icon("icon.ico"),
                Visible = true
            };
            TrayNotifyIcon.MouseDoubleClick += (s, e) =>
            {
                if (Properties.Settings.Default.DefaultMinimize)
                {
                    WindowState = WindowState.Normal;
                }
                else
                {
                    Show();
                }

                Activate();
            };
            TrayNotifyIcon.BalloonTipClicked += (s, e) =>
            {
                if (TrayNotifyIcon.Tag != null)
                {
                    KSPNotificationActivator.ActivateHandler((string)TrayNotifyIcon.Tag, null);
                    TrayNotifyIcon.Tag = null;
                }
                else
                {
                    Show();
                    //Activate();
                }
            };

            ContextMenu menu     = new ContextMenu();
            MenuItem    timeline = new MenuItem
            {
                Index = 0,
                Text  = "타임라인"
            };

            timeline.Click += (s, a) =>
            {
                BT_TimeLine_Click(null, null);
            };
            menu.MenuItems.Add(timeline);

            MenuItem write = new MenuItem
            {
                Index = 0,
                Text  = "게시글 작성"
            };

            write.Click += (s, a) =>
            {
                BT_Write_Click(null, null);
            };
            menu.MenuItems.Add(write);

            MenuItem notification = new MenuItem
            {
                Index = 0,
                Text  = "알림 확인"
            };

            notification.Click += (s, a) =>
            {
                BT_Notifiations_Click(null, null);
            };
            menu.MenuItems.Add(notification);

            MenuItem profile = new MenuItem
            {
                Index = 0,
                Text  = "내 프로필"
            };

            profile.Click += (s, a) =>
            {
                BT_MyProfile_Click(null, null);
            };
            menu.MenuItems.Add(profile);

            MenuItem settings = new MenuItem
            {
                Index = 0,
                Text  = "설정"
            };

            settings.Click += (s, a) =>
            {
                BT_Settings_Click(null, null);
            };
            menu.MenuItems.Add(settings);

            MenuItem exit = new MenuItem
            {
                Index = 0,
                Text  = "종료"
            };

            exit.Click += (s, a) =>
            {
                Hide();
                IsClose = true;
                Environment.Exit(0);
            };
            menu.MenuItems.Add(exit);

            TrayNotifyIcon.ContextMenu = menu;

            if (Properties.Settings.Default.AutoLogin)
            {
                TBX_Email.Text        = Properties.Settings.Default.AutoEmail;
                TBX_Password.Password = Properties.Settings.Default.AutoPassword;
                Task.Run(() =>
                {
                    Dispatcher.InvokeAsync(() =>
                    {
                        TryLogin();
                    });
                });
            }

            SetClickObject(GD_Friends);
            SetClickObject(GD_Write);
            SetClickObject(GD_Timeline);
            SetClickObject(GD_Notifications);
            SetClickObject(GD_Mail);
            SetClickObject(GD_Settings);
            SetClickObject(GD_Friends);
            SetClickObject(GD_ProfileSettings);
            SetClickObject(BT_Login);
            SetClickObject(EL_Profile);
            SetClickObject(TB_MyProfile);
            SetClickObject(TB_Tray);
            SetClickObject(IMG_Power);

            Dispatcher.InvokeAsync(async() =>
            {
                await KakaoRequestClass.RequestNotification(false);
            });
        }
Example #28
0
        private async void BT_Execute_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("작업을 실행하시겠습니까?\n이 작업은 되돌릴 수 없습니다!", "경고", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                SP_Progress.Visibility       = Visibility.Visible;
                BT_Execute.IsEnabled         = false;
                BT_Execute.Content           = "실행중..";
                CB_Task.IsEnabled            = false;
                CB_Target.IsEnabled          = false;
                CB_Range.IsEnabled           = false;
                CB_ExcludeFavorite.IsEnabled = false;

                TB_Progress.Text       = "준비중...";
                SP_Progress.Visibility = Visibility.Visible;
                PR_Main.IsActive       = true;

                List <CommentData.PostData> posts = new List <CommentData.PostData>();
                await Dispatcher.Invoke(async() =>
                {
                    if ((CB_Task.SelectedIndex == 1 || CB_Task.SelectedIndex == 2) && CB_Target.SelectedIndex == 5)
                    {
                        var bookmarkMain = await KakaoRequestClass.GetBookmark(MainWindow.UserProfile.id, null);
                        while (!isClosed)
                        {
                            foreach (var bookmark in bookmarkMain.bookmarks)
                            {
                                posts.Add(bookmark.activity);
                            }
                            TB_Progress.Text = $"게시글 조회 ({posts.Count})";
                            bookmarkMain     = await KakaoRequestClass.GetBookmark(MainWindow.UserProfile.id, bookmarkMain.bookmarks.Last().id);
                            if (bookmarkMain.bookmarks.Count == 0)
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        var feeds = await KakaoRequestClass.GetProfileFeed(MainWindow.UserProfile.id, null);
                        while (!isClosed)
                        {
                            posts.AddRange(feeds.activities);
                            TB_Progress.Text = $"게시글 조회 ({posts.Count})";
                            feeds            = await KakaoRequestClass.GetProfileFeed(MainWindow.UserProfile.id, feeds.activities[feeds.activities.Count - 1].id);
                            if (feeds.activities.Count == 0)
                            {
                                break;
                            }
                        }
                    }
                    PR_Main.IsActive   = false;
                    PR_Main.Visibility = Visibility.Collapsed;

                    PB_Main.Visibility = Visibility.Visible;
                    if (!isClosed)
                    {
                        FeedLoop(posts);
                    }
                });
            }
        }
Example #29
0
        private async void BT_Submit_Click(object sender, RoutedEventArgs e)
        {
            if (BT_Submit.IsEnabled == true)
            {
                BT_Submit.IsEnabled = false;
                string baseStr = "게시중...";
                BT_Submit.Content = baseStr;
                bool isImageExists = false;
                bool isVideoExists = false;
                if (assets.Count > 0)
                {
                    foreach (var asset in assets)
                    {
                        var assetData = new MediaData.MediaObject();
                        if (asset.Type.Equals("video"))
                        {
                            if (asset.Key == null)
                            {
                                assetData.media_path = await UploadVideo(asset);
                                await GetPercentVideo(assetData.media_path);
                                await GetMetaVideo(assetData.media_path);
                            }
                            else
                            {
                                assetData.media_path = asset.Key;
                            }
                            isVideoExists = true;
                        }
                        else
                        {
                            if (asset.Key == null)
                            {
                                assetData.media_path = await UploadImage(asset);
                            }
                            else
                            {
                                assetData.media_path = asset.Key;
                            }
                            isImageExists = true;
                        }
                        assetData.media_type = asset.Type;
                        assetData.caption    = new List <string>();
                        StoryMediaData.media.Add(assetData);
                    }

                    if (isImageExists && isVideoExists)
                    {
                        StoryMediaData.media_type = "mixed";
                    }
                    else if (isImageExists)
                    {
                        StoryMediaData.media_type = "image";
                    }
                    else if (isVideoExists)
                    {
                        StoryMediaData.media_type = "video";
                    }

                    mediaText = JsonConvert.SerializeObject(StoryMediaData);
                }

                string permission = "F";

                switch (ComboRange.SelectedIndex)
                {
                case 0:
                    permission = "A";
                    break;

                case 1:
                    permission = "F";
                    break;

                case 2:
                    permission = "P";
                    break;

                case 3:
                    permission = "M";
                    break;
                }
                if (permission.Equals("P") && trust_ids.Count == 0)
                {
                    MessageBox.Show("편한 친구를 선택해주세요.");
                }
                else
                {
                    try
                    {
                        if (!isShare)
                        {
                            await WriteText(TB_Main.Text, permission, (bool)CB_Comment.IsChecked, (bool)CB_Share.IsChecked);
                        }
                        else
                        {
                            await KakaoRequestClass.ShareFeed(shareFeedID, TB_Main.Text, permission, (bool)CB_Comment.IsChecked, with_ids, trust_ids);
                        }
                        if (MainWindow.ProfileTimeLineWindow != null)
                        {
                            await MainWindow.ProfileTimeLineWindow.RefreshTimeline(null, true);
                        }
                        if (MainWindow.TimeLineWindow != null)
                        {
                            await MainWindow.TimeLineWindow.RefreshTimeline(null, true);
                        }
                        Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("업로드 도중 오류가 발생했습니다.\n" + ex.Message);
                    }
                }
                BT_Submit.IsEnabled = true;
                BT_Submit.Content   = "게시";
            }
        }