Ejemplo n.º 1
0
        public bool IsAllQoute(string text)
        {
            if (text != "")
            {
                text = YMLTools.RemoveSpace(text);
                if (text.Length > 0)
                {
                    string first = text.Substring(0, 1);
                    string end   = text.Substring(text.Length - 1);
                    if (first == "$" && end == "$")
                    {
                        return(true);
                    }
                    if (first == "[" && end == "]")
                    {
                        return(true);
                    }
                }

                //if (first == "§" && text.Substring(text.Length - 2) == "§!")
                //{
                //    if (IsAllQoute(YMLTools.RegexRemoveColorSign(text))) { return true; }
                //}
            }
            return(false);
        }
Ejemplo n.º 2
0
        private void Showintxt(int id)
        {
            string engtext = YMLText.ElementAt(id).VENG;

            if (engtext == "")
            {
                engtext = YMLText.ElementAt(id).OldENG;
            }
            if (UserDict.Count > 0)
            {
                TxtENG.Text = YMLTools.ReplaceWithUserDict(engtext, UserDict);
            }
            else
            {
                TxtENG.Text = engtext;
            }

            TxtCHN.Text = YMLText.ElementAt(id).VCHN;

            if (!YMLText.ElementAt(id).IsEditable())
            {
                BtnApply.Enabled = false;
            }
            else
            {
                BtnApply.Enabled = true;
            }
            GetAPITranslation();
        }
Ejemplo n.º 3
0
 public bool OldNewisDifferent()
 {
     if (YMLTools.RemoveSpace(oldeng) == YMLTools.RemoveSpace(veng))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
 private void BtnApply_Click(object sender, EventArgs e)
 {
     TxtCHN.Text = YMLTools.RemoveReturnMark(TxtCHN.Text);
     YMLText.ElementAt(DfData.CurrentRow.Index).ApplyLine(TxtCHN.Text);
     DfData.Refresh();
     //将文本框内容移除换行符,放回变量,并刷新datagrid。
     BtnSave.Enabled = true;
     //做过修改,保存按钮可以使用了。
 }
Ejemplo n.º 5
0
 public void LoadWithOldDict(Dictionary <string, string> OldDict)
 {
     if (VariableNameWithoutNum != "" && OldDict.TryGetValue(VariableNameWithoutNum, out string outvalue) && outvalue != "")
     {
         oldeng = YMLTools.RegexGetValue(outvalue);
     }
     else
     {
         oldeng = "";
     }
 }
Ejemplo n.º 6
0
 private void BtnOpenBrowser_Click(object sender, EventArgs e)
 {
     if (RadioBaidu.Checked)
     {
         YMLTools.OpenWithBrowser(TxtENG.Text, "Baidu");
     }
     if (RadioGoogle.Checked)
     {
         YMLTools.OpenWithBrowser(TxtENG.Text, "Google");
     }
 }
Ejemplo n.º 7
0
 private bool IsComment()
 {
     if (YMLTools.RemoveSpace(LineCHN).Length > 0)
     {
         if (YMLTools.RemoveSpace(LineCHN).Substring(0, 1) == "#")
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
 private void LstFiles_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (LstFiles.Enabled == true)
     {
         YMLText = YMLTools.ReadFile(LstFiles.Text);
         LoadtoDataGrid();
         if (OldVersionDict.Count > 0)
         {
             ComBLoad();
         }
     }
 }
Ejemplo n.º 9
0
 public YML(string LineTo) : this()
 {
     LineCHN                = LineTo;
     LineENG                = "";
     variablename           = YMLTools.RegexGetName(LineTo);
     variablenamewithoutnum = YMLTools.RegexGetNameOnly(variablename);
     vchn = YMLTools.RegexGetValue(LineTo);
     if (HasError())
     {
         FixError();
     }
     oldeng = "";
 }
Ejemplo n.º 10
0
 public bool IsEditable()
 {
     if (IsSpaceLine())
     {
         return(false);
     }
     if (YMLTools.RemoveSpace(LineCHN) == "l_english:")
     {
         return(false);
     }
     if (IsComment())
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 11
0
        private void BuildOldVersionDict()
        {
            string LoadinDir = StaticVars.DirOldBase + CombOldVersion.SelectedItem.ToString() + "\\";

            string[] FileYMLList = Directory.GetFiles(LoadinDir, "*.yml");
            if (FileYMLList.Length > 0)
            {
                List <string> ListForDict = new List <string>();
                foreach (string str in FileYMLList)
                {
                    string Filepath = LoadinDir + Path.GetFileName(str);
                    ListForDict.AddRange(File.ReadAllLines(Filepath));
                }
                OldVersionDict = YMLTools.BuildDictionary(ListForDict);
            }
        }
Ejemplo n.º 12
0
        private void BtnMergeAll_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Merge All Files ?", "Merge All", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                LstFiles.Enabled = false;
                for (int i = 0; i < LstFiles.Items.Count; i++)
                {
                    LstFiles.SelectedIndex = i;
                    YMLText = YMLTools.ReadFile(LstFiles.Text);
                    List <string> lstWriteback = MakeWriteBackList();
                    WriteEngFile(lstWriteback);
                }
                LstFiles.Enabled = true;
            }
        }
Ejemplo n.º 13
0
        private void ReadFile()
        {
            string EngPath = "eng\\" + LstFiles.Text;
            string ChnPath = "chn\\" + LstFiles.Text;

            if (!File.Exists(ChnPath))
            {
                FileStream fs   = File.Create(ChnPath);
                Byte[]     info = new UTF8Encoding(true).GetBytes("l_english:");
                fs.Write(info, 0, info.Length);
                fs.Close();
            }
            // 检测chn文件夹内文件是否存在,不存在则建立。

            listEng = new List <string>(File.ReadAllLines(EngPath));
            listChn = new List <string>(File.ReadAllLines(ChnPath));

            YMLText = YMLTools.BuildYMLList(listEng, listChn);
        }
Ejemplo n.º 14
0
 private void TxtFind_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         for (int i = DfData.CurrentRow.Index; i < DfData.RowCount; i++)
         {
             if (i + 1 <= DfData.RowCount - 1)
             {
                 DfData.CurrentCell = DfData[DfData.CurrentCell.ColumnIndex, i + 1];
             }
             else
             {
                 DfData.CurrentCell = DfData[DfData.CurrentCell.ColumnIndex, 0];
             }
             if (YMLTools.RegexContainsWord(YMLText.ElementAt(DfData.CurrentRow.Index).VENG, TxtFind.Text))
             {
                 break;
             }
         }
     }
 }
