public void Handle(string[] arguments, MainTerminal terminal)
        {
            switch (arguments[0])
            {
            case "terminal":
                new MainTerminal().Show();
                terminal.WriteToBuffer("Successfully Openned a new Terminal");
                terminal.FlushBuffer();
                //Close();

                break;

            case "irc":
                terminal.ChangeTextColour("yelow");
                terminal.WriteToBuffer("Error: IRChat is under development!");
                break;

            case "IRChat":
                terminal.ChangeTextColour("yelow");
                terminal.WriteToBuffer("Error: IRChat is under development!");
                break;

            default:
                terminal.ChangeTextColour("red");
                terminal.WriteToBuffer("Invalid Syntax: new <application>");
                return;
            }
        }
Пример #2
0
        public void Handle(string[] arguments, MainTerminal terminal)
        {
            if (arguments.Length < 1)
            {
                terminal.WriteToBuffer("Invalid syntax: connect <ip address>");
                terminal.FlushBuffer();
                return;
            }

            var gateway = NetworkHandler.GetGateway(arguments[0]);

            if (gateway != null)
            {
                terminal.WriteToBuffer("Connecting to IP Address  " + arguments[0] + "..>");
                terminal.FlushBuffer();
                terminal.ChangeTextColour("Green");
                terminal.WriteToBuffer("Successfully Connected to " + arguments[0]);
            }
            else
            {
                terminal.ChangeTextColour("red");
                terminal.WriteToBuffer("Connect: IPv4 address either not found or invalid");
            }

            terminal.WriteToBuffer("Under Development!");
            terminal.FlushBuffer();
        }
Пример #3
0
        private void SimpleAddToTerminal(string message)
        {
            MainTerminal.Document.Blocks.Add(new Paragraph(new Run(message)));
            MainTerminal.ScrollToEnd();

            while (MainTerminal.Document.Blocks.Count > 100)
            {
                MainTerminal.Document.Blocks.Remove(MainTerminal.Document.Blocks.FirstBlock);
            }
        }
Пример #4
0
 public void Handle(string[] arguments, MainTerminal terminal)
 {
     if (MainTerminal.DeveloperMode == true)
     {
         for (int i = 0; i < 40;)
         {
             terminal.WriteToBuffer("connect 192.168.1.6");
             terminal.FlushBuffer();
         }
         return;
     }
     else
     {
         return;
     }
 }
Пример #5
0
        public void Handle(string[] arguments, MainTerminal terminal)
        {
            if (arguments.Length < 3)
            {
                terminal.WriteToBuffer($"Invalid syntax: {_commandSyntax}");
                terminal.FlushBuffer();
                return;
            }

            if (!int.TryParse(arguments[1], out var portFrom))
            {
                terminal.ChangeTextColour("red");
                terminal.WriteToBuffer($"Invalid syntax: {_commandSyntax}");
                terminal.FlushBuffer();
                return;
            }

            if (!int.TryParse(arguments[2], out var portTo))
            {
                terminal.WriteToBuffer($"Invalid syntax: {_commandSyntax}");
                terminal.FlushBuffer();
                return;
            }

            var gateway = NetworkHandler.GetGateway(arguments[0]);

            if (gateway == null)
            {
                terminal.WriteToBuffer("Invalid syntax: connect <ip address>");
                terminal.FlushBuffer();
                return;
            }

            var openPorts = gateway.Devices.Where(x => x.Execuatbles.Any(exe => portFrom <= exe.NetworkInterfacePort && portTo >= exe.NetworkInterfacePort)).SelectMany(x => x.Execuatbles.Select(exe => exe.NetworkInterfacePort)).ToArray();

            /*var device = Devices;*/

            /*if (!int.TryParse(arguments[1], out portFrom))
             * {
             *  if (!int.TryParse(arguments[2], out portTo)) {
             *      for (var i = 0; i <= 65535; i++)
             *      {
             *          var portState = openPorts.Contains(i) ? "OPEN" : "CLOSED"; //short if staement. if(openports.Contains(i)) { portstate = "OPEN" } else { pertstate = "CLSOED" }
             *          terminal.WriteToBuffer($"Port {i} - {portState}");  //Sends Output as $"Port {i} - {portState}"
             *      }
             *  }
             * }*/

            //openPorts = gateway.Devices.Where(x => x.Execuatbles.Any(exe => portFrom <= exe.NetworkInterfacePort && portTo >= exe.NetworkInterfacePort)).SelectMany(x => x.Execuatbles.Select(exe => exe.NetworkInterfacePort)).ToArray();
            for (var i = portFrom; i <= portTo; i++)
            {
                var portState = openPorts.Contains(i) ? "OPEN" : "CLOSED";              //short if staement. if(openports.Contains(i)) { portstate = "OPEN" } else { pertstate = "CLSOED" }
                terminal.WriteToBuffer($"PORT   STATE   SERVICE \n {i} - {portState}"); //Sends Output as $"Port {i} - {portState}"
            }


            if (gateway != null)
            {
                terminal.WriteToBuffer("Connecting to IP Address  " + arguments[0] + "..>");
                terminal.FlushBuffer();
                terminal.ChangeTextColour("Green");
                terminal.WriteToBuffer("Successfully Connected to " + arguments[0]);
            }
            else
            {
                terminal.ChangeTextColour("red");
                terminal.WriteToBuffer("Connect: IPv4 address either not found or invalid");
            }


            terminal.FlushBuffer();
        }
