Beispiel #1
0
        /// <summary>
        /// pripoji se a nacte avatary
        /// </summary>
        /// <param name="u"></param>
        public void UserLogIn(Uzivatel u)
        {
            try
            {
                GetVersion();
                Console.WriteLine("Download main.swf");
                var      responseNON = wc.DownloadString(MnfAddress.SiteSWF("main.swf?version=" + Properties.Settings.Default.Verze));
                string[] toDown      = new string[] { "highscores", "dialog_manager", "outlined_font", "bubble_manager", "chat_manager", "picture_viewer", "avatar_info", "custom_bg_manager", "friends_list", "mail_manager", "invite_manager", "item_manager", "system_message_manager", "game_settings", "login_screen", "emoticons", "petnis", "avatar" };
                foreach (var td in toDown)
                {
                    Console.WriteLine("Download " + td + ".swf");
                    responseNON = wc.DownloadString(MnfAddress.SiteSWF(td + ".swf?version=" + Properties.Settings.Default.Verze));
                }
                string s;
                //Logovani
                var data = new NameValueCollection();
                data["pass"]  = u.HesloUzivatele;
                data["email"] = u.JmenoUzivatele;
                mnfUzivatel.LoginPaswCrypted = u.HesloUzivatele;

                Console.WriteLine("Loging to game");
                var response = wc.UploadValues(MnfAddress.SiteMain() + MnfAddress.SiteLogin, "POST", data);//&errors=00&user_id=1658254&premium=0&premium_notification=0&overcrowder=0&
                s = Encoding.UTF8.GetString(response, 0, response.Length);
                if (UserParse(s))
                {
                    MessageBox.Show("Bad login\n" + s); return;
                }
                Console.WriteLine("Loging ok");
                Console.WriteLine("Download bug_report & avatar_manager_screen");
                responseNON = wc.DownloadString(MnfAddress.SiteMain("bug_report.php?email=" + u.JmenoUzivatele + "&avatar="));
                responseNON = wc.DownloadString(MnfAddress.SiteSWF("avatar_manager_screen.swf?1." + Properties.Settings.Default.Verze));
                ////Zisk Avatara
                data            = new NameValueCollection();
                data["pass"]    = u.HesloUzivatele;
                data["user_id"] = mnfUzivatel.UserID.ToString();//nebo user%5Fid

                Console.WriteLine("read avatars");
                response = wc.UploadValues(MnfAddress.SiteMain() + MnfAddress.SiteAvatar, "POST", data);
                s        = Encoding.UTF8.GetString(response, 0, response.Length);
                string[] ss = s.Split('&')[1].Split(';');
                //if (ss.Length < 5) { MessageBox.Show("bad response\n" + s); return true; }
                Avatars.Clear();
                for (int i = 0; i < ss.Length; i++)
                {
                    var a = new Avatar();
                    if (a.ParseAvatar(ss[i]))
                    {
                        MessageBox.Show("bad response\n" + ss[i]);
                    }
                    else
                    {
                        Avatars.Add(a);
                        Console.WriteLine("Avatar add " + a.JmenoPostavy);
                    }
                }
            }
            catch (Exception e) { Console.WriteLine("Nepovedlo se pripojit uzivatele " + u.JmenoUzivatele); Console.WriteLine(e); }
        }
        async Task LoadToCollection(IEnumerable <AvatarItem> avatars)
        {
            await AvatarsSemaphore.WaitAsync().ConfigureAwait(false);

            using (Avatars.UpdatesBlock()) {
                Avatars.Clear();
                Avatars.AddRange(avatars);
                TryAddCustomAvatar();
            }

            AvatarsSemaphore.Release();
        }
        public async Task ExecuteLoadStatsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                var adminManager  = new AdminManager(Settings.AccessToken);
                var avatarManager = new AvatarManager(Settings.AccessToken);
                Count = await adminManager.TotalAvatarCount();

                var avas = await avatarManager.GetStaticAvatars();

                Avatars.Clear();
                var items = await adminManager.PopularAvatars();

                foreach (var avatar in items.OrderByDescending(a => a.Count))
                {
                    var myava = avas.FirstOrDefault(a => a.Id == avatar.AvatarId);

                    if (myava == null)
                    {
                        continue;
                    }

                    Avatars.Add(new MyAvatar
                    {
                        Count    = avatar.Count.ToString(),
                        Location = myava.Location,
                        Url      = EndPoints.BaseUrl + myava.Location
                    });
                }
            }
            catch (Exception ex)
            {
                var page = new ContentPage();
                page.DisplayAlert("Error", "Unable to load.", "OK");;
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #4
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Avatars.Clear();
                await getAvatars();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Beispiel #5
0
 public static void Clear()
 {
     Avatars.Clear();
 }