private void dgvMain_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if ((this.m_datasource != null) && (this.m_datasource.Count > e.RowIndex)) { GameFileDataSource source = this.m_datasource[e.RowIndex].Object; if (!this.m_properties.ContainsKey(e.ColumnIndex)) { this.m_properties.Add(e.ColumnIndex, source.GetType().GetProperty(this.dgvMain.Columns[e.ColumnIndex].DataPropertyName)); } e.Value = this.m_properties[e.ColumnIndex].GetValue(source); } }
private IGameFileDataSource FromZipFile(FileInfo fi) { IGameFileDataSource source = new GameFileDataSource { FileName = fi.Name }; ZipArchive archive = null; try { archive = ZipFile.OpenRead(fi.FullName); } catch { return(null); } bool flag = false; try { foreach (ZipArchiveEntry entry in archive.Entries) { if (new FileInfo(entry.FullName).Extension.Equals(".txt", StringComparison.OrdinalIgnoreCase)) { byte[] buffer = new byte[entry.Length]; entry.Open().Read(buffer, 0, Convert.ToInt32(entry.Length)); IdGamesTextFileParser parser = new IdGamesTextFileParser(Encoding.UTF7.GetString(buffer), this.DateParseFormats); source.Title = parser.Title; source.Author = parser.Author; source.ReleaseDate = parser.ReleaseDate; source.Description = parser.Description; if (string.IsNullOrEmpty(source.Title)) { source.Title = fi.Name; } flag = (!string.IsNullOrEmpty(source.Title) || !string.IsNullOrEmpty(source.Author)) || !string.IsNullOrEmpty(source.Description); } if (flag) { return(source); } } return(source); } catch (InvalidDataException exception1) { source = null; string message = exception1.Message; } return(source); }
public IGameFileDataSource[] Parse(string file) { this.m_errors.Clear(); List <IGameFileDataSource> list = new List <IGameFileDataSource>(); string text = File.ReadAllText(file).Replace("\r\n", "\n"); if (!text.StartsWith("[zdl.save]")) { this.m_errors.Add("Not a valid zdl file"); return(new IGameFileDataSource[0]); } string str2 = null; int num = 0; do { str2 = this.FindValue(text, $"file{num}", s_regexFull, true).Trim(); num++; if (!string.IsNullOrEmpty(str2)) { GameFileDataSource item = new GameFileDataSource { FileName = str2 }; list.Add(item); } }while (!string.IsNullOrEmpty(str2)); if (list.Count > 0) { string str3 = this.FindValue(text, "skill", s_regexFull, true); string port = this.FindValue(text, "port", s_regexFull, true); string str5 = this.FindValue(text, "warp", s_regexFull, true); string str6 = this.FindValue(text, "iwad", s_regexFull, true); string str7 = this.FindValue(text, "extra", s_regexFull, true); IGameFileDataSource local1 = list[0]; local1.SettingsSkill = str3; local1.SettingsMap = str5; local1.Map = str5; local1.SettingsExtraParams = str7; local1.SourcePortID = this.GetSourcePort(port); local1.IWadID = this.GetIWad(str6 + ".wad"); } else { this.m_errors.Add("Did not contain any files (e.g. file=0)"); } return(list.ToArray()); }