Exemplo n.º 1
0
        public void work_dowork(object sender, DoWorkEventArgs e)
        {
            bool _Iserror      = false;
            int  counterReload = 0;
            int  checkcounter  = 0;

            do
            {
                try
                {
                    counterReload++;
                    _Work1doc.LoadHtml(_Client1.DownloadString(Url1));
                    _Iserror = false;
                    Application.DoEvents();
                }
                catch
                {
                    _Iserror = true;
                }
            } while (counterReload < 25 && _Iserror);
            if (_Iserror)
            {
                WriteLogEvent(Url1, "issue accured in loading Given URL is not found");
            }
            if (_IsCategory && !_Iserror)
            {
                try
                {
                    GetCategoryInfo(_Work1doc, Url1, Category1);
                }
                catch
                { WriteLogEvent(Url1, "Issue accured in reading produts from category page"); }

                /**********Report progress**************/
                gridindex++;
                _Work.ReportProgress((gridindex * 100 / CategoryUrl.Count));

                /****************end*******************/
            }
            else if (_IsProduct && !_Iserror)
            {
                try
                {
                    GetProductInfo(_Work1doc, Url1, Category1);
                }
                catch
                { WriteLogEvent(Url1, "Issue accured in reading product Info."); }

                /**********Report progress**************/
                gridindex++;
                _Work.ReportProgress((gridindex * 100 / allCategoryUrl.Count));

                /****************end*******************/
            }
        }
