private void allItemsInColorPaletteToolStripMenuItem_Click(object sender, EventArgs e) { var mats = Materials.List.Where(x => x.IsEnabled); var map = new int[10, 1 + (mats.Count() / 10)]; BlueprintPA print = new BlueprintPA() { MaxDepth = 1, }; SchemFormatter.writeBlueprint("./io.schem", print); }
private void dlgSave_FileOk(object sender, CancelEventArgs e) { if (this.LoadedBlueprint != null) { SaveFileDialog dlg = (SaveFileDialog)sender; string fName = dlg.FileName; int chosenFilterIndex = dlg.FilterIndex; if (fName.ToLower().EndsWith(".schem")) { SchemFormatter.writeBlueprint(fName, this.LoadedBlueprint); } else if (fName.ToLower().EndsWith(".schematic")) { SchematicFormatter.writeBlueprint(fName, this.LoadedBlueprint); } else if (fName.ToLower().EndsWith(".png")) { if (this.renderedImagePanel != null) { this.renderedImagePanel.SaveToPNG(fName); } } else if (fName.ToLower().EndsWith(".csv")) { Dictionary <Material, int> materialCounts = new Dictionary <Material, int>(); bool isv = Options.Get.IsSideView; int xM = this.LoadedBlueprint.Mapper.GetXLength(isv); int yM = this.LoadedBlueprint.Mapper.GetYLength(isv); int zM = this.LoadedBlueprint.Mapper.GetZLength(isv); for (int x = 0; x < xM; x++) { for (int y = 0; y < yM; y++) { for (int z = 0; z < zM; z++) { Material m = this.LoadedBlueprint.Mapper.GetMaterialAt(isv, x, y, z); if (m != Materials.Air) { if (!materialCounts.ContainsKey(m)) { materialCounts.Add(m, 0); } materialCounts[m] = materialCounts[m] + 1; } } } } StringBuilder sb = new StringBuilder(); sb.AppendLine("\"Material\",\"Block Count\",\"Full Stacks needed\""); sb.AppendLine("\"Total\"," + materialCounts.Values.Sum()); foreach (var kvp in materialCounts.OrderByDescending(x => x.Value)) { sb.AppendLine($"\"{kvp.Key.GetBlockNameAndData(isv).Replace("\"", "\"\"")}\",{kvp.Value},{kvp.Value / 64} stacks and {kvp.Value % 64} remaining blocks"); } File.WriteAllText(fName, sb.ToString()); } } else { this.exportSchematicToolStripMenuItem.Enabled = false; } }