Ejemplo n.º 1
0
        private void hostedListLoader_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            WebClient loader = new WebClient();

            loader.Headers.Add("User-Agent", MorebitsDotNet.UserAgent);
            try
            {
                string result = loader.DownloadString(new Uri("http://en.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=User:This,%20that%20and%20the%20other/FtCG%20local%20wiki%20data%20files.css"));
                Invoke((MethodInvoker) delegate()
                {
                    try
                    {
                        cboLocalDataHosted.Items.Clear();
                        cboLocalDataHosted.ForeColor = SystemColors.WindowText;
                        foreach (string line in result.Split('\n'))
                        {
                            string[] parts = line.Split('|');
                            if (parts.Length == 2)
                            {
                                HostedLocalWikiDataEntry item = new HostedLocalWikiDataEntry(parts[0], parts[1]);
                                cboLocalDataHosted.Items.Add(item);
                                if (Settings.LocalWikiDataHosted.StartsWith(item.displayName + "|"))
                                {
                                    cboLocalDataHosted.SelectedItem = item;
                                }
                            }
                        }
                        if (cboLocalDataHosted.Items.Count > 0 && cboLocalDataHosted.SelectedIndex == -1)
                        {
                            cboLocalDataHosted.SelectedIndex = 0;
                        }
                    }
                    catch (Exception)
                    {
                        MorebitsDotNet.DefaultErrorHandler(Localization.GetString("FailedToLoadHostedLocalWikiDataList"));
                    }
                });
            }
            catch (Exception ex)
            {
                if (!(ex is InvalidOperationException))
                {
                    MorebitsDotNet.DefaultErrorHandler(Localization.GetString("FailedToLoadHostedLocalWikiDataList"));
                }
            }
        }
Ejemplo n.º 2
0
 private void hostedListLoader_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     WebClient loader = new WebClient();
     loader.Headers.Add("User-Agent", MorebitsDotNet.UserAgent);
     try
     {
         string result = loader.DownloadString(new Uri("http://en.wikipedia.org/w/index.php?action=raw&ctype=text/css&title=User:This,%20that%20and%20the%20other/FtCG%20local%20wiki%20data%20files.css"));
         Invoke((MethodInvoker) delegate()
         {
             try
             {
                 cboLocalDataHosted.Items.Clear();
                 cboLocalDataHosted.ForeColor = SystemColors.WindowText;
                 foreach (string line in result.Split('\n'))
                 {
                     string[] parts = line.Split('|');
                     if (parts.Length == 2)
                     {
                         HostedLocalWikiDataEntry item = new HostedLocalWikiDataEntry(parts[0], parts[1]);
                         cboLocalDataHosted.Items.Add(item);
                         if (Settings.LocalWikiDataHosted.StartsWith(item.displayName + "|"))
                             cboLocalDataHosted.SelectedItem = item;
                     }
                 }
                 if (cboLocalDataHosted.Items.Count > 0 && cboLocalDataHosted.SelectedIndex == -1)
                     cboLocalDataHosted.SelectedIndex = 0;
             }
             catch (Exception)
             {
                 MorebitsDotNet.DefaultErrorHandler(Localization.GetString("FailedToLoadHostedLocalWikiDataList"));
             }
         });
     }
     catch (Exception ex)
     {
         if (!(ex is InvalidOperationException))
             MorebitsDotNet.DefaultErrorHandler(Localization.GetString("FailedToLoadHostedLocalWikiDataList"));
     }
 }