Exemplo n.º 1
0
        public TestSceneUserProfileHeader()
        {
            header = new ProfileHeader();
            Add(header);

            AddStep("Show offline dummy", () => header.User.Value = TestSceneUserProfileOverlay.TEST_USER);

            AddStep("Show null dummy", () => header.User.Value = new User
            {
                Username = "******"
            });

            addOnlineStep("Show ppy", new User
            {
                Username    = @"peppy",
                Id          = 2,
                IsSupporter = true,
                Country     = new Country {
                    FullName = @"Australia", FlagName = @"AU"
                },
                CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
            });

            addOnlineStep("Show flyte", new User
            {
                Username = @"flyte",
                Id       = 3103765,
                Country  = new Country {
                    FullName = @"Japan", FlagName = @"JP"
                },
                CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
            });
        }
Exemplo n.º 2
0
        public void UpdateSupergroupFullInfo(Chat chat, Supergroup group, SupergroupFullInfo fullInfo)
        {
            ProfileHeader?.UpdateSupergroupFullInfo(chat, group, fullInfo);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateSupergroupFullInfo(chat, group, fullInfo);
            }
        }
Exemplo n.º 3
0
        public void UpdateChatPhoto(Chat chat)
        {
            ProfileHeader?.UpdateChatPhoto(chat);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateChatPhoto(chat);
            }
        }
Exemplo n.º 4
0
        public void UpdateSecretChat(Chat chat, SecretChat secretChat)
        {
            ProfileHeader?.UpdateSecretChat(chat, secretChat);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateSecretChat(chat, secretChat);
            }
        }
Exemplo n.º 5
0
        public void UpdateBasicGroup(Chat chat, BasicGroup group)
        {
            ProfileHeader?.UpdateBasicGroup(chat, group);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateBasicGroup(chat, group);
            }
        }
Exemplo n.º 6
0
        public void UpdateUserFullInfo(Chat chat, User user, UserFullInfo fullInfo, bool secret, bool accessToken)
        {
            ProfileHeader?.UpdateUserFullInfo(chat, user, fullInfo, secret, accessToken);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateUserFullInfo(chat, user, fullInfo, secret, accessToken);
            }
        }
Exemplo n.º 7
0
        public void UpdateUserStatus(Chat chat, User user)
        {
            ProfileHeader?.UpdateUserStatus(chat, user);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateUserStatus(chat, user);
            }
        }
Exemplo n.º 8
0
        public void UpdateUser(Chat chat, User user, bool secret)
        {
            ProfileHeader?.UpdateUser(chat, user, secret);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateUser(chat, user, secret);
            }
        }
Exemplo n.º 9
0
        public void UpdateChatNotificationSettings(Chat chat)
        {
            ProfileHeader?.UpdateChatNotificationSettings(chat);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateChatNotificationSettings(chat);
            }
        }
Exemplo n.º 10
0
        public void UpdateChatTitle(Chat chat)
        {
            Title = chat.Title;

            ProfileHeader?.UpdateChatTitle(chat);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateChatTitle(chat);
            }
        }
Exemplo n.º 11
0
        public void UpdateBasicGroupFullInfo(Chat chat, BasicGroup group, BasicGroupFullInfo fullInfo)
        {
            ProfileHeader?.UpdateBasicGroupFullInfo(chat, group, fullInfo);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateBasicGroupFullInfo(chat, group, fullInfo);
            }

            ViewModel.Members = new SortedObservableCollection <ChatMember>(new ChatMemberComparer(ViewModel.ProtoService, true), fullInfo.Members);
        }
Exemplo n.º 12
0
 public void ClickOnProfileHeader()
 {
     if (ProfileHeader.Displayed)
     {
         ProfileHeader.Click();
         Thread.Sleep(3000);
     }
     else
     {
         throw new Exception("Element is not found or not clickable");
     }
 }
        public static MvcHtmlString ProfileHeaderRenderer(this HtmlHelper html, ProfileHeader header)
        {
            var builder = new StringBuilder();

            var el = new TagBuilder("p")
                         {
                             InnerHtml = header.Title,
                         };
            el.AddCssClass("profile-header");

            builder.Append(el);
            return MvcHtmlString.Create(builder.ToString());
        }