Exemplo n.º 2
0
        // GET: Rooms/SyncNewRooms
        public void SyncNewRooms(string followedRoomId = "None")
        {
            try
            {
                string user = AppHelper.GetVmtUser();
                // make HTML request
                var client = new ExtendedWebClient();
                client.Encoding = System.Text.Encoding.UTF8;
                string roomsData = client.DownloadString(VmtDevAPI.VMT_URL + "/rooms/");

                // sync rooms (if followedRoomId is not 'None', then user is not a moderator)
                List <Room> newRooms;
                if (followedRoomId == "None")
                {
                    newRooms = SyncUserRooms(user.ToLower(), roomsData);
                }
                else
                {
                    newRooms = followNewRoom(user.ToLower(), followedRoomId, roomsData);
                }

                foreach (Room room in newRooms)
                {
                    VmtDevAPI.RegisterLiveChat(room.ID);
                    VmtDevAPI.RegisterLiveActions(room.ID);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the newest available programme version.
        /// </summary>
        /// <returns>The newest available programme version,
        /// or 69.69.69.69 if now information could be retrieved.</returns>
        private Version GetNewProgrammeVersion(out string p_strDownloadUri)
        {
            ExtendedWebClient wclNewVersion = new ExtendedWebClient(15000);
            Version           verNew        = new Version("69.69.69.69");

            p_strDownloadUri = String.Empty;

            try
            {
                string strNewVersion = wclNewVersion.DownloadString(NexusLinks.LatestVersion);
                if (!String.IsNullOrEmpty(strNewVersion))
                {
                    verNew           = new Version(strNewVersion.Split('|')[0]);
                    p_strDownloadUri = strNewVersion.Split('|')[1];
                }
            }
            catch (WebException)
            {
                try
                {
                    string strNewVersion = wclNewVersion.DownloadString(NexusLinks.LatestVersion4dot5);
                    if (!String.IsNullOrEmpty(strNewVersion))
                    {
                        verNew           = new Version(strNewVersion.Split('|')[0]);
                        p_strDownloadUri = strNewVersion.Split('|')[1];
                    }
                }
                catch (WebException e)
                {
                    Trace.TraceError(String.Format("Could not connect to update server: {0}", e.Message));
                }
                catch (ArgumentException e)
                {
                    Trace.TraceError(String.Format("Unexpected response from the server: {0}", e.Message));
                }
            }
            catch (ArgumentException e)
            {
                Trace.TraceError(String.Format("Unexpected response from the server: {0}", e.Message));
            }

            return(verNew);
        }
Exemplo n.º 4
0
        public MinerResponse GetData(Miner miner)
        {
            var result = new MinerResponse();

            using (var client = new ExtendedWebClient())
            {
                client.Timeout = TimeOut;

                if (Proxy != null)
                {
                    WebRequest.DefaultWebProxy = Proxy;
                    client.Proxy = Proxy;
                }

                if (miner.Credentials != null)
                {
                    client.Credentials = miner.Credentials;

                    try
                    {
                        client.OpenRead(miner.Uri);
                    }
                    catch (Exception e)
                    {
                        result.Error = new WebError(DateTime.Now, e.Message);
                    }
                }

                try
                {
                    var response = client.DownloadString(miner.Uri);

                    if (response != null)
                    {
                        result.Data   = JsonConvert.DeserializeObject <MinerData>(response);
                        result.Status = true;
                    }
                }
                catch (Exception e)
                {
                    result.Error = new WebError(DateTime.Now, e.Message);
                }
            }

            return(result);
        }
Exemplo n.º 5
0
        public IReadOnlyCollection <BricklinkStore> GetStoresByCountry(string countryCode)
        {
            string html;

            using (var client = new ExtendedWebClient())
            {
                client.UserAgent = Constants.UserAgent;
                var url = string.Format(
                    "https://www.bricklink.com/browseStores.asp?countryID={0}",
                    HttpUtility.UrlEncode(countryCode));

                html = client.DownloadString(url);
            }

            var stores = ParseStoreList(html);

            return(stores);
        }
Exemplo n.º 6
0
        void GetVideoFeedUrl(ChatRoomModel parameter)
        {
            if (parameter == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(parameter.VideoFeedUrl))
            {
                const string VIDEO_URL_START = "initHlsPlayer(jsplayer, '";
                const string VIDEO_URL_END   = "');";

                using (var webClient = new ExtendedWebClient())
                {
                    string html;
                    try
                    {
                        html = webClient.DownloadString(new Uri(parameter.ProfileUrl, UriKind.Absolute));
                    }
                    catch (WebException)
                    {
                        return;
                    }

                    if (string.IsNullOrEmpty(html))
                    {
                        return;
                    }

                    var start = html.IndexOf(VIDEO_URL_START);
                    if (start > -1)
                    {
                        var end = html.IndexOf(VIDEO_URL_END, start + VIDEO_URL_START.Length);
                        var url = html.Substring(start + VIDEO_URL_START.Length, end - start - VIDEO_URL_START.Length);
                        parameter.VideoFeedUrl = url;
                        SelectedRoom           = parameter;
                    }
                }
            }
            else
            {
                SelectedRoom = parameter;
            }
        }
Exemplo n.º 7
0
 HtmlNode Load(ref ExtendedWebClient client, ref HtmlDocument parser, Uri uri)
 {
     try
     {
         var html = client.DownloadString(uri);
         parser.LoadHtml(html);
         return(parser.DocumentNode);
     }
     catch (WebException)
     {
         Status = SearchStatus.Failed;
         return(null);
     }
     catch (Exception)
     {
         Status = SearchStatus.Failed;
         return(null);
     }
 }
        public IReadOnlyCollection <BricklinkItemAvailability> GetAvailability(string itemTypeCode, string itemId,
                                                                               int colorId)
        {
            var url = string.Format(
                "https://www.bricklink.com/catalogPG.asp?{0}={1}&colorID={2}",
                HttpUtility.UrlEncode(itemTypeCode),
                HttpUtility.UrlEncode(itemId),
                colorId);

            string html;

            using (var client = new ExtendedWebClient())
            {
                client.UserAgent = Constants.UserAgent;

                html = client.DownloadString(url);
            }

            var result = ParseAvailabilityPage(html);

            return(result);
        }
            private bool GetReleaseInformation(out string data)
            {
                data = "";
                bool ret = false;

                using (ExtendedWebClient wclNewVersion = new ExtendedWebClient(15000))
                {
                    try
                    {
                        data = wclNewVersion.DownloadString(NexusLinks.LatestVersion);
                        ret  = true;
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine("GithubReleaseParser::GetReleaseInformation:: error - {0}", e.Message);
                        Console.Error.WriteLine(e.ToString());
                        data = "";
                        ret  = false;
                    }
                }

                return(ret);
            }
		/// <summary>
		/// Gets the newest available programme version.
		/// </summary>
		/// <returns>The newest available programme version,
		/// or 69.69.69.69 if now information could be retrieved.</returns>
		private Version GetNewProgrammeVersion(out string p_strDownloadUri)
		{
			ExtendedWebClient wclNewVersion = new ExtendedWebClient(15000);
			Version verNew = new Version("69.69.69.69");
			p_strDownloadUri = String.Empty;

			try
			{
				string strNewVersion = wclNewVersion.DownloadString("http://nmm.nexusmods.com/NMM?GetLatestVersion");
				if (!String.IsNullOrEmpty(strNewVersion))
				{
					verNew = new Version(strNewVersion.Split('|')[0]);
					p_strDownloadUri = strNewVersion.Split('|')[1];
				}
			}
			catch (WebException)
			{
				try
				{
					string strNewVersion = wclNewVersion.DownloadString("http://dev.nexusmods.com/client/4.5/latestversion.php");
					if (!String.IsNullOrEmpty(strNewVersion))
					{
						verNew = new Version(strNewVersion.Split('|')[0]);
						p_strDownloadUri = strNewVersion.Split('|')[1];
					}
				}
				catch (WebException e)
				{
					Trace.TraceError(String.Format("Could not connect to update server: {0}", e.Message));
				}
				catch (ArgumentException e)
				{
					Trace.TraceError(String.Format("Unexpected response from the server: {0}", e.Message));
				}
			}
			catch (ArgumentException e)
			{
				Trace.TraceError(String.Format("Unexpected response from the server: {0}", e.Message));
			}

			return verNew;
		}
Exemplo n.º 11
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);
                        }
                    }
                }
            }
        }
