Ejemplo n.º 1
0
        // FIXME: This method keeps submitting the last entered values from the form
        // each time the page is refreshed.
        public void OnPostGenerate(int rows, int columns, Algorithm algorithm, Format format)
        {
            Grid       grid             = new Grid(new Point(columns, rows));
            IAlgorithm linkingAlgorithm = AlgorithmFactory.GetAlgorithm(algorithm, grid);

            linkingAlgorithm.Apply();

            DisplayFormat = format;

            switch (format)
            {
            case Format.Ascii:
                Maze += grid.ToString();
                break;

            case Format.Png:
                grid.ToPng();
                // FIXME: Need an expert on serving static files in ASP.NET Core to help me get this image source to work.
                ImageSource = @"~/StaticFiles/maze.png";
                break;

            default:
                // REVIEW: What would be better here is displaying a flash message at the GUI.
                throw new ArgumentException("Given format does not match a known enum.");
            }
        }