Exemplo n.º 1
0
        private void LoadFile(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }
            var package = LoadPackageFromChunk(path);

            // window title
            _currentPackage    = package;
            _currentRenderTree = RenderTree.Create(package);
            PopulateTreeView(package, _currentRenderTree);
            viewOutput.Init(Path.Combine(Path.GetDirectoryName(path) ?? "", "textures"));
            Render();

            Text = package.Name;
        }
Exemplo n.º 2
0
        private static int RunApplication(Options options)
        {
            if (!File.Exists(options.InputFile))
            {
                Console.Error.WriteLine("File not found: {0}", options.InputFile);
                return(1);
            }

            var package = LoadPackageFromChunk(options.InputFile);

            PackageDumper.DumpPackage(package);

            var outputFile = options.OutputFile;

            if (!string.IsNullOrWhiteSpace(outputFile))
            {
                var renderer = new ImageRenderTreeRenderer();
                renderer.LoadTextures(options.TextureDir);
                var img = renderer.Render(RenderTree.Create(package));
                using var fs = File.OpenWrite(outputFile);
                img.SaveAsPng(fs);

                if (!options.NoOpen)
                {
                    Process.Start(new ProcessStartInfo(outputFile)
                    {
                        UseShellExecute = true
                    });
                }
            }

            //Console.WriteLine(JsonConvert.SerializeObject(package, Formatting.Indented, new JsonSerializerSettings()
            //{
            //    TypeNameHandling = TypeNameHandling.Auto,
            //    PreserveReferencesHandling = PreserveReferencesHandling.Objects,
            //    Converters =
            //    {
            //        new StringEnumConverter(new DefaultNamingStrategy())
            //    }
            //}));

            return(0);
        }