public ListDataBook(string folderTable, string fileName) { string[] _lineFileds; string lang, nameBook, added, transl, path, fname; uint id, idAuthor, series, year, size, crc32, number; FormatStr p_FormatStr; //hработа со строкой файла _lineFileds = File.ReadAllLines(folderTable + fileName, Encoding.GetEncoding(1251)); p_FormatStr = new FormatStr(); foreach (string currLine in _lineFileds) { p_FormatStr.FormatetStr(currLine); id = Convert.ToUInt32(p_FormatStr.StrFiledList[0]); idAuthor = Convert.ToUInt32(p_FormatStr.StrFiledList[1]); nameBook = p_FormatStr.StrFiledList[2]; lang = p_FormatStr.StrFiledList[3]; series = Convert.ToUInt32(p_FormatStr.StrFiledList[4]); number = Convert.ToUInt32(p_FormatStr.StrFiledList[5]); year = Convert.ToUInt32(p_FormatStr.StrFiledList[6]); transl = p_FormatStr.StrFiledList[7]; path = p_FormatStr.StrFiledList[8]; fname = p_FormatStr.StrFiledList[9]; size = Convert.ToUInt32(p_FormatStr.StrFiledList[10]); added = p_FormatStr.StrFiledList[12]; crc32 = Convert.ToUInt32(p_FormatStr.StrFiledList[13]); DataBookList.Add(new DataBook(id, nameBook, idAuthor, lang, series, number, year, transl, path, fname, size, added, crc32)); p_FormatStr.StrFiledList.Clear(); } }
public ListDataBookTags(string folderTable, string fileName) { string[] _lineFileds; string _bookAnons; uint id; FormatStr p_FormatStr; //hработа со строкой файла _lineFileds = File.ReadAllLines(folderTable + fileName, Encoding.GetEncoding(1251)); p_FormatStr = new FormatStr(); foreach (string currLine in _lineFileds) { p_FormatStr.FormatetStr(currLine); id = Convert.ToUInt32(p_FormatStr.StrFiledList[0]); _bookAnons = p_FormatStr.StrFiledList[1]; DataBookTags.Add(new DataBookTags(id, _bookAnons)); p_FormatStr.StrFiledList.Clear(); } }
/********************************************************** * имя процедуры: ListDataAuthor * назначение: конструктор класса * входные данные: folderTable - имя папки хранения таблиц * fileName - таблица списка авторов * выходные данные: * ********************************************************/ public ListDataAuthor(string folderTable, string fileName) { string[] _lineFileds; string name, midname; uint id; FormatStr p_FormatStr; //работа со строкой файла _lineFileds = File.ReadAllLines(folderTable + fileName, Encoding.GetEncoding(1251)); p_FormatStr = new FormatStr(); foreach (string currLine in _lineFileds) { p_FormatStr.FormatetStr(currLine); id = Convert.ToUInt32(p_FormatStr.StrFiledList[0]); name = p_FormatStr.StrFiledList[1]; midname = p_FormatStr.StrFiledList[2]; DataAuthorList.Add(new DataAuthor(id, name, midname)); p_FormatStr.StrFiledList.Clear(); } }
public void PraseSelf() { Regex reg; if (FormatStr.StartsWith ("SerialNo[")) { _type = "SerialNo"; reg = new Regex(@"SerialNo\[(\d{0,})\,(\d{0,})\,(\d{0,})\,(\d{0,})\,([a-zA-Z]{0,})\](\[(varlen)\]){0,}"); Match ma = reg.Match(FormatStr); if (ma.Success) { _start = int.Parse((ma.Groups[1].Value ?? "1").ToString() == "" ? "1" : (ma.Groups[1].Value ?? "1").ToString()); _incr = int.Parse((ma.Groups[2].Value ?? "1").ToString() == "" ? "1" : (ma.Groups[2].Value ?? "1").ToString()); object obj = ma.Groups[3].Value ?? ""; if (string.IsNullOrWhiteSpace(obj.ToString())) { _len = -1; } else { _len = int.Parse(obj.ToString()); } obj = ma.Groups[4].Value ?? ""; if (string.IsNullOrWhiteSpace(obj.ToString())) { _end = -1; } else { _end = int.Parse(obj.ToString()); } _cyclemodel = (ma.Groups[5].Value ?? "").ToString(); if ((ma.Groups[7].Value ?? "").ToString() == "varlen") { _varlen = true; } else { _varlen = false; } } else { throw new Exception("当前未匹配成功,请检查语法:" + FormatStr); } } else if (FormatStr.StartsWith("Text[")) { _type = "Text"; reg = new Regex(@"Text\[([^\]]+)\]\[(\d+)\]"); Match ma = reg.Match(FormatStr); if (ma.Success) { _textval = ma.Groups[1].Value.ToString(); _len = int.Parse(ma.Groups[2].Value.ToString()); } else { throw new Exception("当前未匹配成功,请检查语法:" + FormatStr); } } else if (FormatStr.StartsWith("DateTime[")) { _type = "DateTime"; reg = new Regex(@"DateTime\[([^\]]+)\]\[(\d+)\](\[(incycle)\]){0,}"); Match ma = reg.Match(FormatStr); if (ma.Success) { _dateformate = ma.Groups[1].Value.ToString(); _len = int.Parse(ma.Groups[2].Value.ToString()); object obj = ma.Groups[4].Value ?? ""; if (obj.ToString() == "incycle") { _incyle = true; } else { _incyle = false; } } else { throw new Exception("当前未匹配成功,请检查语法:" + FormatStr); } } }
private void DisplayString(int Index) { string Data; string FormatStr; m_BoxList[Index].Var1.Text = (m_BoxList[Index].Var1.Text == "" ? "0" : m_BoxList[Index].Var1.Text); m_BoxList[Index].Var2.Text = (m_BoxList[Index].Var2.Text == "" ? "0" : m_BoxList[Index].Var2.Text); m_BoxList[Index].Var3.Text = (m_BoxList[Index].Var3.Text == "" ? "0" : m_BoxList[Index].Var3.Text); // Load in data float Val1 = float.Parse(m_BoxList[Index].Var1.Text); float Val2 = float.Parse(m_BoxList[Index].Var2.Text); float Val3 = float.Parse(m_BoxList[Index].Var3.Text); Data = m_EffectList[m_BoxList[Index].EffectBox.SelectedIndex].EffectToolList; OutputStr[Index] = ""; // Find and replace all old C++ // printf with new format options // NOTE: This is for ENB Emulator types ONLY! int VarNum = 0; for (int x = 0; x < Data.Length; x++) { FormatStr = ""; // See if we found the start of the string if ((x + 6 <= Data.Length) && ("%value" == Data.Substring(x, 6))) { x += 6; // Add 6 to our string for (int z = x; z < Data.Length - 1; z++) { // We have found the end of the format string if (Data.Substring(z, 2) == "f%") { // Save the data FormatStr = Data.Substring(x, z - x); x += z - x; break; } } // Format string now for (int y = 0; y < FormatStr.Length; y++) { if (FormatStr.Substring(y, 1) == ".") { OutputStr[Index] += "{" + VarNum.ToString() + ":"; int Before = Int32.Parse(FormatStr.Substring(0, y)); int After = Int32.Parse(FormatStr.Substring(y + 1, FormatStr.Length - y - 1)); for (int j = 0; j < Before; j++) { OutputStr[Index] += "0"; } OutputStr[Index] += "."; for (int j = 0; j < After; j++) { OutputStr[Index] += "0"; } break; } } OutputStr[Index] += "}"; x += 2; // Jump over the f% VarNum++; } else { // Save parsed string OutputStr[Index] += Data.Substring(x, 1); } } // Enable correct box's if (VarNum > 0) { m_BoxList[Index].Var1.Enabled = true; } else { m_BoxList[Index].Var1.Enabled = false; } if (VarNum > 1) { m_BoxList[Index].Var2.Enabled = true; } else { m_BoxList[Index].Var2.Enabled = false; } if (VarNum > 2) { m_BoxList[Index].Var3.Enabled = true; } else { m_BoxList[Index].Var3.Enabled = false; } m_BoxList[Index].EffectString.Text = String.Format(OutputStr[Index], Val1, Val2, Val3); }