示例#1
0
        private static void Save()
        {
            // save file
            string document = "";

            try
            {
                for (int i = 0; i < Lines.Count; i++)
                {
                    document += Lines[i] + "\n";
                }
                PMFAT.WriteAllText(CurrentFile, document);
                TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
                TextGraphics.DrawString(0, StartY, "Successfully saved \"" + CurrentFile + "\"", Color.Green, Color.Black);
            }
            catch (Exception ex)
            {
                TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
                TextGraphics.DrawString(0, StartY, "Unable to save file \"" + CurrentFile + "\"", Color.Red, Color.Black);
            }

            // finish
            Kernel.Delay(500);
            Draw();
        }
示例#2
0
 private void SetupScreen()
 {
     CLI.ForceClear(Color.Black);
     Shell.DrawTitleBar();
     TextGraphics.FillRect(2, 2, CLI.Width - 4, CLI.Height - 3, ' ', Color.White, Color.Blue);
     TextGraphics.DrawLineH(2, 2, CLI.Width - 4, ' ', Color.White, Color.Cyan);
     TextGraphics.DrawString(2, 2, " CMD                   DESCRIPTION", Color.Black, Color.Cyan);
     TextGraphics.DrawLineH(0, 3, CLI.Width, ' ', Color.White, Color.Black);
     TextGraphics.DrawString(Shell.TitleBarTime.Length, 0, " | Run \"help [cmd]\" for usage", Shell.TitleColor, Shell.TitleBarColor);
     CLI.SetCursorPos(2, 2);
 }
示例#3
0
        private static void Load()
        {
            // draw
            Draw();
            TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
            TextGraphics.DrawString(0, StartY, "FILENAME: ", Color.White, Color.Black);
            CLI.SetCursorPos(10, StartY);

            // get file
            string file = Console.ReadLine();

            // load file
            LoadFile(file);
        }
