public override void Populate() { var txtFileLines = File.ReadAllLines(Install.GetPath("roof.txt")); var typeNames = txtFileLines[1].Split(Separators); TileCategory category = null; for (int i = 2; i < txtFileLines.Length; i++) { var infos = txtFileLines[i].Split('\t'); if (infos[1] == "0") { category = new TileCategory(Int32.Parse(infos[2])); category.Name = infos.Last(); Categories.Add(category); } var style = new TileStyle(); category.AddStyle(style); style.Name = infos.Last(); style.Index = Int32.Parse(infos[1]); for (int j = 3; j < typeNames.Length - 2; j++) { if (infos[j] != "0") { var tile = new TileRoof { Id = short.Parse(infos[j]) }; style.AddTile(tile); tile.ChangeRoofPosition(j-2); } } } }
private void ButtonAddTile_Click(object sender, RoutedEventArgs e) { var category = DataCategory.SelectedItem as TileCategory; var id = ListData.SelectedIndex; var style = DataStyle.SelectedItem as TileStyle; if(style == null) { style = new TileStyle(); category.AddStyle(style); } if (ComboEnum.SelectedItem == null) return; switch ((TilesInfo.Components.Enums.Type)ComboEnum.SelectedItem) { case Type.Wall: { var tile = new TileWall(); tile.Id = (short)id; style.AddTile(tile); break; } case Type.Roofs: { var tile = new TileRoof(); tile.Id = (short)id; style.AddTile(tile); break; } case Type.Floor: { var tile = new TileFloor(); tile.Id = (short)id; style.AddTile(tile); break; } case Type.Misc: { var tile = new TileMisc(); tile.Id = (short)id; style.AddTile(tile); break; } default: { var tile = new Tile(); tile.Id = (short)id; style.AddTile(tile); break; } } DataRefresh(); }