Exemple #1
0
        public void KeyPress(ref string[] Document, int X, int Y, ConsoleKeyInfo Key)
        {
            switch (Key.Key)
            {
            case ConsoleKey.PageUp:
                //Move up in the color wheel
                CurrentColorWheelPosition++;
                break;

            case ConsoleKey.PageDown:
                //Move down in the color wheel
                CurrentColorWheelPosition--;
                break;

            case ConsoleKey.K:
                //Pick Color
                CurrentColorWheelPosition = ColorWheel.IndexOf(Document[Y][X]);
                break;

            case ConsoleKey.Spacebar:
                //Replace the text at that position
                StringBuilder TempString = new StringBuilder(Document[Y]);
                TempString[X] = ColorWheel[CurrentColorWheelPosition];
                Document[Y]   = TempString.ToString();
                BasicGraphic.DrawColorString(ColorWheel[CurrentColorWheelPosition] + "");
                break;

            default:
                return;
            }

            Render(ref Document, true);
        }
Exemple #2
0
        /// <summary>Draws the screen</summary>
        public void Render()
        {
            try {
                if (Console.WindowWidth < 80 || Console.WindowHeight < 25)
                {
                    DialogBox.ShowDialogBox(WindowElements.Icon.IconType.EXCLAMATION, DialogBox.DialogBoxButtons.OK, "Unable to show STOP error. Window too small. Error Dialog Box to be shown instead.");
                    DialogBox.ShowExceptionError(E);
                    return;
                }

                //Minimum width is like 40x20
                //30x15 + STOP

                RenderUtils.Color(ConsoleColor.Black, ConsoleColor.White);

                //Draw a box
                Draw.Box(ConsoleColor.Black, Console.WindowWidth, Console.WindowHeight - 4, 0, 2);

                //Draw the stop sign
                BasicGraphic StopSign = BasicGraphic.LoadFromResource(Properties.Resources.Stop);
                StopSign.Draw(1, 3);

                //Draw STOP!
                BasicFont.DefaultFont.DrawText("STOP", StopSign.GetWidth() + 2, 3, ConsoleColor.White);

                //Render Text
                Draw.Sprite("An unhandled exception has caused this program to crash.", ConsoleColor.Black, ConsoleColor.White, StopSign.GetWidth() + 2, 9);
                Draw.Sprite(E.Message, ConsoleColor.Black, ConsoleColor.White, 1, StopSign.GetHeight() + 3);

                //Render the Exception Stack Trace
                string StackTrace = E.StackTrace;
                if (Stripped)
                {
                    StackTrace = DialogBox.StrippedStackTrace(E);
                }
                Draw.Sprite(FormattedText.Format(StackTrace, Console.WindowWidth - 1, Console.WindowHeight - 4 - StopSign.GetHeight() - 6).Replace("\n", "\n "), ConsoleColor.Black, ConsoleColor.White, 0, StopSign.GetHeight() + 5);

                //Draw writing.
                Draw.CenterText("Writing to disk", Console.WindowHeight - 4, ConsoleColor.Black, ConsoleColor.Red);

                File.AppendAllText("Errors.log", "\nERROR ON [" + DateTime.Now + "] " + E.Message + ": \n\n" + E.StackTrace);


                //Draw the last bit of text
                Draw.CenterText("Press a key to attempt to continue execution, or CTRL+C to close this program", Console.WindowHeight - 4, ConsoleColor.Black, ConsoleColor.Red);

                //Pause
                RenderUtils.Pause();

                //Draw a box again to clear
                Draw.Box(ConsoleColor.Black, Console.WindowWidth, Console.WindowHeight - 4, 0, 2);
            } catch (Exception F) {
                DialogBox.ShowDialogBox(WindowElements.Icon.IconType.EXCLAMATION, DialogBox.DialogBoxButtons.OK, "There was an error rendering the error, the following exception is the original error");
                DialogBox.ShowExceptionError(E);
                DialogBox.ShowDialogBox(WindowElements.Icon.IconType.EXCLAMATION, DialogBox.DialogBoxButtons.OK, "The following error occurred when rendering STOP");
                DialogBox.ShowExceptionError(F);
            }
        }
Exemple #3
0
            public override KeyPressReturn Action()
            {
                //Launch the showcase

                RenderUtils.Color(ConsoleColor.Black, ConsoleColor.Gray);
                Console.Clear();

                RenderUtils.Echo("Hello!", true);
                RenderUtils.Sleep(3000);

                RenderUtils.Type("...", 500);
                RenderUtils.Sleep(2000);

                RenderUtils.Type("Hello?\n", 30);
                RenderUtils.Sleep(1000);

                RenderUtils.Echo("It is cloudy: \n\n", true);
                new Cloud().Draw(Console.CursorLeft, Console.CursorTop);
                RenderUtils.Sleep(3000);

                RenderUtils.Type("\n\nCool I didn't care\n", 30);
                RenderUtils.Sleep(1000);

                Draw.Sprite("H o w   d a r e   y o u", ConsoleColor.Black, ConsoleColor.Red);
                RenderUtils.Sleep(5000);

                Console.Clear();
                RenderUtils.Sleep(3000);

                Graphic Landscape = BasicGraphic.LoadFromResource(Resources.Landscape);

                Landscape.Draw(0, 0);
                RenderUtils.Sleep(5000);

                Graphic TextBox = HiColorGraphic.LoadFromResource(Resources.Textbox);

                TextBox.Draw(Landscape.GetWidth() - TextBox.GetWidth() - 2, 2);

                RenderUtils.Color(ConsoleColor.Gray, ConsoleColor.Black);
                RenderUtils.SetPos(Landscape.GetWidth() - TextBox.GetWidth() - 2 + 6, 2);
                RenderUtils.Type("And so the man died.");
                RenderUtils.Sleep(3000);

                RenderUtils.SetPos(Landscape.GetWidth() - TextBox.GetWidth() - 2 + 6, 3);
                RenderUtils.Type("  t h e      e n d  ", 100);
                RenderUtils.Sleep(5000);

                RenderUtils.Color(ConsoleColor.DarkCyan, ConsoleColor.White);
                Console.Clear();
                Parent.Redraw();
                return(KeyPressReturn.NOTHING);
            }