示例#4
0
        public static void LoadFile(string file)
        {
            // format filename
            if (!file.StartsWith(@"0:\"))
            {
                file = @"0:\" + file;
            }

            // load file
            bool error = false;

            if (PMFAT.FileExists(file))
            {
                try
                {
                    string[] lines = PMFAT.ReadLines(file);
                    Clear(false);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        Lines.Add(lines[i]);
                    }
                    TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
                    TextGraphics.DrawString(0, StartY, "Successfully loaded \"" + file + "\"", Color.Green, Color.Black);
                    error = false;
                }
                catch (Exception ex) { error = true; }
            }
            else
            {
                error = true;
            }

            if (error)
            {
                TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
                TextGraphics.DrawString(0, StartY, "Unable to load file \"" + file + "\"", Color.Red, Color.Black);
            }

            if (!error)
            {
                CurrentFile = file;
            }
            Kernel.Delay(500);
            Draw();
            ReadInput();
        }
示例#5
0
        private static void SaveAs()
        {
            // draw
            Draw();
            TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
            TextGraphics.DrawString(0, StartY, "FILENAME: ", Color.White, Color.Black);
            CLI.SetCursorPos(10, StartY);

            // get file
            string file = Console.ReadLine();

            // format filename
            if (!file.StartsWith(@"0:\"))
            {
                file = @"0:\" + file;
            }

            // save file
            string document = "";

            try
            {
                for (int i = 0; i < Lines.Count; i++)
                {
                    document += Lines[i] + "\n";
                }
                PMFAT.WriteAllText(file, document);
                TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
                TextGraphics.DrawString(0, StartY, "Successfully saved \"" + file + "\"", Color.Green, Color.Black);
            }
            catch (Exception ex)
            {
                TextGraphics.DrawLineH(0, StartY, Width, ' ', Color.White, Color.Black);
                TextGraphics.DrawString(0, StartY, "Unable to save file \"" + file + "\"", Color.Red, Color.Black);
            }

            // finish
            CurrentFile = file;
            Kernel.Delay(500);
            Draw();
        }
示例#6
0
        public override void Execute(string line, string[] args)
        {
            bool result = true;
            bool error  = false;

            if (args[1] == "0" || args[1].ToLower() == "false" || args[1].ToLower() == "no" || args[1].ToLower() == "off")
            {
                result = false;
            }
            else if (args[1] == "1" || args[1].ToLower() == "true" || args[1].ToLower() == "yes" || args[1].ToLower() == "on")
            {
                result = true;
            }
            else
            {
                CLI.Write("Invalid argument!", Color.Red); CLI.WriteLine("Usage: tbar (1,0) (true,false) (yes,no) (on,off) "); error = true;
            }

            if (!error)
            {
                Shell.TitleBarVisible = result;
                int oldX = CLI.CursorX, oldY = CLI.CursorY;
                SystemInfo.SaveConfig(PMFAT.ConfigFile);
                if (result)
                {
                    Shell.DrawTitleBar();
                    CLI.WriteLine("Title bar is now visible.");
                }
                else
                {
                    TextGraphics.DrawLineH(0, 0, CLI.Width, ' ', Color.Black, CLI.BackColor);
                    CLI.SetCursorPos(oldX, oldY);
                    CLI.WriteLine("Title bar hidden.");
                }
            }
        }
示例#7
0
 // draw title bar
 public static void DrawTitleBar()
 {
     TextGraphics.DrawLineH(0, 0, CLI.Width, ' ', Color.Black, TitleBarColor);                             // draw background
     DrawTime();                                                                                           // draw time
     TextGraphics.DrawString(CLI.Width - TitleBarText.Length, 0, TitleBarText, TitleColor, TitleBarColor); // draw title
 }
示例#8
0
        private void DrawMessage()
        {
            TextGraphics.DrawLineH(2, 2, CLI.Width - 4, ' ', Color.White, Color.Cyan);
            TextGraphics.DrawString(2, 2, " C    COLOR                  VALUE", Color.Black, Color.Cyan);
            TextGraphics.DrawLineH(0, 3, CLI.Width, ' ', Color.White, Color.Black);
            int   dx = 3, dy = 4;
            Color bg = Color.Black;

            // black
            TextGraphics.DrawChar(dx, dy, '#', Color.Black, bg);
            TextGraphics.DrawString(dx + 5, dy, "BLACK", Color.White, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Black, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // dark gray
            TextGraphics.DrawChar(dx, dy, '#', Color.DarkGray, bg);
            TextGraphics.DrawString(dx + 5, dy, "DARK GRAY", Color.DarkGray, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkGray, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // gray
            TextGraphics.DrawChar(dx, dy, '#', Color.Gray, bg);
            TextGraphics.DrawString(dx + 5, dy, "GRAY", Color.Gray, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Gray, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // white
            TextGraphics.DrawChar(dx, dy, '#', Color.White, bg);
            TextGraphics.DrawString(dx + 5, dy, "WHITE", Color.White, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.White, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // dark red
            TextGraphics.DrawChar(dx, dy, '#', Color.DarkRed, bg);
            TextGraphics.DrawString(dx + 5, dy, "DARK RED", Color.DarkRed, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkRed, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // red
            TextGraphics.DrawChar(dx, dy, '#', Color.Red, bg);
            TextGraphics.DrawString(dx + 5, dy, "RED", Color.Red, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Red, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // dark yellow
            TextGraphics.DrawChar(dx, dy, '#', Color.DarkYellow, bg);
            TextGraphics.DrawString(dx + 5, dy, "DARK YELLOW", Color.DarkYellow, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkYellow, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // yellow
            TextGraphics.DrawChar(dx, dy, '#', Color.Yellow, bg);
            TextGraphics.DrawString(dx + 5, dy, "YELLOW", Color.Yellow, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Yellow, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // dark green
            TextGraphics.DrawChar(dx, dy, '#', Color.DarkGreen, bg);
            TextGraphics.DrawString(dx + 5, dy, "DARK GREEN", Color.DarkGreen, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkGreen, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // green
            TextGraphics.DrawChar(dx, dy, '#', Color.Green, bg);
            TextGraphics.DrawString(dx + 5, dy, "GREEN", Color.Green, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Green, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // dark cyan
            TextGraphics.DrawChar(dx, dy, '#', Color.DarkCyan, bg);
            TextGraphics.DrawString(dx + 5, dy, "DARK CYAN", Color.DarkCyan, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkCyan, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // cyan
            TextGraphics.DrawChar(dx, dy, '#', Color.Cyan, bg);
            TextGraphics.DrawString(dx + 5, dy, "CYAN", Color.Cyan, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Cyan, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // dark blue
            TextGraphics.DrawChar(dx, dy, '#', Color.DarkBlue, bg);
            TextGraphics.DrawString(dx + 5, dy, "DARK BLUE", Color.Blue, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkBlue, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // blue
            TextGraphics.DrawChar(dx, dy, '#', Color.Blue, bg);;
            TextGraphics.DrawString(dx + 5, dy, "BLUE", Color.Blue, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Blue, "X2"), Color.Yellow, Color.Blue);;
            dy++;
            // dark magenta
            TextGraphics.DrawChar(dx, dy, '#', Color.DarkMagenta, bg);
            TextGraphics.DrawString(dx + 5, dy, "DARK MAGENTA", Color.DarkMagenta, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.DarkMagenta, "X2"), Color.Yellow, Color.Blue);
            dy++;
            // magenta
            TextGraphics.DrawChar(dx, dy, '#', Color.Magenta, bg);
            TextGraphics.DrawString(dx + 5, dy, "MAGENTA", Color.Magenta, Color.Blue);
            TextGraphics.DrawString(dx + 28, dy, DataUtils.IntToHex((int)Color.Magenta, "X2"), Color.Yellow, Color.Blue);
            dy++;

            // exit message
            TextGraphics.DrawString(2, CLI.Height - 2, "Press any key to exit...", Color.White, Color.Blue);
        }