private async void btnDecompress_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.Filter = "TDAS Images. (.tdas) |*.tdas";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                BinaryFile file  = new BinaryFile();
                Stopwatch  watch = new Stopwatch();
                watch.Start();
                lblStatus.Text = "Decompressing Image...";
                await Task.Run(() => file.Read(openFileDialog1.FileName));

                watch.Stop();
                lblStatus.Text = "Decompression Completed.";
                string te = watch.Elapsed.ToString(@"m\:ss");
                lblTimeTaken.Visible = true;
                lblTimeTaken.Text    = te;
                ImageMatrix          = file.Image;
                ImageHeight          = file.ImageHeight;
                ImageWidth           = file.ImageWidth;
                InitialSeed          = file.InitialSeed;
                TapPosition          = file.TapPosition;
                ImageOperations.DisplayImage(ImageMatrix, pictureBox1);
                txtHeight.Text = file.ImageHeight.ToString();
                txtWidth.Text  = file.ImageWidth.ToString();
                string tmp = Convert.ToString(file.InitialSeed, 2);
                txtInitialSeed.Text = tmp.PadLeft(file.NumberOfBits, '0');
                txtTapPosition.Text = file.TapPosition.ToString();
            }
        }
Beispiel #2
0
        public void SaveThenReadName()
        {
            var dummy = new DummySerializable {
                Value = 1
            };
            var file = this.directory.CreateFileInfoInDirectory("dummy.json");

            BinaryFile.Save(file.Name, dummy);
            var read = BinaryFile.Read <DummySerializable>(file.Name);

            Assert.AreNotSame(dummy, read);
            Assert.AreEqual(dummy.Value, read.Value);
        }
Beispiel #3
0
        static BitmapFont FromBinaryStream(string filePath)
        {
            var stream = AssetManager.GetStream(filePath, ".fnt");

            if (stream != null)
            {
                using (stream)
                {
                    var directory = Path.GetDirectoryName(filePath);
                    return(BinaryFile.Read(stream, directory));
                }
            }

            return(null);
        }
Beispiel #4
0
        private HierarchicalDataContext LoadCached(string cacheFile, string fileName)
        {
            var builder = new HierarchicalDataBuilder();

            //var cacheFile = "d:\\data.bin";
            if (File.Exists(cacheFile))
            {
                var file = new BinaryFile <HierarchicalData>();
                var data = file.Read(cacheFile);
                return(new HierarchicalDataContext(data));
            }
            else
            {
                var context = builder.CreateHierarchyFromFilesystem(fileName, true);
                var file    = new BinaryFile <HierarchicalData>();
                file.Write(cacheFile, context.Data);
                return(context);
            }
        }
        private static void AssertLayouting(string path, double width, double height)
        {
            var layout  = new CirclePackingLayout();
            var binFile = new BinaryFile <HierarchicalData>();
            var data    = binFile.Read(path);

            // Includes layout info
            var reference = data.Dump();

            Assert.IsTrue(File.Exists(path));

            var clone = (HierarchicalData)data.Clone();

            // Clone does not copy the layout.
            layout.Layout(clone, width, height);
            var result = clone.Dump();

            Assert.AreEqual(reference, result);
        }
        public BinaryDataTabViewModel(string header, string binaryFilePath, BinaryDataTemplate template)
            : base(header)
        {
            this.template = template;

            this.BinaryFilePath = binaryFilePath;

            ShowHexDump = AppSettings.Instance.GetConfigValue_Bool(AppSettings.Key_ShowHexDump);

            if (template != null)
            {
                BinaryFile = new BinaryFile(binaryFilePath, template);
                BinaryFile.Read();
            }
            else
            {
                // TODO!
            }
        }
        public VoxelSystemScene(string savePath)
        {
            _planetPath = Path.Join(savePath, "planet");
            _playerPath = Path.Join(savePath, "player");
            SavePath    = savePath;
            var assets = G.Assets;

            Planet = new Planet(64, 20);
            if (File.Exists(_planetPath))
            {
                BinaryFile.Read(_planetPath, Planet);
                _chunkProducer = VoxelChunkProducer.Bind();
            }
            else
            {
                var terrainGenerator = new PlanetTerrainGenerator();
                terrainGenerator.MaxHeight = 16;
                terrainGenerator.Grass     = assets.GetAsset <VoxelType>("core:grass");
                terrainGenerator.Stone     = assets.GetAsset <VoxelType>("core:stone");
                terrainGenerator.Dirt      = assets.GetAsset <VoxelType>("core:dirt");
                _chunkProducer             = terrainGenerator;
            }
            _lightCalculator = new VoxelVolumeLightCalculator();
            _meshGenerator   = new VoxelVolumeMeshGenerator();

            // player
            var center = new Point(G.Game.Window.ClientBounds.Width / 2, G.Game.Window.ClientBounds.Height / 2);
            var pos    = new Vector3(0, Planet.Radius + 16, 0);

            Player = new PlayerEntity(pos, new MouseLook(center));
            var types = new List <VoxelType>();

            types.Add(assets.GetAsset <VoxelType>("core:grass"));
            types.Add(assets.GetAsset <VoxelType>("core:stone"));
            types.Add(assets.GetAsset <VoxelType>("core:dirt"));
            types.Add(assets.GetAsset <VoxelType>("core:glow"));
            types.Add(assets.GetAsset <VoxelType>("core:leaves"));
            types.Add(assets.GetAsset <VoxelType>("core:log"));
            Player.PlaceableVoxelTypes = types;

            if (File.Exists(_playerPath))
            {
                BinaryFile.Read(_playerPath, Player);
            }
            Player.Freeze();

            _chunkProducer.Start(Planet.Volume);
            _lightCalculator.Start(_chunkProducer);
            _meshGenerator.Start(_lightCalculator);

            _meshGenerator.OnComplete += Player.UnFreeze;

            // new VoxelVolumeMeshUpdater(GraphicsDevice).RegisterCallbacks(planet.volume);
            SunDirection = Vector3.Down;
            Planet.StartThreads();

            // _ui.Input.MakeActive();
            Player.Input.MakeActive();
            Player.SetPlanet(Planet);
            AddObject(Player);
            SunDirection = -new Vector3(1, 2, 3);
        }
Beispiel #8
0
 protected override T Read <T>(FileInfo file)
 {
     return(BinaryFile.Read <T>(file));
 }