private void pictureBox1_Paint(object sender, PaintEventArgs e) { var graphic = new MazeGraphic(e.Graphics); _visualizer.Draw(graphic, _maze.ViewData, _maze.UnitList); _maze.ProcessPlayerInNode(); }
public async Task <ActionResult> Generate(MazeGenerationOptions options) { Maze maze = this.mazeGenerator.Generate(options); MazeGraphic graphic = this.painter.Paint(maze, options); await this.mazeGraphicRepository.Create(graphic); return(this.File(graphic.Content, "image/jpeg")); }
public async Task GetByName() { string name = "1"; MazeGraphic mazeGraphic = await this.repository.GetByName(name); Assert.IsNotNull(mazeGraphic); Assert.AreEqual(0, mazeGraphic.Content.Length); Assert.AreEqual(name, mazeGraphic.Name); }
public async Task Update() { MazeGraphic graphic = new MazeGraphic { Content = Enumerable.Range(0, 50).Select(Convert.ToByte).ToArray(), Name = "test", GraphicType = "123" }; await this.repository.Update(graphic); }
public Task Delete(MazeGraphic item) { string fullPath = this.FindFullPathByName(item.Name); if (!string.IsNullOrEmpty(fullPath)) { System.IO.File.Delete(fullPath); } return(Task.FromResult(true)); }
public async Task <MazeGraphic> Create(MazeGraphic item) { string fullPath = string.Format("{0}/{1}.{2}", this.basePath, item.Name, this.extensionPicker.GetExtensionByType(item.GraphicType)); using (FileStream file = new FileStream(fullPath, FileMode.CreateNew, FileAccess.Write, FileShare.None)) { await file.WriteAsync(item.Content, 0, item.Content.Length); } return(item); }
public async Task <MazeGraphic> Update(MazeGraphic item) { string fullPath = this.FindFullPathByName(item.Name); if (string.IsNullOrEmpty(fullPath)) { return(null); } using (FileStream fileStream = new FileStream(fullPath, FileMode.Truncate, FileAccess.Write, FileShare.None)) { await fileStream.WriteAsync(item.Content, 0, item.Content.Length); } return(item); }