Exemplo n.º 12
0
        public void work_dowork1(object sender, DoWorkEventArgs e)
        {
            bool _Iserror      = false;
            int  checkcounter  = 0;
            int  counterReload = 0;

            if (_IsProduct)
            {
                do
                {
                    try
                    {
                        counterReload++;
                        _Work1doc2.LoadHtml(_Client2.DownloadString(Url2));
                        _Iserror = false;
                        Application.DoEvents();
                    }
                    catch
                    {
                        _Iserror = true;
                    }
                } while (counterReload < 25 && _Iserror);
            }
            else
            {
                do
                {
                    try
                    {
                        counterReload++;
                        _Worker2.GoTo(Url2);
                        _Iserror = false;
                        _Worker2.WaitForComplete();
                        if (_Worker2.Html == null || !_Worker2.Html.ToLower().Contains("class=\"nxt-product-list\""))
                        {
                            do
                            {
                                System.Threading.Thread.Sleep(20);
                                Application.DoEvents();
                                checkcounter++;
                            } while ((_Worker2.Html == null || !_Worker2.Html.ToLower().Contains("class=\"nxt-product-list\"")) && checkcounter < 10000);
                        }
                        _Work1doc2.LoadHtml(_Worker2.Html);
                        Application.DoEvents();
                    }
                    catch
                    {
                        _Iserror = true;
                    }
                } while (counterReload < 25 && _Iserror);
            }
            if (_Iserror)
            {
                WriteLogEvent(Url2, "issue accured in loading Given URL is not found");
            }
            if (_IsCategory && !_Iserror)
            {
                try
                {
                    GetCategoryInfo(_Work1doc2, Url2);
                }
                catch
                { WriteLogEvent(Url2, "Issue accured in reading produts from category page"); }
                gridindex++;
                _Work1.ReportProgress((gridindex * 100 / CategoryUrl.Count));
            }
            else if (_IsProduct && !_Iserror)
            {
                try
                {
                    GetProductInfo(_Work1doc2, Url2);
                }
                catch
                { WriteLogEvent(Url2, "Issue accured in reading product Info."); }
                gridindex++;
                _Work1.ReportProgress((gridindex * 100 / Producturl.Count));
            }
        }