Exemple #4
0
        public void Render(ref String[] Document, Boolean Partial)
        {
            //Draw the stored graphic
            if (!Partial)
            {
                int X = 1;
                foreach (String Line in Document)
                {
                    RenderUtils.SetPos(0, X);
                    BasicGraphic.DrawColorString(Line);
                    X++;
                }
            }

            //Draw the color wheel
            RenderUtils.SetPos(Console.WindowWidth - ColorWheel.Length - 2, Console.WindowHeight - 2);
            BasicGraphic.DrawColorString(ColorWheel);
            Draw.Row(ConsoleColor.Black, ColorWheel.Length, Console.WindowWidth - ColorWheel.Length - 2, Console.WindowHeight - 1);
            Draw.Block(ConsoleColor.Red, Console.WindowWidth - ColorWheel.Length - 2 + CurrentColorWheelPosition, Console.WindowHeight - 1);

            Draw.Sprite("Use PGUP/PGDOWN to change colors, K to pick color, and SPACE to draw.", ConsoleColor.Black, ConsoleColor.White, 0, Console.WindowHeight - 1);
        }
 public override void DrawPixel(string ColorString)
 {
     BasicGraphic.DrawColorString(ColorString);
 }
Exemple #6
0
        /// <summary>Starts a bouncy ball</summary>
        /// <param name="args"></param>
        public static void Main(string[] args)
        {
            BasicBall Ball = new BasicBall {
                XSpeed      = 3,
                BallGraphic = new BasicGraphic(squareball3x3, "SquareBall 3x3"),
                Bounciness  = 0.9,
                Gravity     = 0.5
            }; //default settings

            bool ShowInfo   = true;
            int  FPS        = 20;
            bool StopOnZero = false;

            string ErrorString = "";

            foreach (string arg in args)
            {
                try {
                    //split
                    string[] SplitArg = arg.Split('=');
                    if (SplitArg.Length < 2)
                    {
                        continue;
                    }

                    //Parse
                    switch (SplitArg[0].ToUpper())
                    {
                    case "/GRAPHIC":
                        if (SplitArg[1].ToUpper().EndsWith(".DF"))
                        {
                            Ball.BallGraphic = BasicGraphic.LoadFromFile(SplitArg[1]);
                        }
                        if (SplitArg[1].ToUpper().EndsWith(".HC"))
                        {
                            Ball.BallGraphic = HiColorGraphic.LoadFromFile(SplitArg[1]);
                        }
                        break;

                    case "/X":
                        Ball.X = double.Parse(SplitArg[1]);
                        break;

                    case "/Y":
                        Ball.Y = double.Parse(SplitArg[1]);
                        break;

                    case "/XSPEED":
                        Ball.XSpeed = double.Parse(SplitArg[1]);
                        break;

                    case "/YSPEED":
                        Ball.YSpeed = double.Parse(SplitArg[1]);
                        break;

                    case "/SPEED":
                        //ok Speed is going to be formatted like: VEL:ANG (IE: 10:30 is 10 speed units at 30 degrees up
                        string[] splitsplitarg = SplitArg[1].Split(':');

                        double Vel = double.Parse(splitsplitarg[0]);
                        double Ang = double.Parse(splitsplitarg[1]) * (Math.PI / 180);

                        Ball.XSpeed = Vel * Math.Cos(Ang);
                        Ball.YSpeed = -1 * Vel * Math.Sin(Ang);   //negative since positive is *down*

                        break;

                    case "/BOUNCE":
                    case "/BOUNCINESS":
                        Ball.Bounciness = double.Parse(SplitArg[1]);
                        break;

                    case "/GRAV":
                    case "/GRAVITY":
                        Ball.Gravity = double.Parse(SplitArg[1]);
                        break;

                    case "/FPS":
                        FPS = int.Parse(SplitArg[1]);
                        break;

                    case "/SHOWINFO":
                        ShowInfo = bool.Parse(SplitArg[1]);
                        break;

                    case "/STOPONZERO":
                        StopOnZero = bool.Parse(SplitArg[1]);
                        break;

                    default:
                        break;
                    }
                }
                catch (FormatException) { ErrorString += "\nCould not parse parameter for " + arg; }
                catch (FileNotFoundException) { ErrorString += "\nCould not find file for " + arg; }
                catch (IndexOutOfRangeException) { ErrorString += "\nNo Parameter for " + arg; }
            }

            if (!string.IsNullOrWhiteSpace(ErrorString))
            {
                RenderUtils.Echo("\nErrors occurred while parsing parameters:\n" + ErrorString + "\n\nPress CTRL+C to stop execution, or any other key to continue.");
                RenderUtils.Pause();
                Console.Clear();
            }

            BallRenderer(Ball, ShowInfo, FPS, StopOnZero);
        }