Exemplo n.º 14
0
        public void UpdateSupergroup(Chat chat, Supergroup group)
        {
            ProfileHeader?.UpdateSupergroup(chat, group);

            if (MediaFrame.Content is ChatSharedMediaPageBase sharedMedia)
            {
                sharedMedia.Header.UpdateSupergroup(chat, group);
            }

            if (!group.IsChannel && (ViewModel.Members == null || group.MemberCount < 200 && group.MemberCount != ViewModel.Members.Count))
            {
                ViewModel.Members = ViewModel.CreateMembers(group.Id);
            }
        }
Exemplo n.º 15
0
        public static MvcHtmlString ProfileHeaderRenderer(this HtmlHelper html, ProfileHeader header)
        {
            var builder = new StringBuilder();

            var el = new TagBuilder("p")
            {
                InnerHtml = header.Title,
            };

            el.AddCssClass("profile-header");

            builder.Append(el);
            return(MvcHtmlString.Create(builder.ToString()));
        }
Exemplo n.º 16
0
        public void ShowUser(User user, bool fetchOnline = true)
        {
            if (user == User.SYSTEM_USER)
            {
                return;
            }

            Show();

            if (user.Id == Header?.User.Value?.Id)
            {
                return;
            }

            userReq?.Cancel();
            Clear();
            lastSection = null;

            sections = !user.IsBot
                ? new ProfileSection[]
            {
                //new AboutSection(),
                new RecentSection(),
                new RanksSection(),
                //new MedalsSection(),
                new HistoricalSection(),
                new BeatmapsSection(),
                new KudosuSection()
            }
                : Array.Empty <ProfileSection>();

            tabs = new ProfileSectionTabControl
            {
                RelativeSizeAxes = Axes.X,
                Anchor           = Anchor.TopCentre,
                Origin           = Anchor.TopCentre,
            };

            Add(new Box
            {
                RelativeSizeAxes = Axes.Both,
                Colour           = ColourProvider.Background6
            });

            Add(sectionsContainer = new ProfileSectionsContainer
            {
                ExpandableHeader = Header = new ProfileHeader(),
                FixedHeader      = tabs,
                HeaderBackground = new Box
                {
                    // this is only visible as the ProfileTabControl background
                    Colour           = ColourProvider.Background5,
                    RelativeSizeAxes = Axes.Both
                },
            });
            sectionsContainer.SelectedSection.ValueChanged += section =>
            {
                if (lastSection != section.NewValue)
                {
                    lastSection        = section.NewValue;
                    tabs.Current.Value = lastSection;
                }
            };

            tabs.Current.ValueChanged += section =>
            {
                if (lastSection == null)
                {
                    lastSection = sectionsContainer.Children.FirstOrDefault();
                    if (lastSection != null)
                    {
                        tabs.Current.Value = lastSection;
                    }
                    return;
                }

                if (lastSection != section.NewValue)
                {
                    lastSection = section.NewValue;
                    sectionsContainer.ScrollTo(lastSection);
                }
            };

            if (fetchOnline)
            {
                userReq          = new GetUserRequest(user.Id);
                userReq.Success += userLoadComplete;
                API.Queue(userReq);
            }
            else
            {
                userReq = null;
                userLoadComplete(user);
            }

            sectionsContainer.ScrollToTop();
        }
Exemplo n.º 17
0
 public void SetUpSteps()
 {
     AddStep("create header", () => Child = header = new ProfileHeader());
 }
