public void ReadTxtFile(StreamReader sw) { TeleportList = new List <FileStructure>(); try { while (true) { string[] Point = sw.ReadLine().Split(new char[] { '\"' }); if (Point.Count() != 0) { FileStructure fs = new FileStructure(); int.TryParse(Point[0], out fs.ID); fs.MapName = Point[1]; int.TryParse(Point[2], out fs.MapId); string[] Positions = Point[3].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); float.TryParse(Positions[0].Replace('.', ','), out fs.X_position); float.TryParse(Positions[1].Replace('.', ','), out fs.Y_position); float.TryParse(Positions[2].Replace('.', ','), out fs.Z_position); int.TryParse(Point[4], out fs.GroupId); TeleportList.Add(fs); TeleportAmount++; } } } catch (Exception ex) { } sw.Close(); }
private void Add_Click(object sender, EventArgs e) { if (Read != null && TeleportsGrid.Rows.Count > 0) { TeleportsGrid.ScrollBars = ScrollBars.None; SelectedRowIndexes = SelectedRowIndexes.OrderBy(z => z).ToList(); foreach (var item in SelectedRowIndexes) { Read.TeleportAmount++; FileStructure fs = new FileStructure(); fs.ID = Read.TeleportList[item].ID; fs.MapId = Read.TeleportList[item].MapId; fs.MapName = Read.TeleportList[item].MapName; fs.X_position = Read.TeleportList[item].X_position; fs.Y_position = Read.TeleportList[item].Y_position; fs.Z_position = Read.TeleportList[item].Z_position; Read.TeleportList.Add(fs); TeleportsGrid.Rows.Add(Read.TeleportAmount, TeleportsGrid.Rows[item].Cells[1].Value, TeleportsGrid.Rows[item].Cells[2].Value); } TeleportsGrid.ScrollBars = ScrollBars.Vertical; var RowsClone = SelectedRowIndexes; TeleportsGrid.CurrentCell = TeleportsGrid.Rows[TeleportsGrid.Rows.Count - 1].Cells[1]; for (int i = 1; i <= RowsClone.Count; i++) { TeleportsGrid.Rows[TeleportsGrid.Rows.Count - i].Selected = true; } TeleportsGrid_CurrentCellChanged(null, null); } }
public void ReadSevFile(BinaryReader br) { TeleportList = new List <FileStructure>(); TeleportAmount = br.ReadInt32(); for (int i = 0; i < TeleportAmount; i++) { FileStructure fs = new FileStructure(); fs.ID = br.ReadInt32(); fs.MapId = br.ReadInt32(); fs.X_position = br.ReadSingle(); fs.Y_position = br.ReadSingle(); fs.Z_position = br.ReadSingle(); fs.GroupId = br.ReadInt32(); TeleportList.Add(fs); } br.Close(); }