Ejemplo n.º 1
0
 private static void DownloadFile(string url, string fileName)
 {
     using (var client = new ExtendedWebClient())
     {
         client.DownloadFile(new Uri(url), fileName);
     }
 }
Ejemplo n.º 2
0
        public void TestDownloadTagsXml()
        {
            string            url      = @"https://yande.re/tag/index.xml?limit=0";
            string            filename = @"test-tag.xml";
            ExtendedWebClient client   = new ExtendedWebClient();

            client.DownloadFile(url, filename);
            Assert.IsTrue(File.Exists(filename));
        }
Ejemplo n.º 3
0
        private static Bitmap GetPokemonImage(int pokemonId)
        {
            var    Sprites  = AppDomain.CurrentDomain.BaseDirectory + "Sprites\\";
            string location = Sprites + pokemonId + ".png";

            if (!Directory.Exists(Sprites))
            {
                Directory.CreateDirectory(Sprites);
            }
            bool   err          = false;
            Bitmap bitmapRemote = null;

            if (!File.Exists(location))
            {
                try
                {
                    ExtendedWebClient wc = new ExtendedWebClient();
                    wc.DownloadFile("http://pokemon-go.ar1i.xyz/img/pokemons/" + pokemonId + ".png", @location);
                }
                catch (Exception)
                {
                    // User fail picture
                    err = true;
                }
            }
            if (err)
            {
                PictureBox picbox = new PictureBox();
                picbox.Image = PokemonGo.RocketAPI.Console.Properties.Resources.error_sprite;
                bitmapRemote = (Bitmap)picbox.Image;
            }
            else
            {
                try
                {
                    PictureBox picbox = new PictureBox();
                    FileStream m      = new FileStream(location, FileMode.Open);
                    picbox.Image = Image.FromStream(m);
                    bitmapRemote = (Bitmap)picbox.Image;
                    m.Close();
                }
                catch (Exception e)
                {
                    PictureBox picbox = new PictureBox();
                    picbox.Image = PokemonGo.RocketAPI.Console.Properties.Resources.error_sprite;
                    bitmapRemote = (Bitmap)picbox.Image;
                }
            }
            return(bitmapRemote);
        }
