Esempio n. 1
0
 private void downloaded_html(object sender, DownloadStringCompletedEventArgs e)
 {
     try
     {
         this.fAdventures = new List <PremadeForm.Adventure>();
         string lower = e.Result.ToLower();
         int    num   = 0;
         while (true)
         {
             int num1 = lower.IndexOf("<tr>", num);
             if (num1 == -1)
             {
                 break;
             }
             int length = lower.IndexOf("</tr>", num1);
             if (length == -1)
             {
                 break;
             }
             length += "</tr>".Length;
             string str = e.Result.Substring(num1, length - num1);
             num = length;
             PremadeForm.Adventure _adventure = this.get_adventure(str);
             if (_adventure != null)
             {
                 this.fAdventures.Add(_adventure);
             }
         }
     }
     catch
     {
     }
     this.update_list();
 }
Esempio n. 2
0
        private void start_download(PremadeForm.Adventure adv, string filename)
        {
            this.fProgressScreen = new ProgressScreen("Downloading Adventure...", 100)
            {
                CurrentSubAction = adv.Name
            };
            this.fProgressScreen.Show();
            WebClient webClient = new WebClient();

            webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(this.progress_changed);
            webClient.DownloadFileCompleted   += new AsyncCompletedEventHandler(this.download_completed);
            webClient.DownloadFileAsync(new Uri(adv.URL), filename);
            this.fDownloadedFileName = filename;
        }
Esempio n. 3
0
        private void get_file_name(PremadeForm.Adventure adv)
        {
            string str = FileName.Name(adv.Name);

            str = string.Concat(FileName.TrimInvalidCharacters(str), ".masterplan");
            SaveFileDialog saveFileDialog = new SaveFileDialog()
            {
                Filter   = Program.ProjectFilter,
                FileName = str
            };

            if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this.start_download(adv, saveFileDialog.FileName);
            }
        }
Esempio n. 4
0
 private PremadeForm.Adventure get_adventure(string html)
 {
     PremadeForm.Adventure adventure;
     try
     {
         XmlDocument xmlDocument = new XmlDocument();
         xmlDocument.LoadXml(html);
         XmlNode documentElement = xmlDocument.DocumentElement;
         if (documentElement != null)
         {
             PremadeForm.Adventure innerText = new PremadeForm.Adventure();
             XmlNode firstChild = documentElement.FirstChild;
             innerText.Name = firstChild.InnerText;
             innerText.URL  = XMLHelper.GetAttribute(firstChild.FirstChild, "href");
             innerText.URL  = string.Concat("http://www.habitualindolence.net/masterplan/", innerText.URL);
             XmlNode nextSibling = firstChild.NextSibling;
             string  str         = nextSibling.InnerText.Replace("Level", "");
             str = str.Replace("level", "");
             str = str.Replace(" ", "");
             innerText.PartyLevel = int.Parse(str);
             string str1 = nextSibling.NextSibling.InnerText.Replace("PCs", "");
             str1 = str1.Replace("pcs", "");
             str1 = str1.Replace("heroes", "");
             str1 = str1.Replace(" ", "");
             innerText.PartySize = int.Parse(str1);
             adventure           = innerText;
         }
         else
         {
             adventure = null;
         }
     }
     catch
     {
         return(null);
     }
     return(adventure);
 }