예제 #1
0
        /// <summary>
        /// The ArgumentOutOfRangeException check is now done at driver level in PCSpeaker - is it still needed here?
        /// </summary>
        /// <param name="aFrequency"></param>
        /// <param name="aDuration"></param>
        public static void Beep(int aFrequency, int aDuration)
        {
            if (aFrequency < 37 || aFrequency > 32767)
            {
                throw new ArgumentOutOfRangeException("Frequency must be between 37 and 32767Hz");
            }

            if (aDuration <= 0)
            {
                throw new ArgumentOutOfRangeException("Duration must be more than 0");
            }

            PCSpeaker.Beep((uint)aFrequency, (uint)aDuration);
        }
예제 #2
0
        protected override void BeforeRun()
        {
            CommandManager.RegisterAllCommands();
            //AConsole = new System.Shell.VGA.VGAConsole(null);
            Encoding.RegisterProvider(CosmosEncodingProvider.Instance);

            Console.InputEncoding  = Encoding.GetEncoding(437);
            Console.OutputEncoding = Encoding.GetEncoding(437);
            Console.Clear();
            enableFs = true;
            Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
            printLogoConsole();
            Console.Write("Detected Drives: ");
            Console.WriteLine(DriveInfo.GetDrives().Length);
            foreach (DriveInfo d in DriveInfo.GetDrives())
            {
                Console.WriteLine(" - " + d.Name + " (" + d.GetType() + ") " + (d.TotalSize / 1048576) + "MB");
            }
            WaitSeconds(5);

            PCSpeaker.Beep(850, 10);
            startupchecks();
        }
예제 #3
0
 /// <summary>
 /// Beep() is pure CIL
 /// Default implementation beeps for 200 milliseconds at 800 hertz
 /// In Cosmos, these are Cosmos.System.Duration.Default and Cosmos.System.Notes.Default respectively,
 /// and are used when there are no params
 /// https://docs.microsoft.com/en-us/dotnet/api/system.console.beep?view=netcore-2.0
 /// </summary>
 public static void Beep()
 {
     PCSpeaker.Beep();
 }
