Пример #1
0
        private static void exportAllJpgButton_Click(List <IMapLayout <int> > generatedLayouts, string name = null)
        {
            WFLayoutDrawer <int> wfLayoutDrawer = new WFLayoutDrawer <int>();

            var time = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();

            if (generatedLayouts.Count == 0)
            {
                throw new ArgumentNullException("No generator layouts were produced");
            }
            var folder = $"Output/{time}_{name ?? generatedLayouts.First().Rooms.Count().ToString()}";
            int width  = 600;
            int height = 600;

            try
            {
                Directory.CreateDirectory(folder);

                for (var i = 0; i < generatedLayouts.Count; i++)
                {
                    Bitmap bitmap = wfLayoutDrawer.DrawLayout(generatedLayouts[i], width, height, true, null);

                    bitmap.Save($"{folder}/{name + "_" ?? ""}{i}.jpg");
                }
                File.WriteAllText(folder + "/benchmark.txt", $"Inference process took {netGenerationTime}s \n" +
                                  $"Generation process took {dunGenerationTime}s \n" +
                                  $"Total elapsed time :: {netGenerationTime + dunGenerationTime}s");

                if (enableUserInput)
                {
                    string output = new DirectoryInfo(folder).FullName;
                    MessageBox.Show($"Images were saved to {output} \n Press Ctrl + C to copy the directory", "Images saved", 0);
                    Console.Write("Press any key to exit...");
                    Console.ReadKey();
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine($"{e.Message} with: {e.Data} {e.StackTrace}");
            }
        }