public static void convertDirectory(string InDir, string OutDir) { var exclude = new TStringList(); exclude.Add("WebCore\\bindings"); exclude.Add("WebCore\\testing"); foreach (var excl in exclude) { if (InDir.EndsWith(excl)) { return; } } if (!(InDir.EndsWith("\\"))) { InDir += "\\"; } if (!(OutDir.EndsWith("\\"))) { OutDir += "\\"; } System.IO.DirectoryInfo InDirInfo = new System.IO.DirectoryInfo(InDir); foreach (System.IO.DirectoryInfo InDirInfo2 in InDirInfo.GetDirectories()) { convertDirectory(InDirInfo2.FullName, OutDir + InDirInfo2.Name); } foreach (System.IO.FileInfo file in InDirInfo.GetFiles("*.idl")) { convertFile(file.FullName, OutDir + file.Name.Replace(".idl", ".cs")); } }
public static void convertFile(string InFile, string OutFile) { TStringList st = new TStringList(); st.Add("org\\w3c\\dom\\html\\Function.java"); st.Add("org\\w3c\\dom\\websocket"); foreach (string f in st) { if (InFile.Contains(f)) { return; } } Console.WriteLine(InFile); if (!(System.IO.Directory.Exists(Path.GetDirectoryName(OutFile)))) { System.IO.Directory.CreateDirectory(Path.GetDirectoryName(OutFile).ToLower()); } TParsedFile Parser = new TParsedFile(); Parser.convertFile(InFile, OutFile); parsedFiles.Add(Parser); }
public void WriteString(string str_sec, string str_key, string str_value) { int dest_idx; int tmp_idx; dest_idx = FindSec(str_sec); if (dest_idx >= 0) { dest_idx = FindKey(str_key, dest_idx); if (dest_idx >= 0) //有 section 有 key { TmpList[dest_idx] = str_key + "=" + str_value; } else //有 section 沒 key { tmp_idx = FindSecLastIdx(str_sec); //TmpList.Insert(tmp_idx,str_key+"="+str_value); if (tmp_idx != TmpList.Count - 1) { TmpList.Insert(tmp_idx + 1, str_key + "=" + str_value); } else { TmpList.Add(str_key + "=" + str_value); } } } else //沒 section 沒 key { TmpList.Add("[" + str_sec + "]"); TmpList.Add(str_key + "=" + str_value); } }
public void GetListOfLanguages(TStringList list) { string filename, path; string langcode; int j; list.Clear(); // Iterate through filesystem foreach (string name in System.IO.Directory.EnumerateDirectories(Directory, "*")) { if (name != "." && name != "..") { filename = Directory + name + Path.DirectorySeparatorChar + "LC_MESSAGES" + Path.DirectorySeparatorChar + Domain + ".mo"; if (File.Exists(filename)) { langcode = name.ToLower(); if (list.IndexOf(langcode) == -1) { list.Add(langcode); } } } } // Iterate through embedded files for (int i = 0; i < TFileLocator.filelist.Count; i++) { filename = TFileLocator.basedirectory + TFileLocator.filelist.Strings[i]; path = Directory; path = path.ToUpper(); filename = filename.ToUpper(); j = path.Length; if (filename.Substring(0, j) == path) { path = Path.DirectorySeparatorChar + "LC_MESSAGES" + Path.DirectorySeparatorChar + Domain + ".mo"; path = path.ToUpper(); if (filename.Substring(filename.Length - path.Length, path.Length) == path) { langcode = filename.Substring(j, filename.Length - path.Length - j).ToLower(); langcode = langcode.Substring(0, 3) + langcode.Substring(3).ToUpper(); if (list.IndexOf(langcode) == -1) { list.Add(langcode); } } } } }
public void SaveCastleList() { TStringList LoadList; try { if (!Directory.Exists(M2Share.g_Config.sCastleDir)) { Directory.CreateDirectory(M2Share.g_Config.sCastleDir); } if (m_CastleList.Count > 0) { LoadList = new TStringList(); for (int I = 0; I < m_CastleList.Count; I++) { LoadList.Add(Convert.ToString(I)); } LoadList.SaveToFile(M2Share.g_Config.sCastleFile); } } catch { M2Share.MainOutMessage("{异常} CastleManager.SaveCastleList..." + M2Share.g_Config.sCastleFile); } }
public TStringList GetHelpStrings(string HelpString) { TStringList Result = new TStringList(); Result.Add(GetViewerName() + ": " + HelpString); return(Result); }
public static void SaveGateConfig(TConfig Config) { TStringList SaveList; int I; int n8; string s10; string sC; SaveList = new TStringList(); SaveList.Add(";No space allowed"); SaveList.Add(GenSpaceString(";Server", 15) + GenSpaceString("Title", 15) + GenSpaceString("Remote", 17) + GenSpaceString("Public", 17) + "Gate..."); for (I = 0; I < Config.nRouteCount; I++) { sC = GenSpaceString(Config.GateRoute[I].sServerName, 15) + GenSpaceString(Config.GateRoute[I].sTitle, 15) + GenSpaceString(Config.GateRoute[I].sRemoteAddr, 17) + GenSpaceString(Config.GateRoute[I].sPublicAddr, 17); n8 = 0; while (true) { s10 = Config.GateRoute[I].Gate[n8].sIPaddr; if (s10 == "") { break; } if (!Config.GateRoute[I].Gate[n8].boEnable) { s10 = '*' + s10; } s10 = s10 + ':' + (Config.GateRoute[I].Gate[n8].nPort).ToString(); sC = sC + GenSpaceString(s10, 17); n8++; if (n8 >= 10) { break; } } SaveList.Add(sC); } SaveList.SaveToFile(".\\!addrtable.txt"); //SaveList.Free; }
/// <summary> /// 添加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonAdd_Click(object sender, EventArgs e) { try { string Msg = ComboBoxMsg.Text.Trim(); if (Msg != "") { StrList.Add(Msg); } StrList.SaveToFile(StrListFile); this.Refresh(); } finally { } }
private TStringList TokensToStringList() { TStringList st = new TStringList(); System.Text.StringBuilder CurrentLine = new System.Text.StringBuilder(); foreach (TCodeToken tok in Tokens) { if (tok.token == ECodeToken.SyEndOfLine) { st.Add(CurrentLine.ToString()); CurrentLine.Length = 0; } else { CurrentLine.Append(tok.value); } } return(st); }
private TStringList TokensToStringList() { TStringList st = new TStringList(); System.Text.StringBuilder CurrentLine = new System.Text.StringBuilder(); foreach (TCodeToken tok in Tokens) { if (tok.token == ECodeToken.SyEndOfLine) { st.Add(CurrentLine.ToString()); CurrentLine.Length = 0; } else { CurrentLine.Append(tok.value); } } return st; }
//--------------------------------------------------------------------------- // Baue einen Report zusammen private void DoReport(string ReportFile) {//TODO: fix indices from delphi port string strLine = "", strTag = null, strName = null, strInsert; TStringList strText = new TStringList(); int i; char cCur; bool[] bVisible = new bool[10]; // Ist Output sichtbar bVisible[0] = true; int ifLevel = 0; // If-Ebenen-Verschachtelung bool bTag = false; bool bConditional = false; // Ist wahr, wenn in der Zeile ein conditional steht bool bName = false; tbReport.Clear(); try { IFStreamWrapper _in = new IFStreamWrapper(ReportFile); while (!_in.EndOfStream) { // Lese alles bis zum Dateiende _in.get(out cCur); if (bTag) { if (cCur == '>') { // Tag ist wieder zu Ende int iPos = strName.Length + 1; // Erstes Zeichen nach dem Tagnamen strName = strName.ToLower(); strInsert = ""; int aid = -1; if (strName == "name") { strInsert = Unit.player.Name; } else if (strName == "if") { ifLevel++; Debug.Assert(ifLevel < 10); if (bVisible[ifLevel - 1]) { string strTemp = strTag.Substring(iPos, Math.Min(99, strTag.Length - iPos)); iPos = strTemp.IndexOf(' ') + 1; if (PieceStat(strTemp, out strInsert, ref iPos) == 0) { bVisible[ifLevel] = false; } else { bVisible[ifLevel] = true; } } else { bVisible[ifLevel] = false; } bConditional = true; // strInsert = ""; } else if (strName == "endif") { ifLevel--; bConditional = true; } else if (strName == "else") { if (bVisible[ifLevel - 1]) { bVisible[ifLevel] = !bVisible[ifLevel]; } bConditional = true; } else if (strName == "level") { strInsert = (Unit.player.Level).ToString(); } else if (strName == "totalcost") { strInsert = Unit.frmMain.lbSCCost.Text; } else if (strName == "str") { aid = Unit.xml_config.GetAttributeId("STRENGTH"); } else if (strName == "con") { aid = Unit.xml_config.GetAttributeId("CONSTITUTION"); } else if (strName == "dex") { aid = Unit.xml_config.GetAttributeId("DEXTERITY"); } else if (strName == "qui") { aid = Unit.xml_config.GetAttributeId("QUICKNESS"); } else if (strName == "int") { aid = Unit.xml_config.GetAttributeId("INTELLIGENCE"); } else if (strName == "pie") { aid = Unit.xml_config.GetAttributeId("PIETY"); } else if (strName == "cha") { aid = Unit.xml_config.GetAttributeId("CHARISMA"); } else if (strName == "emp") { aid = Unit.xml_config.GetAttributeId("EMPATHY"); } else if (strName == "hits") { aid = Unit.xml_config.GetAttributeId("HITPOINTS"); } else if (strName == "power") { aid = Unit.xml_config.GetAttributeId("POWER"); } else if (strName == "crush") { aid = Unit.xml_config.GetAttributeId("RES_CRUSH"); } else if (strName == "slash") { aid = Unit.xml_config.GetAttributeId("RES_SLASH"); } else if (strName == "thrust") { aid = Unit.xml_config.GetAttributeId("RES_THRUST"); } else if (strName == "heat") { aid = Unit.xml_config.GetAttributeId("RES_HEAT"); } else if (strName == "cold") { aid = Unit.xml_config.GetAttributeId("RES_COLD"); } else if (strName == "matter") { aid = Unit.xml_config.GetAttributeId("RES_MATTER"); } else if (strName == "body") { aid = Unit.xml_config.GetAttributeId("RES_BODY"); } else if (strName == "spirit") { aid = Unit.xml_config.GetAttributeId("RES_SPIRIT"); } else if (strName == "energy") { aid = Unit.xml_config.GetAttributeId("RES_ENERGY"); } else if (strName == "skills") { // Alles Skills listen for (int skill = 0; skill < Unit.xml_config.arClasses[Unit.player.Class].nSkills; skill++) { int a = Unit.xml_config.arClasses[Unit.player.Class].arSkills[skill]; // Allerdings nur, wenn höher als 0 if (bVisible[ifLevel] && (Unit.player.Attributes.Value[a] > 0)) { strText.Add((Unit.player.Attributes.Value[a]).ToString() + " " + Unit.xml_config.arAttributes[a].Name); } } } else if (strName == "skill") { int skill = strTag.Substring(iPos, Math.Min(2, strTag.Length - iPos)).ToIntDef(0); iPos += 3; if ((skill > 0) && (skill <= Unit.xml_config.arClasses[Unit.player.Class].nSkills)) { int a = Unit.xml_config.arClasses[Unit.player.Class].arSkills[skill - 1]; strInsert = (Unit.player.Attributes.Value[a]).ToString() + " " + Unit.xml_config.arAttributes[a].Name; } } else if (strName.Length > 5 && strName.Substring(0, 5) == "focus") { int focus = strTag.Substring(5, 1).ToIntDef(0); int fg = Unit.xml_config.GetGroupId("FOCUS"); if ((focus > 0) && (fg >= 0)) { int c = 0; for (i = 0; i < Unit.xml_config.nBonuses; i++) { if ((Unit.xml_config.arBonuses[i].idGroup == fg) && (Unit.xml_config.arBonuses[i].arAttributes.Length == 1)) { int fid = Unit.xml_config.arBonuses[i].arAttributes[0]; if ((Unit.player.Attributes.Value[fid] > 0) && (Unit.xml_config.arAttributes[fid].SkillId >= 0) && Unit.player.AttributeUseable(Unit.xml_config.arAttributes[fid].SkillId)) { c++; if (c == focus) { strInsert = (Unit.player.Attributes.Value[fid]).ToString() + " " + Unit.xml_config.arAttributes[fid].Name; } } } } } } else if (strName == "capbonuses") { // Liste die Cap-Boni for (i = 0; i < Unit.xml_config.nAttributes; i++) { if (Unit.xml_config.arAttributes[i].CapId >= 0 && !Unit.xml_config.arAttributes[i].bCapAttr) { int cid = Unit.xml_config.arAttributes[i].CapId; if ((Unit.player.Attributes.Cap[cid] > 0) && bVisible[ifLevel]) { strText.Add((Unit.player.Attributes.Cap[cid]).ToString() + " " + Unit.xml_config.arAttributes[cid].Name); } } } } else if (strName == "otherbonuses") { // Liste die anderen Boni int idOthers = Unit.xml_config.GetGroupId("OTHERS"); Debug.Assert(idOthers >= 0); for (i = 0; i < Unit.xml_config.nBonuses; i++) { if ((Unit.xml_config.arBonuses[i].idGroup == idOthers) && (Unit.xml_config.arBonuses[i].arAttributes.Length == 1)) { // Werte für Sinnesschärfe direkt nicht anzeigen int bid = Unit.xml_config.arBonuses[i].arAttributes[0] & 0xfff; if ((Unit.player.Attributes.Value[bid] > 0) && bVisible[ifLevel]) { strText.Add((Unit.player.Attributes.Value[bid]).ToString() + " " + Unit.xml_config.arAttributes[bid].Name); } } } } else if (strName == "materials") { string strTemp = strTag.Substring(iPos, Math.Min(99, strTag.Length - iPos)); if (strTemp == "gemlist") { int[] arGemList = new int[Unit.xml_config.nBonuses * 10]; Debug.Assert(arGemList != null); for (i = Unit.xml_config.nBonuses * 10; (i--) > 0;) { arGemList[i] = 0; } for (int p = 0; p < 10; p++) { if (Unit.player.ItemType[p] == EItemType.Crafted) { for (i = 0; i < Unit.player.nItemEffects[p]; i++) { int bid = Unit.player.ItemEffect[p][i]; if (bid >= 0 && i < 4) { int val = Unit.player.EffectValue[p][i]; // Effektlevel besorgen for (int j = 0; j < 10; j++) { if (Unit.xml_config.arBonuses[bid].Gemvalue[j] == val) { arGemList[bid * 10 + j]++; break; } } } } } } // Gems ausgeben for (i = 0; i < Unit.xml_config.nBonuses; i++) { for (int j = 0; j < 10; j++) { if (arGemList[i * 10 + j] > 0) { if (bVisible[ifLevel]) { strText.Add((arGemList[i * 10 + j]).ToString() + " " + Unit.xml_config.arBonuses[i].GemName + " (" + Unit.xml_config.arMaterials[Unit.xml_config.GetMaterialId("GEMS")].arLevel[j].GemPrefix + ")"); } } } } arGemList = null; } else { int[] Gems = new int[10]; // Zähler für die Gems TStringList sGemList; sGemList = new TStringList(); // Lösche die Zählvariablen for (i = 0; i < Unit.xml_config.nIngredients; i++) { Unit.xml_config.arIngredients[i].Count[0] = 0; } for (i = 0; i < 10; i++) { Gems[i] = 0; } for (int p = 0; p < 10; p++) { if (Unit.player.ItemType[p] == EItemType.Crafted) { for (i = 0; i < Unit.player.nItemEffects[p]; i++) { int bid = Unit.player.ItemEffect[p][i]; if (bid >= 0 && i < 4) { int val = Unit.player.EffectValue[p][i]; // Gemlevel bestimmen int gemlevel = -1; for (int j = 0; j < 10; j++) { if (Unit.xml_config.arBonuses[bid].Gemvalue[j] == val) { gemlevel = j; break; } } Debug.Assert(gemlevel >= 0); // Besorge zu dem gemlevel die Anzahl an Stäuben und Flüssigkeiten int dusts = Unit.xml_config.arBonuses[bid].DustAmount[gemlevel]; int liquids = Unit.xml_config.arBonuses[bid].LiquidAmount[gemlevel]; // Jetzt wissen wir welches Gem gebraucht wird int dust = Unit.xml_config.arBonuses[bid].GemDust; Gems[gemlevel] += Unit.xml_config.arBonuses[bid].GemAmount[gemlevel] + (Unit.player.Remakes[p][i] * Unit.xml_config.arBonuses[bid].GemAmount[gemlevel]); Unit.xml_config.arIngredients[dust].Count[0] += (Unit.player.Remakes[p][i] + 1) * dusts; for (int j = 0; j < Unit.xml_config.arBonuses[bid].nLiquids; j++) { Unit.xml_config.arIngredients[Unit.xml_config.arBonuses[bid].GemLiquids[j]].Count[0] += (Unit.player.Remakes[p][i] + 1) * liquids; } } } } } // Die Ausgabe ist jetzt abhängig von der angeforderten Liste if (strTemp == "gems") { int Gem = Unit.xml_config.GetMaterialId("GEMS"); for (i = 0; i < 10; i++) { if ((Gems[i] > 0) && bVisible[ifLevel]) { strText.Add((Gems[i]).ToString() + " " + Unit.xml_config.arMaterials[Gem].arLevel[i].Name + " " + _("Juwel")); } } } else if (strTemp == "dusts") { for (i = 0; i < Unit.xml_config.nIngredients; i++) { if (Unit.xml_config.arIngredients[i].bDust && (Unit.xml_config.arIngredients[i].Count[0] > 0) && bVisible[ifLevel]) { strText.Add((Unit.xml_config.arIngredients[i].Count[0]).ToString() + " " + Unit.xml_config.arIngredients[i].Name); } } } else if (strTemp == "liquids") { for (i = 0; i < Unit.xml_config.nIngredients; i++) { if (!Unit.xml_config.arIngredients[i].bDust && (Unit.xml_config.arIngredients[i].Count[0] > 0) && bVisible[ifLevel]) { strText.Add((Unit.xml_config.arIngredients[i].Count[0]).ToString() + " " + Unit.xml_config.arIngredients[i].Name); } } } sGemList = null; } } else if (PieceStat(strTag, out strInsert, ref iPos) > 0) { } // Hier muß nichts mehr gemacht werden else // Kein bekannter Tag, also den tag im orginal ausgeben { strInsert = "<" + strTag + '>'; } if (aid >= 0) { strInsert = Unit.player.Attributes.Value[aid].ToString(); } if (bVisible[ifLevel]) { if (iPos < strTag.Length) { // Gibt eine Feldlänge int iLen = strTag.Substring(iPos, Math.Min(2, strTag.Length - iPos)).ToIntDef(0); if (strInsert.Length < iLen) { strLine += new string(' ', iLen - strInsert.Length); } } strLine += strInsert; } bTag = false; } else { // Im Tag if (cCur == ' ') { bName = false; } strTag += cCur; if (bName) { strName += cCur; } } } else // Wir sind im normalen Text { if (cCur == '<') { bTag = true; bName = true; strTag = ""; strName = ""; } else if (cCur == '\n') { if (bVisible[ifLevel] && !bConditional) { strText.Add(strLine); } strLine = ""; bConditional = false; } else if (bVisible[ifLevel]) { strLine += cCur; } } } tbReport.Lines = strText.Strings.ToArray(); strText = null; } catch (Exception) { Utils.DebugPrint("Es ist ein Fehler in TfrmReport::DoReport aufgetreten!"); } }
static Utils() { ComponentDomainList = new TStringList(); ComponentDomainList.Add(TGnuGettextInstance.DefaultTextDomain); ComponentDomainListCS = new ReaderWriterLock(); }
private void Log(string AMsg) { LogFile.Add(AMsg); }