Ejemplo n.º 1
0
        public override int Run(string[] remainingArguments)
        {
            if (remainingArguments[0] != "-")
            {
                program = File.OpenRead(remainingArguments[0]);
            }

            using (StreamReader read = new StreamReader(program))
            {
                Brainfuck.Run(read.ReadToEnd());
            }

            return(0);
        }
Ejemplo n.º 2
0
        public override int Run(string[] remainingArguments)
        {
            if (remainingArguments[1] != "-")
            {
                input = File.OpenRead(remainingArguments[1]);
            }

            switch (remainingArguments[0])
            {
            case "brainfuck":
                using (StreamWriter sw = new StreamWriter(output))
                    sw.Write(Brainfuck.Encode(input));
                return(0);

            case "brainloller":
                if (width == 0)
                {
                    throw new ConsoleHelpAsException("Width is a required option when encoding with Brainloller.");
                }
                using (StreamReader reader = new StreamReader(input))
                {
                    string code   = reader.ReadToEnd();
                    Bitmap newBmp = Brainloller.Encode(code, width, Color.Firebrick);
                    newBmp.Save(output, System.Drawing.Imaging.ImageFormat.Png);
                }
                return(0);

            case "braincopter":
                if (orig_image == null)
                {
                    throw new ConsoleHelpAsException("Original image is required when encoding with Braincopter.");
                }
                using (StreamReader reader = new StreamReader(input))
                {
                    string code     = reader.ReadToEnd();
                    Bitmap original = new Bitmap(orig_image);
                    Bitmap newBmp   = Braincopter.Encode(original, code);
                    newBmp.Save(output, System.Drawing.Imaging.ImageFormat.Png);
                }
                return(0);

            default:
                throw new ConsoleHelpAsException("Unrecognized language.");
            }
        }