예제 #4
0
        public static String ReadLine()
        {
            var xConsole = GetConsole();

            if (xConsole == null)
            {
                // for now:
                return(null);
            }
            List <char> chars = new List <char>(32);
            KeyEvent    current;

            int currentCount = 0;

            bool firstdown = false;

            string CMDToComplete = "";

            while ((current = KeyboardManager.ReadKey()).Key != ConsoleKeyEx.Enter)
            {
                if (current.Key == ConsoleKeyEx.NumEnter)
                {
                    break;
                }
                //Check for "special" keys
                if (current.Key == ConsoleKeyEx.Backspace) // Backspace
                {
                    CMDToComplete = "";
                    if (currentCount > 0)
                    {
                        int curCharTemp = GetConsole().X;
                        chars.RemoveAt(currentCount - 1);
                        GetConsole().X = GetConsole().X - 1;

                        //Move characters to the left
                        for (int x = currentCount - 1; x < chars.Count; x++)
                        {
                            Write(chars[x]);
                        }

                        Write(' ');

                        GetConsole().X = curCharTemp - 1;

                        currentCount--;
                    }
                    else
                    {
                        PCSpeaker.Beep();
                    }
                    continue;
                }
                else if (current.Key == ConsoleKeyEx.LeftArrow)
                {
                    if (currentCount > 0)
                    {
                        GetConsole().X = GetConsole().X - 1;
                        currentCount--;
                    }
                    continue;
                }
                else if (current.Key == ConsoleKeyEx.RightArrow)
                {
                    if (currentCount < chars.Count)
                    {
                        GetConsole().X = GetConsole().X + 1;
                        currentCount++;
                    }
                    continue;
                }
                else if (current.Key == ConsoleKeyEx.Tab)
                {
                    if (currentCount >= 1)
                    {
                        int index = -1;

                        foreach (char ch in chars)
                        {
                            CMDToComplete = CMDToComplete + ch.ToString();
                        }

                        foreach (string c in CommandManager.CMDs)
                        {
                            index++;
                            if (c.StartsWith(CMDToComplete))
                            {
                                CommandsHistory.ClearCurrentConsoleLine();
                                currentCount = 0;
                                chars.Clear();

                                Uszka.Kernel.BeforeCommand();

                                foreach (char chr in c)
                                {
                                    chars.Add(chr);
                                    Write(chr);
                                    currentCount++;
                                }
                            }
                        }
                        continue;
                    }
                }
                else if (current.Key == ConsoleKeyEx.C && KeyboardManager.ControlPressed)
                {
                    CMDToComplete = "";
                    if (Uszka.Kernel.AConsole.writecommand)
                    {
                        CommandsHistory.ClearCurrentConsoleLine();
                        currentCount = 0;
                        chars.Clear();

                        Uszka.Kernel.BeforeCommand();
                    }
                }
                else if (current.Key == ConsoleKeyEx.UpArrow) //COMMAND HISTORY UP
                {
                    if (Uszka.Kernel.AConsole.writecommand)   //IF SHELL
                    {
                        CMDToComplete = "";
                        if (CommandsHistory.CHIndex >= 0)
                        {
                            CommandsHistory.ClearCurrentConsoleLine();
                            currentCount = 0;
                            chars.Clear();

                            Uszka.Kernel.BeforeCommand();

                            string Command = Uszka.Kernel.AConsole.commands[CommandsHistory.CHIndex];
                            CommandsHistory.CHIndex = CommandsHistory.CHIndex - 1;

                            foreach (char chr in Command)
                            {
                                if (currentCount == chars.Count)
                                {
                                    chars.Add(chr);
                                    Write(chr);
                                    currentCount++;
                                }
                                else
                                {
                                    //Insert the new character in the correct location
                                    //For some reason, List.Insert() doesn't work properly
                                    //so the character has to be inserted manually
                                    List <char> temp = new List <char>();

                                    for (int x = 0; x < chars.Count; x++)
                                    {
                                        if (x == currentCount)
                                        {
                                            temp.Add(chr);
                                        }

                                        temp.Add(chars[x]);
                                    }

                                    chars = temp;

                                    //Shift the characters to the right
                                    for (int x = currentCount; x < chars.Count; x++)
                                    {
                                        Write(chars[x]);
                                    }

                                    Uszka.Kernel.AConsole.X -= (chars.Count - currentCount) - 1;
                                    currentCount++;
                                }
                            }
                        }
                    }
                    continue;
                }
                else if (current.Key == ConsoleKeyEx.DownArrow) //COMMAND HISTORY UP
                {
                    if (Uszka.Kernel.AConsole.writecommand)     //IF SHELL
                    {
                        CMDToComplete = "";
                        if (CommandsHistory.CHIndex < Uszka.Kernel.AConsole.commands.Count - 1)
                        {
                            CommandsHistory.ClearCurrentConsoleLine();
                            currentCount = 0;
                            chars.Clear();

                            Uszka.Kernel.BeforeCommand();

                            CommandsHistory.CHIndex = CommandsHistory.CHIndex + 1;

                            if (!firstdown)
                            {
                                CommandsHistory.CHIndex = CommandsHistory.CHIndex + 1;
                                firstdown = true;
                            }

                            string Command = Uszka.Kernel.AConsole.commands[CommandsHistory.CHIndex];

                            foreach (char chr in Command)
                            {
                                if (currentCount == chars.Count)
                                {
                                    chars.Add(chr);
                                    Write(chr);
                                    currentCount++;
                                }
                                else
                                {
                                    //Insert the new character in the correct location
                                    //For some reason, List.Insert() doesn't work properly
                                    //so the character has to be inserted manually
                                    List <char> temp = new List <char>();

                                    for (int x = 0; x < chars.Count; x++)
                                    {
                                        if (x == currentCount)
                                        {
                                            temp.Add(chr);
                                        }

                                        temp.Add(chars[x]);
                                    }

                                    chars = temp;

                                    //Shift the characters to the right
                                    for (int x = currentCount; x < chars.Count; x++)
                                    {
                                        Write(chars[x]);
                                    }

                                    Uszka.Kernel.AConsole.X -= (chars.Count - currentCount) - 1;
                                    currentCount++;
                                }
                            }
                        }
                    }
                    continue;
                }

                if (current.KeyChar == '\0')
                {
                    continue;
                }

                //Write the character to the screen
                if (currentCount == chars.Count)
                {
                    chars.Add(current.KeyChar);
                    Write(current.KeyChar);
                    currentCount++;
                }
                else
                {
                    //Insert the new character in the correct location
                    //For some reason, List.Insert() doesn't work properly
                    //so the character has to be inserted manually
                    List <char> temp = new List <char>();

                    for (int x = 0; x < chars.Count; x++)
                    {
                        if (x == currentCount)
                        {
                            temp.Add(current.KeyChar);
                        }

                        temp.Add(chars[x]);
                    }

                    chars = temp;

                    //Shift the characters to the right
                    for (int x = currentCount; x < chars.Count; x++)
                    {
                        Write(chars[x]);
                    }

                    GetConsole().X -= (chars.Count - currentCount) - 1;
                    currentCount++;
                }
            }
            WriteLine();

            char[] final = chars.ToArray();
            return(new string(final));
        }