Esempio n. 1
0
 public void Calculate()
 {
     this.gbStats.Text = "对话统计(计算...)";
     this.statsThread  = new Thread(() => {
         float single;
         int num;
         int num1;
         int num2;
         TranslationManager.GetStats(out single, out num, out num1, out num2);
         single          = (float)((int)Math.Round((double)single * 1000)) / 1000f;
         int length      = 0;
         char[] chrArray = new char[] { ' ', '\n' };
         Dictionary <string, byte> strs = new Dictionary <string, byte>();
         foreach (GameData.Item value in this.nav.ou.gameData.items.Values)
         {
             if (value.type != itemType.DIALOGUE_LINE)
             {
                 continue;
             }
             foreach (KeyValuePair <string, object> keyValuePair in value)
             {
                 if (value.getState(keyValuePair.Key) == GameData.State.ORIGINAL || !keyValuePair.Key.StartsWith("text"))
                 {
                     continue;
                 }
                 string str = keyValuePair.Value as string;
                 if (strs.ContainsKey(str))
                 {
                     continue;
                 }
                 strs.Add(str, 0);
                 length += (int)str.Split(chrArray, StringSplitOptions.RemoveEmptyEntries).Length;
             }
         }
         StreamWriter streamWriter = new StreamWriter(string.Concat(TranslationManager.ActiveTranslation.path, "/translated.txt"), false, Encoding.UTF8);
         foreach (string key in strs.Keys)
         {
             streamWriter.WriteLine(key);
         }
         streamWriter.Flush();
         streamWriter.Close();
         base.BeginInvoke(new MethodInvoker(() => {
             this.lblCompletePercentage.Text = string.Concat(single.ToString(), "%");
             this.lblTranslatedSource.Text   = num.ToString();
             this.lblWordsTotal.Text         = num1.ToString();
             this.lblWordsExtra.Text         = num2.ToString();
             this.lblTranslatedWords.Text    = length.ToString();
             this.gbStats.Text = "对话统计";
         }));
     });
     this.statsThread.Start();
 }