Esempio n. 1
0
        private async void Pivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((pivot.SelectedItem as PivotItem) == Invites && !LoadingInvites)
            {
                InviteView.Items.Clear();
                NoInvites.Opacity     = 0;
                LoadingInvite.Opacity = 1;
                LoadingInvites        = true;
                IEnumerable <Invite> invites = null;
                await Task.Run(async() =>
                {
                    invites = await RESTCalls.GetChannelInvites(guildId);
                });

                if (invites != null)
                {
                    foreach (var invite in invites)
                    {
                        InviteView.Items.Add(invite);
                    }
                    LoadingInvite.Fade(0, 200).Start();
                }
                if (InviteView.Items.Count == 0)
                {
                    NoInvites.Fade(0.2f, 200).Start();
                    LoadingInvite.Fade(0, 200).Start();
                }
            }
            else if ((pivot.SelectedItem as PivotItem) == Bans && !loadingBans)
            {
                BanView.Items.Clear();
                NoBans.Opacity      = 0;
                LoadingBans.Opacity = 1;
                loadingBans         = true;
                IEnumerable <Ban> bans = null;
                await Task.Run(async() =>
                {
                    bans = await RESTCalls.GetGuildBans(guildId);
                });

                if (bans != null)
                {
                    foreach (var ban in bans)
                    {
                        ban.GuildId = guildId;
                        BanView.Items.Add(ban);
                    }
                    LoadingBans.Fade(0, 200).Start();
                }
                if (BanView.Items.Count == 0)
                {
                    NoBans.Fade(0.2f, 200).Start();
                    LoadingBans.Fade(0, 200).Start();
                }
            }
        }
Esempio n. 2
0
 private async void BanAdded(object sender, GatewayEventArgs <GuildBanUpdate> e)
 {
     if (e.EventData.GuildId == guildId)
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                   () =>
         {
             if (BanView.Items.Count == 0)
             {
                 NoBans.Fade(0.0f, 200).Start();
             }
             BanView.Items.Insert(0, new Ban()
             {
                 User = e.EventData.User, Reason = e.EventData.Reason, GuildId = guildId
             });
         });
     }
 }
Esempio n. 3
0
 private async void BanRemoved(object sender, GatewayEventArgs <GuildBanUpdate> e)
 {
     if (e.EventData.GuildId == guildId)
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                   () =>
         {
             for (int x = 0; x < BanView.Items.Count; x++)
             {
                 if ((BanView.Items[x] as Ban).User.Id == e.EventData.User.Id)
                 {
                     BanView.Items.RemoveAt(x);
                 }
             }
             if (BanView.Items.Count == 0)
             {
                 NoBans.Fade(0.2f, 200).Start();
             }
         });
     }
 }