Ejemplo n.º 15
0
        private List <string> MakeWriteBackList()
        {
            List <string> lstWriteback = new List <string>();

            for (int id = 0; id < YMLText.Count; id++)
            {
                if (ChkSaveOnlyTranslated.Checked == true && YMLText.ElementAt(id).SameInToAndFrom())
                {
                    continue;
                }
                if (ChkSimplifiedChinese.Checked == true)
                {
                    lstWriteback.Add(YMLTools.ToSimplifiedChinese(YMLText.ElementAt(id).TranslatedLine)); continue;
                }
                if (ChkTraditionalChinese.Checked == true)
                {
                    lstWriteback.Add(YMLTools.ToTraditionalChinese(YMLText.ElementAt(id).TranslatedLine)); continue;
                }
                lstWriteback.Add(YMLText.ElementAt(id).TranslatedLine);
            }
            return(lstWriteback);
        }
Ejemplo n.º 16
0
        private async void GetAPITranslation()
        {
            TxtAPI.Clear();
            BtnAPItochnBox.Enabled = false;
            Task <string> GetTranslationTask = new Task <string>(FuncAsyncGetTranslation);

            try
            {
                GetTranslationTask.Start();
                TxtAPI.Text = await GetTranslationTask;
                GetTranslationTask.Dispose();
            }
            catch
            {
                TxtAPI.Text = "Nothing";
                GetTranslationTask.Dispose();
            }
            BtnAPItochnBox.Enabled = true;

            string FuncAsyncGetTranslation()
            {
                return(YMLTools.GetTranslatedTextFromAPI(YMLTools.RemoveReturnMark(TxtENG.Text)));
            }
        }
Ejemplo n.º 17
0
        public YML(string LineFrom, Dictionary <string, string> DictForTo) : this()
        {
            LineENG                = LineFrom;
            variablename           = YMLTools.RegexGetName(LineFrom);
            variablenamewithoutnum = YMLTools.RegexGetNameOnly(variablename);
            veng = YMLTools.RegexGetValue(LineFrom);

            if (VariableNameWithoutNum != "" && DictForTo.TryGetValue(VariableNameWithoutNum, out string outvalue) && outvalue != "")
            {
                LineCHN = outvalue;
                //vchn = YMLTools.RegexGetValue(outvalue);
            }
            else
            {
                LineCHN = LineFrom;
                //vchn = YMLTools.RegexGetValue(LineFrom);
            }

            if (HasError())
            {
                FixError();
            }
            oldeng = "";
        }
Ejemplo n.º 18
0
        private void FuncSave()
        {
            List <string> lstWriteback = new List <string>();

            for (int id = 0; id < YMLText.Count; id++)
            {
                if (ChkSaveOnlyTranslated.Checked == true && YMLText.ElementAt(id).SameInToAndFrom())
                {
                    continue;
                }
                if (ChkSimplifiedChinese.Checked == true)
                {
                    lstWriteback.Add(YMLTools.ToSimplifiedChinese(YMLText.ElementAt(id).TranslatedLine)); continue;
                }
                if (ChkTraditionalChinese.Checked == true)
                {
                    lstWriteback.Add(YMLTools.ToTraditionalChinese(YMLText.ElementAt(id).TranslatedLine)); continue;
                }
                lstWriteback.Add(YMLText.ElementAt(id).TranslatedLine);
            }
            File.WriteAllLines("chn\\" + LstFiles.Text, lstWriteback.ToArray(), Encoding.UTF8);
            BtnSave.Enabled = false;
            // 保存文件
        }
Ejemplo n.º 19
0
 private void LabHelp_DoubleClick(object sender, EventArgs e)
 {
     YMLTools.OpenWithBrowser("", "Help");
 }
Ejemplo n.º 20
0
 private string TestComment()
 {
     return(YMLTools.RegexGetName(LineCHN) + "\"" + YMLTools.RegexGetValue(LineCHN) + "\"");
 }