Ejemplo n.º 4
0
        private void GUI_Load(object sender, EventArgs e)
        {
            // Create missing Files
            Directory.CreateDirectory(Program.path);
            Directory.CreateDirectory(Program.path_translation);

            // Load Languages Files always UP2Date
            try
            {
                ExtendedWebClient client       = new ExtendedWebClient();
                string            translations = client.DownloadString("http://pokemon-go.ar1i.xyz/lang/get.php");
                string[]          transArray   = translations.Replace("\r", string.Empty).Split('\n');
                for (int ijik = 0; ijik < transArray.Count(); ijik++)
                {
                    client.DownloadFile("http://pokemon-go.ar1i.xyz/lang/" + transArray[ijik], Program.path_translation + "\\" + transArray[ijik]);
                }
            }
            catch (Exception)
            {
                List <string> b = new List <string>();
                b.Add("de.json");
                b.Add("france.json");
                b.Add("italian.json");
                b.Add("ptBR.json");
                b.Add("ru.json");
                b.Add("spain.json");
                b.Add("tr.json");

                foreach (var l in b)
                {
                    Extract("PokemonGo.RocketAPI.Console", Program.path_translation, "Lang", l);
                }
            }

            TranslationHandler.Init();

            // Version Infoooo
            groupBox9.Text = "Your Version: " + Assembly.GetExecutingAssembly().GetName().Version + " | Newest: " + Program.getNewestVersion();
            if (Program.getNewestVersion() > Assembly.GetExecutingAssembly().GetName().Version)
            {
                DialogResult dialogResult = MessageBox.Show("There is an Update on Github. do you want to open it ?", "Newest Version: " + Program.getNewestVersion(), MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    Process.Start("https://github.com/Ar1i/PokemonGo-Bot");
                }
                else if (dialogResult == DialogResult.No)
                {
                    //nothing
                }
            }

            comboBox1.DisplayMember = "Text";
            var types = new[] {
                new { Text = "Google" },
                new { Text = "Pokemon Trainer Club" },
            };

            comboBox1.DataSource = types;

            //textBox1.Hide();
            //label2.Hide();
            //textBox2.Hide();
            //label3.Hide();

            var pokeIDS   = new Dictionary <string, int>();
            var evolveIDS = new Dictionary <string, int>();
            int i         = 1;
            int ev        = 1;

            foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
            {
                if (pokemon.ToString() != "Missingno")
                {
                    pokeIDS[pokemon.ToString()] = i;
                    gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    if (checkBox8.Checked)
                    {
                        checkedListBox1.Items.Add(StringUtils.getPokemonNameGer(pokemon));
                        checkedListBox2.Items.Add(StringUtils.getPokemonNameGer(pokemon));
                        if (!(evolveBlacklist.Contains(i)))
                        {
                            checkedListBox3.Items.Add(StringUtils.getPokemonNameGer(pokemon));
                            evolveIDS[pokemon.ToString()] = ev;
                            ev++;
                        }
                    }
                    else
                    {
                        checkedListBox1.Items.Add(pokemon.ToString());
                        checkedListBox2.Items.Add(pokemon.ToString());
                        if (!(evolveBlacklist.Contains(i)))
                        {
                            checkedListBox3.Items.Add(pokemon.ToString());
                            evolveIDS[pokemon.ToString()] = ev;
                            ev++;
                        }
                    }
                    i++;
                }
            }

            if (File.Exists(Program.account))
            {
                string[] lines = File.ReadAllLines(@Program.account);
                i = 1;
                int tb = 1;
                foreach (string line in lines)
                {
                    switch (i)
                    {
                    case 1:
                        if (line == "Google")
                        {
                            comboBox1.SelectedIndex = 0;
                        }
                        else
                        {
                            comboBox1.SelectedIndex = 1;
                        }
                        break;

                    case 9:
                        checkBox1.Checked = bool.Parse(line);
                        break;

                    case 10:
                        checkBox2.Checked = bool.Parse(line);
                        break;

                    case 12:
                        checkBox3.Checked = bool.Parse(line);
                        break;

                    case 14:
                        textBox18.Text = line;
                        break;

                    case 15:
                        textBox19.Text = line;
                        break;

                    case 16:
                        textBox20.Text = line;
                        break;

                    case 17:
                        //if (line == "1")
                        //{
                        //    Globals.navigation_option = 1;
                        //    checkBox8.Checked = true;
                        //    checkBox7.Checked = false;
                        //} else
                        //{
                        //    Globals.navigation_option = 2;
                        //    checkBox7.Checked = true;
                        //    checkBox8.Checked = false;
                        //}
                        break;

                    case 18:
                        checkBox7.Checked = bool.Parse(line);
                        break;

                    case 19:
                        checkBox8.Checked = bool.Parse(line);
                        break;

                    case 20:
                        checkBox9.Checked = bool.Parse(line);
                        break;

                    case 21:
                        textBox24.Text = line;
                        break;

                    case 22:
                        checkBox10.Checked = bool.Parse(line);
                        break;

                    case 23:
                        checkBox11.Checked = bool.Parse(line);
                        break;

                    case 24:
                        checkBox12.Checked = bool.Parse(line);
                        break;

                    case 25:
                        chkAutoIncubate.Checked = bool.Parse(line);
                        chkAutoIncubate_CheckedChanged(null, EventArgs.Empty);
                        break;

                    case 26:
                        chkUseBasicIncubators.Checked = bool.Parse(line);
                        break;

                    default:
                        TextBox temp = (TextBox)Controls.Find("textBox" + tb, true).FirstOrDefault();
                        temp.Text = line;
                        tb++;
                        break;
                    }
                    i++;
                }
            }
            else
            {
                textBox3.Text  = "40,764883";
                textBox4.Text  = "-73,972967";
                textBox5.Text  = "10";
                textBox6.Text  = "50";
                textBox7.Text  = "5000";
                textBox8.Text  = "3";
                textBox9.Text  = "999";
                textBox20.Text = "5000";
            }

            if (File.Exists(Program.items))
            {
                string[] lines = File.ReadAllLines(@Program.items);
                i = 10;
                foreach (string line in lines)
                {
                    if (i == 18)
                    {
                        i = 22;
                    }
                    else if (i == 23)
                    {
                        i = 21;
                    }
                    else if (i == 22)
                    {
                        i = 23;
                    }
                    TextBox temp = (TextBox)Controls.Find("textBox" + i, true).FirstOrDefault();
                    temp.Text = line;
                    i++;
                }
            }
            else
            {
                textBox10.Text = "20";
                textBox11.Text = "50";
                textBox12.Text = "100";
                textBox13.Text = "20";
                textBox14.Text = "0";
                textBox15.Text = "0";
                textBox16.Text = "50";
                textBox17.Text = "75";
                textBox22.Text = "200";
                textBox21.Text = "100";
                textBox23.Text = "20";
                textBox24.Text = "90";
            }

            if (File.Exists(Program.keep))
            {
                string[] lines = File.ReadAllLines(@Program.keep);
                foreach (string line in lines)
                {
                    if (line != string.Empty)
                    {
                        if (checkBox8.Checked)
                        {
                            checkedListBox1.SetItemChecked(pokeIDS[gerEng[line]] - 1, true);
                        }
                        else
                        {
                            checkedListBox1.SetItemChecked(pokeIDS[line] - 1, true);
                        }
                    }
                }
            }

            if (File.Exists(Program.ignore))
            {
                string[] lines = File.ReadAllLines(@Program.ignore);
                foreach (string line in lines)
                {
                    if (line != string.Empty)
                    {
                        if (checkBox8.Checked)
                        {
                            checkedListBox2.SetItemChecked(pokeIDS[gerEng[line]] - 1, true);
                        }
                        else
                        {
                            checkedListBox2.SetItemChecked(pokeIDS[line] - 1, true);
                        }
                    }
                }
            }

            if (File.Exists(Program.lastcords))
            {
                try
                {
                    var    latlngFromFile = File.ReadAllText(Program.lastcords);
                    var    latlng = latlngFromFile.Split(':');
                    double latitude, longitude;
                    double.TryParse(latlng[0], out latitude);
                    double.TryParse(latlng[1], out longitude);
                    Globals.latitute  = latitude;
                    Globals.longitude = longitude;
                }
                catch
                {
                }
            }

            if (File.Exists(Program.evolve))
            {
                string[] lines = File.ReadAllLines(@Program.evolve);
                foreach (string line in lines)
                {
                    if (line != string.Empty)
                    {
                        if (checkBox8.Checked)
                        {
                            checkedListBox3.SetItemChecked(evolveIDS[gerEng[line]] - 1, true);
                        }
                        else
                        {
                            checkedListBox3.SetItemChecked(evolveIDS[line] - 1, true);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void GUI_Load(object sender, EventArgs e)
        {
            // Create missing Files
            Directory.CreateDirectory(Program.path);
            Directory.CreateDirectory(Program.path_translation);

            try
            {
                Extract("PokemonGo.RocketAPI.Console", AppDomain.CurrentDomain.BaseDirectory, "Resources", "encrypt.dll"); // unpack our encrypt dll
            } catch (Exception)
            {

            }

            // Load Languages Files always UP2Date
            try
            {
                ExtendedWebClient client = new ExtendedWebClient();
                string translations = client.DownloadString("http://pokemon-go.ar1i.xyz/lang/get.php");
                string[] transArray = translations.Replace("\r", string.Empty).Split('\n');
                for (int ijik = 0; ijik < transArray.Count(); ijik++)
                {
                    client.DownloadFile("http://pokemon-go.ar1i.xyz/lang/" + transArray[ijik], Program.path_translation + "\\" + transArray[ijik]);
                }
            }
            catch (Exception)
            {
                List<string> b = new List<string>();
                b.Add("de.json");
                b.Add("france.json");
                b.Add("italian.json");
                b.Add("ptBR.json");
                b.Add("ru.json");
                b.Add("spain.json");
                b.Add("tr.json");

                foreach (var l in b)
                {
                    Extract("PokemonGo.RocketAPI.Console", Program.path_translation, "Lang", l);
                }
            }

            TranslationHandler.Init();

            // Version Infoooo
            groupBox9.Text = "Your Version: " + Assembly.GetExecutingAssembly().GetName().Version + " | Newest: " + Program.getNewestVersion();
            if (Program.getNewestVersion() > Assembly.GetExecutingAssembly().GetName().Version)
            {
                DialogResult dialogResult = MessageBox.Show("There is an Update on Github. do you want to open it ?", "Newest Version: " + Program.getNewestVersion(), MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    Process.Start("https://github.com/Ar1i/PokemonGo-Bot");
                }
                else if (dialogResult == DialogResult.No)
                {
                    //nothing
                }
            }

            comboBox1.DisplayMember = "Text";
            var types = new[] {
                new { Text = "Google"},
                new { Text = "Pokemon Trainer Club"},
            };
            comboBox1.DataSource = types;

            //textBox1.Hide();
            //label2.Hide();
            //textBox2.Hide();
            //label3.Hide();

            var pokeIDS = new Dictionary<string, int>();
            var evolveIDS = new Dictionary<string, int>();
            int i = 1;
            int ev = 1;
            foreach (PokemonId pokemon in Enum.GetValues(typeof(PokemonId)))
            {
                if (pokemon.ToString() != "Missingno")
                {
                    pokeIDS[pokemon.ToString()] = i;
                    gerEng[StringUtils.getPokemonNameGer(pokemon)] = pokemon.ToString();
                    if (checkBox8.Checked)
                    {
                        checkedListBox1.Items.Add(StringUtils.getPokemonNameGer(pokemon));
                        checkedListBox2.Items.Add(StringUtils.getPokemonNameGer(pokemon));
                        if (!(evolveBlacklist.Contains(i)))
                        {
                            checkedListBox3.Items.Add(StringUtils.getPokemonNameGer(pokemon));
                            evolveIDS[pokemon.ToString()] = ev;
                            ev++;
                        }
                    }
                    else
                    {
                        checkedListBox1.Items.Add(pokemon.ToString());
                        checkedListBox2.Items.Add(pokemon.ToString());
                        if (!(evolveBlacklist.Contains(i)))
                        {
                            checkedListBox3.Items.Add(pokemon.ToString());
                            evolveIDS[pokemon.ToString()] = ev;
                            ev++;
                        }
                    }
                    i++;
                }
            }

            if (File.Exists(Program.account))
            {
                string[] lines = File.ReadAllLines(@Program.account);
                i = 1;
                int tb = 1;
                foreach (string line in lines)
                {
                    switch (i)
                    {
                        case 1:
                            if (line == "Google")
                                comboBox1.SelectedIndex = 0;
                            else
                                comboBox1.SelectedIndex = 1;
                            break;
                        case 9:
                            checkBox1.Checked = bool.Parse(line);
                            break;
                        case 10:
                            checkBox2.Checked = bool.Parse(line);
                            break;
                        case 12:
                            checkBox3.Checked = bool.Parse(line);
                            break;
                        case 14:
                            textBox18.Text = line;
                            break;
                        case 15:
                            textBox19.Text = line;
                            break;
                        case 16:
                            textBox20.Text = line;
                            break;
                        case 17:
                            //if (line == "1")
                            //{
                            //    Globals.navigation_option = 1;
                            //    checkBox8.Checked = true;
                            //    checkBox7.Checked = false;
                            //} else
                            //{
                            //    Globals.navigation_option = 2;
                            //    checkBox7.Checked = true;
                            //    checkBox8.Checked = false;
                            //}
                            break;
                        case 18:
                            checkBox7.Checked = bool.Parse(line);
                            break;
                        case 19:
                            checkBox8.Checked = bool.Parse(line);
                            break;
                        case 20:
                            checkBox9.Checked = bool.Parse(line);
                            break;
                        case 21:
                            textBox24.Text = line;
                            break;
                        case 22:
                            checkBox10.Checked = bool.Parse(line);
                            break;
                        case 23:
                            checkBox11.Checked = bool.Parse(line);
                            break;
                        case 24:
                            checkBox12.Checked = bool.Parse(line);
                            break;
                        case 25:
                            chkAutoIncubate.Checked = bool.Parse(line);
                            chkAutoIncubate_CheckedChanged(null, EventArgs.Empty);
                            break;
                        case 26:
                            chkUseBasicIncubators.Checked = bool.Parse(line);
                            break;
                        default:
                            TextBox temp = (TextBox)Controls.Find("textBox" + tb, true).FirstOrDefault();
                            temp.Text = line;
                            tb++;
                            break;
                    }
                    i++;
                }
            }
            else
            {
                textBox3.Text = "40,764883";
                textBox4.Text = "-73,972967";
                textBox5.Text = "10";
                textBox6.Text = "50";
                textBox7.Text = "5000";
                textBox8.Text = "3";
                textBox9.Text = "999";
                textBox20.Text = "5000";
            }

            if (File.Exists(Program.items))
            {
                string[] lines = File.ReadAllLines(@Program.items);
                i = 10;
                foreach (string line in lines)
                {
                    if (i == 18)
                    {
                        i = 22;
                    }
                    else if (i == 23)
                    {
                        i = 21;
                    }
                    else if (i == 22)
                    {
                        i = 23;
                    }
                    TextBox temp = (TextBox)Controls.Find("textBox" + i, true).FirstOrDefault();
                    temp.Text = line;
                    i++;
                }
            }
            else
            {
                textBox10.Text = "20";
                textBox11.Text = "50";
                textBox12.Text = "100";
                textBox13.Text = "20";
                textBox14.Text = "0";
                textBox15.Text = "0";
                textBox16.Text = "50";
                textBox17.Text = "75";
                textBox22.Text = "200";
                textBox21.Text = "100";
                textBox23.Text = "20";
                textBox24.Text = "90";
            }

            if (File.Exists(Program.keep))
            {
                string[] lines = File.ReadAllLines(@Program.keep);
                foreach (string line in lines)
                {
                    if (line != string.Empty)
                        if (checkBox8.Checked)
                            checkedListBox1.SetItemChecked(pokeIDS[gerEng[line]] - 1, true);
                        else
                            checkedListBox1.SetItemChecked(pokeIDS[line] - 1, true);
                }
            }

            if (File.Exists(Program.ignore))
            {
                string[] lines = File.ReadAllLines(@Program.ignore);
                foreach (string line in lines)
                {
                    if (line != string.Empty)
                        if (checkBox8.Checked)
                            checkedListBox2.SetItemChecked(pokeIDS[gerEng[line]] - 1, true);
                        else
                            checkedListBox2.SetItemChecked(pokeIDS[line] - 1, true);
                }
            }

            if (File.Exists(Program.lastcords))
            {
                try
                {
                    var latlngFromFile = File.ReadAllText(Program.lastcords);
                    var latlng = latlngFromFile.Split(':');
                    double latitude, longitude;
                    double.TryParse(latlng[0], out latitude);
                    double.TryParse(latlng[1], out longitude);
                    Globals.latitute = latitude;
                    Globals.longitude = longitude;
                }
                catch
                {

                }
            }

            if (File.Exists(Program.evolve))
            {
                string[] lines = File.ReadAllLines(@Program.evolve);
                foreach (string line in lines)
                {
                    if (line != string.Empty)
                        if (checkBox8.Checked)
                            checkedListBox3.SetItemChecked(evolveIDS[gerEng[line]] - 1, true);
                        else
                            checkedListBox3.SetItemChecked(evolveIDS[line] - 1, true);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Redownload files with given relative filenames.
        /// </summary>
        /// <returns>RunWorkerCompletedEventArgs. True if the download is succeeded, otherwise false.</returns>
        public static RunWorkerCompletedEventArgs RedownloadFile(ExtendedWebClient _webClient, string relativeFilename, string destinationFullfilename, Func <int, bool> progress_callback)
        {
            bool      continueDownload = true;
            Exception Myex             = null;
            Uri       currenturl       = null;
            DownloadProgressChangedEventHandler ooooo = null;

            if (progress_callback != null)
            {
                ooooo = new DownloadProgressChangedEventHandler(delegate(object sender, DownloadProgressChangedEventArgs e)
                {
                    if (progress_callback.Invoke(e.ProgressPercentage))
                    {
                        continueDownload = false;
                        _webClient.CancelAsync();
                    }
                });
            }
            if (ooooo != null)
            {
                _webClient.DownloadProgressChanged += ooooo;
            }
            try
            {
                HttpStatusCode lastCode;
                var            _pso22fileurl = new PSO2FileUrl(Leayal.UriHelper.URLConcat(DefaultValues.Web.MainDownloadLink, relativeFilename), Leayal.UriHelper.URLConcat(DefaultValues.Web.OldDownloadLink, relativeFilename));
                currenturl = _pso22fileurl.MainUrl;
                lastCode   = HttpStatusCode.ServiceUnavailable;
                try
                {
                    _webClient.AutoUserAgent = true;
                    _webClient.DownloadFile(currenturl, destinationFullfilename);
                    _webClient.AutoUserAgent = false;
                }
                catch (WebException webEx)
                {
                    if (webEx.Response != null)
                    {
                        HttpWebResponse rep = webEx.Response as HttpWebResponse;
                        lastCode = rep.StatusCode;
                    }
                    else
                    {
                        throw webEx;
                    }
                }
                if (lastCode == HttpStatusCode.NotFound)
                {
                    currenturl = _pso22fileurl.GetTheOtherOne(currenturl.OriginalString);
                    try
                    {
                        _webClient.AutoUserAgent = true;
                        _webClient.DownloadFile(currenturl, destinationFullfilename);
                        _webClient.AutoUserAgent = false;
                    }
                    catch (WebException webEx)
                    {
                        if (webEx.Response != null)
                        {
                            HttpWebResponse rep = webEx.Response as HttpWebResponse;
                            if (rep.StatusCode != HttpStatusCode.NotFound)
                            {
                                throw webEx;
                            }
                        }
                        else
                        {
                            throw webEx;
                        }
                    }
                }
            }
            catch (Exception ex) { Myex = ex; }
            if (ooooo != null)
            {
                _webClient.DownloadProgressChanged -= ooooo;
            }
            return(new RunWorkerCompletedEventArgs(null, Myex, !continueDownload));
        }
Ejemplo n.º 7
0
 private static Bitmap GetPokemonImage(int pokemonId)
 {
     var Sprites = AppDomain.CurrentDomain.BaseDirectory + "Sprites\\";
     string location = Sprites + pokemonId + ".png";
     if (!Directory.Exists(Sprites))
         Directory.CreateDirectory(Sprites);
     bool err = false;
     Bitmap bitmapRemote = null;
     if (!File.Exists(location))
     {
         try {
             ExtendedWebClient wc = new ExtendedWebClient();
             wc.DownloadFile("http://pokemon-go.ar1i.xyz/img/pokemons/" + pokemonId + ".png", @location);
         } catch (Exception)
         {
             // User fail picture
             err = true;
         }
     }
     if (err)
     {
         PictureBox picbox = new PictureBox();
         picbox.Image = PokemonGo.RocketAPI.Console.Properties.Resources.error_sprite;
         bitmapRemote = (Bitmap)picbox.Image;
     }
     else
     {
         try
         {
             PictureBox picbox = new PictureBox();
             FileStream m = new FileStream(location, FileMode.Open);
             picbox.Image = Image.FromStream(m);
             bitmapRemote = (Bitmap)picbox.Image;
             m.Close();
         } catch (Exception e)
         { 
             PictureBox picbox = new PictureBox();
             picbox.Image = PokemonGo.RocketAPI.Console.Properties.Resources.error_sprite;
             bitmapRemote = (Bitmap)picbox.Image;
         }
     }
     return bitmapRemote;
 }