Exemple #1
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;
        }
        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 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);
     }
 }
Exemple #5
0
        private void ShowFriends(string filter)
        {
            SP_Content.Children.Clear();
            controls.Clear();

            foreach (var friend in MainWindow.UserFriends.profiles)
            {
                if (friend.blocked != true && friend.display_name.ToLower().Contains(filter.ToLower()))
                {
                    if (CB_OnlyFavorite.IsChecked == true && !friend.is_favorite)
                    {
                        continue;
                    }

                    FriendSelectControl fsc = new FriendSelectControl
                    {
                        id   = friend.id,
                        name = friend.display_name
                    };
                    MainWindow.SetClickObject(fsc.Grid);
                    string imgUri = friend.profile_thumbnail_url;
                    if (Properties.Settings.Default.GIFProfile && friend.profile_video_url_square_small != null)
                    {
                        imgUri = friend.profile_video_url_square_small;
                    }
                    GlobalHelper.AssignImage(fsc.IMG_Profile, imgUri);
                    fsc.TB_Name.Text         = friend.display_name;
                    fsc.TB_Name.Tag          = friend.is_favorite;
                    fsc.Grid.Tag             = friend.id;
                    fsc.MouseLeftButtonDown += OnGridClick;
                    fsc.Tag        = false;
                    fsc.Background = Brushes.Transparent;
                    controls.Add(fsc);
                    SP_Content.Children.Add(fsc);
                }
            }
            SV_Content.ScrollToTop();
            if (controls.Count == 0)
            {
                TB_Empty.Visibility = Visibility.Visible;
            }
            else
            {
                TB_Empty.Visibility = Visibility.Collapsed;
            }
        }
        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);
            }
        }
 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);
     }
 }