Exemplo n.º 18
0
        /// <summary>
        /// Updates the profile elements positions.
        /// </summary>
        /// <param name="profileElementId">The profile element id.</param>
        /// <param name="profileHeaderId">The profile header id.</param>
        /// <param name="orderNumber">The order number.</param>
        public static void UpdateProfileElementsPositions(long?profileElementId, long?profileHeaderId, int orderNumber)
        {
            var profileTypeService    = ServiceLocator.Current.GetInstance <IProfileTypeService>();
            var profileHeaderService  = ServiceLocator.Current.GetInstance <IProfileHeaderService>();
            var profileElementService = ServiceLocator.Current.GetInstance <IProfileElementService>();

            if (profileHeaderId != null)
            {
                ProfileHeader header = profileHeaderService.Find((long)profileHeaderId);

                if (header != null)
                {
                    header.ProfileType.ProfileHeaders.Update(
                        el =>
                    {
                        el.OrderNumber =
                            el.OrderNumber > header.OrderNumber
                                          ? el.OrderNumber - 1
                                          : el.OrderNumber;
                    }
                        );
                    header.ProfileType.ProfileHeaders.Update(
                        el =>
                    {
                        el.OrderNumber =
                            el.OrderNumber >= orderNumber
                                     ? el.OrderNumber + 1
                                     : el.OrderNumber;
                    }
                        );
                    profileTypeService.Save(header.ProfileType);
                    header.OrderNumber = orderNumber;
                    profileHeaderService.Save(header);
                }
            }
            else if (profileElementId != null)
            {
                ProfileElement element = profileElementService.Find((long)profileElementId);

                if (element != null)
                {
                    element.ProfileHeader.ProfileElements.Update(
                        el =>
                    {
                        el.OrderNumber =
                            el.OrderNumber > element.OrderNumber
                                          ? el.OrderNumber - 1
                                          : el.OrderNumber;
                    }
                        );
                    element.ProfileHeader.ProfileElements.Update(
                        el =>
                    {
                        el.OrderNumber =
                            el.OrderNumber >= orderNumber
                                     ? el.OrderNumber + 1
                                     : el.OrderNumber;
                    }
                        );
                    profileHeaderService.Save(element.ProfileHeader);
                    element.OrderNumber = orderNumber;
                    profileElementService.Save(element);
                }
            }
        }
Exemplo n.º 19
0
        public void ShowUser(User user, bool fetchOnline = true)
        {
            userReq?.Cancel();
            Clear();
            lastSection = null;

            sections = new ProfileSection[]
            {
                //new AboutSection(),
                new RecentSection(),
                new RanksSection(),
                //new MedalsSection(),
                new HistoricalSection(),
                new BeatmapsSection(),
                new KudosuSection()
            };
            tabs = new ProfileTabControl
            {
                RelativeSizeAxes = Axes.X,
                Anchor           = Anchor.TopCentre,
                Origin           = Anchor.TopCentre,
                Height           = 30
            };

            Add(new Box
            {
                RelativeSizeAxes = Axes.Both,
                Colour           = OsuColour.Gray(0.2f)
            });

            Header = new ProfileHeader(user);

            Add(sectionsContainer = new SectionsContainer <ProfileSection>
            {
                RelativeSizeAxes = Axes.Both,
                ExpandableHeader = Header,
                FixedHeader      = tabs,
                HeaderBackground = new Box
                {
                    Colour           = OsuColour.Gray(34),
                    RelativeSizeAxes = Axes.Both
                }
            });
            sectionsContainer.SelectedSection.ValueChanged += s =>
            {
                if (lastSection != s)
                {
                    lastSection        = s;
                    tabs.Current.Value = lastSection;
                }
            };

            tabs.Current.ValueChanged += s =>
            {
                if (lastSection == null)
                {
                    lastSection = sectionsContainer.Children.FirstOrDefault();
                    if (lastSection != null)
                    {
                        tabs.Current.Value = lastSection;
                    }
                    return;
                }
                if (lastSection != s)
                {
                    lastSection = s;
                    sectionsContainer.ScrollTo(lastSection);
                }
            };

            if (fetchOnline)
            {
                userReq          = new GetUserRequest(user.Id);
                userReq.Success += userLoadComplete;
                api.Queue(userReq);
            }
            else
            {
                userReq = null;
                userLoadComplete(user);
            }

            Show();
            sectionsContainer.ScrollToTop();
        }
Exemplo n.º 20
0
 public void Initialize()
 {
     Header = new ProfileHeader();
     Header.Deserialize(XElement.Parse(XmlText));
 }