Exemplo n.º 1
0
        //Осуществляет вывод информации, при смене выбранной страны в ListBoxe-e
        private async void SelectedItem(object sender, EventArgs e)
        {
            label10.Text = listBox1.SelectedIndex.ToString();
            int index1 = Convert.ToInt32(label10.Text);

            List <Country> countries = await RESTCountriesAPI.GetAllCountriesAsync();

            ListBox.ObjectCollection collection = new ListBox.ObjectCollection(listBox1);


            foreach (Country country in countries)
            {
                label1.Text = collection.Count.ToString();
                collection.Add(country);
                //listBox1.DisplayMember = "Name";
                label1.Text = collection.Count.ToString();

                if (collection.IndexOf(country) == index1)
                {
                    Strana.Text    = country.Name; stran = Strana.Text;
                    KodStrani.Text = country.Alpha2Code;
                    Stolica.Text   = country.Capital;
                    try
                    {
                        double plosh    = (double)country.Area;
                        string newplosh = plosh.ToString("#,#", CultureInfo.InvariantCulture);
                        Ploshad.Text = String.Format(CultureInfo.InvariantCulture, "{0:#,#}", newplosh + " км. кв.");
                    }
                    catch (Exception)
                    {
                        Ploshad.Text = String.Format(CultureInfo.InvariantCulture, "Площадь не известна!");
                    }
                    int    Nasel    = (int)country.Population;
                    string newNasel = Nasel.ToString("#,#", CultureInfo.InvariantCulture);
                    Naselenie.Text = String.Format(CultureInfo.InvariantCulture, "{0:#,#}", newNasel + " человек");

                    RegionStrani.Text = country.Region;
                }
            }
            listBox1.Items.Clear(); listBox1.Update();
            foreach (Country country in countries)
            {
                label1.Text = (collection.Count).ToString();
                listBox1.Items.Add(country);
            }
            listBox1.SetSelected(index1, true);
        }
Exemplo n.º 2
0
        private static void analysisWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string argument  = (string)((object[])e.Argument)[0];
            bool   flag      = (bool)((object[])e.Argument)[1];
            string argument1 = (string)((object[])e.Argument)[2];
            string str1      = (string)((object[])e.Argument)[3];
            string argument2 = (string)((object[])e.Argument)[4];

            ListBox.ObjectCollection objectCollections = (ListBox.ObjectCollection)((object[])e.Argument)[5];
            bool[] flagArray = (bool[])((object[])e.Argument)[6];
            AnalysisClass.analysisWorker.ReportProgress(0, new Report((object x) => {
                AnalysisClass.mainForm.pbAnalysis.Value = 0;
                AnalysisClass.mainForm.lblCurrentAnalysisFileName.Text = string.Empty;
                AnalysisClass.mainForm.lblAnalysisProgress.Text        = "0/0";
                LogClass.AppendLine(string.Concat("批量解析Start于", DateTime.Now.ToString()), true);
            }, null));
            if (!Directory.Exists(argument1))
            {
                throw new Exception(string.Concat("Export folder\"", argument1, "\"does not exist,Please re-set the correct folder."));
            }
            string str2 = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "umodel.exe");

            if (!File.Exists(str2))
            {
                throw new Exception(string.Concat("\"", str2, "\"does not exist,请自行从\"http://www.gildor.org/en/projects/umodel\"网站下载UEViewer程序并将所有文件到本程序所在文件夹。"));
            }
            AnalysisClass.TryCreateOutputAnalysisFolder(argument1);
            List <string> strs = new List <string>();

            if (!objectCollections.Contains(str1))
            {
                throw new Exception("解析Start项does not exist,不能进行解析。");
            }
            if (!objectCollections.Contains(argument2))
            {
                throw new Exception("解析结束项does not exist,不能进行解析。");
            }
            int num1 = objectCollections.IndexOf(str1);
            int num2 = objectCollections.IndexOf(argument2);

            if (num1 > num2)
            {
                throw new Exception("解析Start项在结束项之后,请重新设置解析范围。");
            }
            for (int i = num1; i < num2 + 1; i++)
            {
                string fileFullNameFromItemList = AnalysisClass.GetFileFullNameFromItemList(objectCollections[i].ToString(), argument, flag);
                strs.Add(fileFullNameFromItemList);
            }
            AnalysisClass.analysisWorker.ReportProgress(0, new Report((object x) => {
                if (x != null)
                {
                    AnalysisClass.mainForm.pbAnalysis.Maximum       = (int)x;
                    AnalysisClass.mainForm.lblAnalysisProgress.Text = string.Concat("0/", x.ToString());
                }
            }, (object)strs.Count));
            int num3 = 0;

            while (true)
            {
                if (num3 < strs.Count)
                {
                    AnalysisClass.analysisWorker.ReportProgress(0, new Report((object x) => {
                        if (x != null)
                        {
                            int num = (int)x;
                            AnalysisClass.mainForm.lblCurrentAnalysisFileName.Text = strs[num];
                            AnalysisClass.mainForm.pbAnalysis.Value = num + 1;
                            Label label = AnalysisClass.mainForm.lblAnalysisProgress;
                            int value   = AnalysisClass.mainForm.pbAnalysis.Value;
                            string str  = value.ToString();
                            value       = AnalysisClass.mainForm.pbAnalysis.Maximum;
                            label.Text  = string.Concat(str, "/", value.ToString());
                            LogClass.AppendLine(string.Concat("正在解析文件:", strs[num3]), false);
                        }
                    }, (object)num3));
                    DateTime now = DateTime.Now;
                    AnalysisClass.ue = new UEViewer(strs[num3], argument1, Application.StartupPath);
                    string imageReturnLog = null;
                    string tempFileName   = null;
                    bool   hasImage       = false;
                    try
                    {
                        imageReturnLog = AnalysisClass.ue.AnalysisToImageReturnLog();
                        tempFileName   = AnalysisClass.ue.TempFileName;
                        hasImage       = AnalysisClass.ue.HasImage;
                    }
                    finally
                    {
                        AnalysisClass.ue.Dispose();
                    }
                    if (hasImage)
                    {
                        AnalysisClass.MoveImageFile(argument1, imageReturnLog, tempFileName, strs[num3], flagArray);
                    }
                    if (AnalysisClass.userCancelAnalysis)
                    {
                        AnalysisClass.ue = null;
                        AnalysisClass.lostHandles.Clear();
                        break;
                    }
                    else
                    {
                        num3++;
                    }
                }
                else
                {
                    break;
                }
            }
        }