Пример #6
0
 public void Handle(string[] arguments, MainTerminal terminal)
 {
     string args = arguments[1..^ 0].ToString();
Пример #7
0
        public void Handle(string[] arguments, MainTerminal terminal)
        {
            List <string> validMusicNames = new List <string> {
                "Silence", "Mr.C.Soldier - Silence.wav", "Silent Hack", "Silent Tool"
            };

            string[] musicName = { "silenthack", "silent", "silenttool" };
            Random   rnd       = new Random();
            int      index     = 0;

            string[] music =
            {
                Path.Combine(Directory.GetCurrentDirectory() + "\\..\\..\\..\\Audio\\Music", "Mr. C. Soldier - Silence.wav"),
                Path.Combine(Directory.GetCurrentDirectory() + "\\..\\..\\..\\Audio\\Music", "Mr. C. Soldier - Silent Hack.wav"),
                Path.Combine(Directory.GetCurrentDirectory() + "\\..\\..\\..\\Audio\\Music", "Mr. C. Soldier - Silent Tool.wav")
            };
            if (arguments[0] == "play")
            {
                if (Array.Exists(musicName, element => element == arguments[1].ToLower()))
                {
                    index = arguments[1] switch
                    {
                        "silence" => index    = 0,
                        "silenthack" => index = 1,
                        "silenttool" => index = 2
                    };
                    SoundPlayer currMusic = new SoundPlayer(music[index]);
                    currMusic.Play();
                }
                else
                {
                    index = rnd.Next();
                    SoundPlayer currMusic = new SoundPlayer(music[index]);
                    currMusic.Play();
                }
            }
            else if (arguments[0] == "stop")
            {
                SoundPlayer currMusic = new SoundPlayer(music[index]);
                if (arguments[1] == "all")
                {
                    currMusic.Dispose();
                }
            }

            else if (arguments[0] == "next")
            {
                index++;
                if (index == 3)
                {
                    index = 2;
                }
                SoundPlayer currMusic = new SoundPlayer(music[index]);
                currMusic.Play();
            }

            else if (arguments[0] == "previous" || arguments[0] == "prev")
            {
                SoundPlayer currMusic = new SoundPlayer(music[index]);
                index--;
                if (index == -1)
                {
                    index = 2;
                }
                else
                {
                    currMusic.Play();
                }
            }
        }
Пример #8
0
 public void Handle(string[] arguments, MainTerminal terminal)
 {
     //Environment.Exit(0);
     terminal.Close();
 }
Пример #9
0
 public void Handle(string[] arguments, MainTerminal terminal)
 {
     terminal.Clear();
 }
Пример #10
0
 public void Handle(MainTerminal terminal)
 {
     terminal.WriteToBuffer("bash: Command not found");
     terminal.FlushBuffer();
 }