Exemplo n.º 13
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);
                }
            }
        }
Exemplo n.º 14
0
        IList <ChatRoomModel> GetChatRooms(NavigationDirection parameter)
        {
            var chatRooms = new List <ChatRoomModel>();

            switch (parameter)
            {
            case NavigationDirection.Forward:
                Page += 1;
                break;

            case NavigationDirection.Backward:
                if (Page > 1)
                {
                    Page -= 1;
                }
                break;

            case NavigationDirection.Refresh:
            default:
                if (Page == 0)
                {
                    Page = 1;
                }
                break;
            }

            var url = string.Format("{0}/?page={1}", CHATURBATE, Page);

            switch (RoomsGender)
            {
            case Gender.Male:
                url = string.Format("{0}/male-cams/?page={1}", CHATURBATE, Page);
                break;

            case Gender.Female:
                url = string.Format("{0}/female-cams/?page={1}", CHATURBATE, Page);
                break;

            case Gender.Couple:
                url = string.Format("{0}/couple-cams/?page={1}", CHATURBATE, Page);
                break;

            case Gender.Trans:
                url = string.Format("{0}/trans-cams/?page={1}", CHATURBATE, Page);
                break;
            }

            string html;

            using (var client = new ExtendedWebClient())
            {
                client.Host = HOST;
                try
                {
                    html = client.DownloadString(new Uri(url, UriKind.Absolute));
                }
                catch (WebException)
                {
                    return(chatRooms);
                }
            }

            var parser = new HtmlDocument();

            parser.LoadHtml(html);

            HtmlNode tempNode;

            foreach (var node in parser.DocumentNode.SelectNodes("//ul[@class='list']/li"))
            {
                tempNode = node.SelectSingleNode("./a/img[@class='png']");
                var profileImageUrl    = tempNode.Attributes["src"].Value;
                var profileImageHeight = int.Parse(tempNode.Attributes["height"].Value);
                var profileImageWidth  = int.Parse(tempNode.Attributes["width"].Value);

                tempNode = node.SelectSingleNode("./div[contains(@class,'thumbnail_label')]");
                var isVideoFeedHd = tempNode.InnerText.Equals("HD", StringComparison.InvariantCultureIgnoreCase);

                tempNode = node.SelectSingleNode("./div/ul[@class='subject']/li");
                var title = tempNode.Attributes["title"].Value;

                tempNode = node.SelectSingleNode("./div[@class='details']/div[@class='title']/a");
                var name       = tempNode.InnerText.Trim();
                var profileUrl = string.Format("{0}{1}", CHATURBATE, tempNode.Attributes["href"].Value);

                tempNode = node.SelectSingleNode("./div[@class='details']/div[@class='title']/span[contains(@class,'age')]");
                int.TryParse(tempNode.InnerText, out int age);
                var    genderString = tempNode.Attributes["class"].Value;
                Gender gender;
                if (genderString.Contains("genderm"))
                {
                    gender = Gender.Male;
                }
                else if (genderString.Contains("genderf"))
                {
                    gender = Gender.Female;
                }
                else if (genderString.Contains("genderc"))
                {
                    gender = Gender.Couple;
                }
                else
                {
                    gender = Gender.Trans;
                }

                tempNode = node.SelectSingleNode("./div[@class='details']/ul[@class='sub-info']/li[@class='cams']");
                var cams = tempNode.InnerText;

                var chatRoom = new ChatRoomModel(name, age, gender, title, profileUrl, profileImageUrl, profileImageHeight, profileImageWidth);
                chatRoom.IsVideoFeedHd = isVideoFeedHd;
                chatRoom.CamsCount     = cams;
                chatRooms.Add(chatRoom);
            }

            return(chatRooms);
        }