From fb69cc80fc9e22549915f2a0905323f145e23374 Mon Sep 17 00:00:00 2001 From: TheEdgeNK Date: Sat, 1 Sep 2018 00:36:43 -0400 Subject: New terminal in the form of a console application --- PortEngine/PortEngine.csproj | 1 + PortEngine/PortsTerminalAPI.cs | 70 ++++++++++++++++++++++++++++++++ PortEngine/TerminalAPI.cs | 1 + PortsTerminal/App.config | 6 +++ PortsTerminal/PortsTerminal.csproj | 62 ++++++++++++++++++++++++++++ PortsTerminal/Program.cs | 26 ++++++++++++ PortsTerminal/Properties/AssemblyInfo.cs | 36 ++++++++++++++++ Project Ports.sln | 6 +++ 8 files changed, 208 insertions(+) create mode 100644 PortEngine/PortsTerminalAPI.cs create mode 100644 PortsTerminal/App.config create mode 100644 PortsTerminal/PortsTerminal.csproj create mode 100644 PortsTerminal/Program.cs create mode 100644 PortsTerminal/Properties/AssemblyInfo.cs diff --git a/PortEngine/PortEngine.csproj b/PortEngine/PortEngine.csproj index 544ab0e..1485897 100644 --- a/PortEngine/PortEngine.csproj +++ b/PortEngine/PortEngine.csproj @@ -50,6 +50,7 @@ EarnSite.cs + UserControl diff --git a/PortEngine/PortsTerminalAPI.cs b/PortEngine/PortsTerminalAPI.cs new file mode 100644 index 0000000..c751b85 --- /dev/null +++ b/PortEngine/PortsTerminalAPI.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PortEngine +{ + public class PortsTerminalAPI + { + public static void InitializeConsole() + { + AppendConsolePrefix(); + } + + public static void AppendConsolePrefix() + { + string ConsolePrefix = (Properties.Settings.Default.userDisplayName + "@PortOS:~$ "); + + Console.Write(ConsolePrefix); + } + + public static void RunCommand(String pendingCommand) + { + bool LastCommandWasClear = false; + + switch (pendingCommand) + { + case "help": + Console.WriteLine("help - lists the commands\r\ntest - displays a test message\r\nclear - clears the terminal\r\nchangeusername - changes your username for use with the Chatter application\r\n example: changeusername --TheBestUser" + Environment.NewLine); + + break; + case "clear": + Console.Clear(); + LastCommandWasClear = true; + + break; + case "test": + Console.WriteLine("This is a test!\r\nof the EBS!" + Environment.NewLine); + + break; + + default: + if (pendingCommand.StartsWith("changeusername --")) + { + Console.WriteLine("Username changed from " + Properties.Settings.Default.userDisplayName + " to " + pendingCommand.Substring(17)); + Properties.Settings.Default.userDisplayName = pendingCommand.Substring(17); + break; + } + else + { + Console.WriteLine("Syntax error. Reference the command list for commands that exist." + Environment.NewLine); + } + break; + } + + if (LastCommandWasClear == true) + { + LastCommandWasClear = false; + AppendConsolePrefix(); + } + else + { + Console.WriteLine(); + AppendConsolePrefix(); + } + } + } +} diff --git a/PortEngine/TerminalAPI.cs b/PortEngine/TerminalAPI.cs index 7724c48..d7ec2ba 100644 --- a/PortEngine/TerminalAPI.cs +++ b/PortEngine/TerminalAPI.cs @@ -1,6 +1,7 @@ /************************************************************************ * * PortEngine + * Deprecated Component - TerminalAPI * Copyright (C) 2018 UniverseDG * * This program is free software: you can redistribute it and/or modify diff --git a/PortsTerminal/App.config b/PortsTerminal/App.config new file mode 100644 index 0000000..bae5d6d --- /dev/null +++ b/PortsTerminal/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/PortsTerminal/PortsTerminal.csproj b/PortsTerminal/PortsTerminal.csproj new file mode 100644 index 0000000..0f9e69f --- /dev/null +++ b/PortsTerminal/PortsTerminal.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {51B19B80-B154-4EFE-B838-FEC598F9E6D9} + Exe + PortsTerminal + PortsTerminal + v4.6.1 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {c1b21b60-7ccc-42fc-83aa-b41644faa952} + PortEngine + + + {7ff89341-be42-4ae1-b53e-f9fa4104d30f} + Project Ports + + + + \ No newline at end of file diff --git a/PortsTerminal/Program.cs b/PortsTerminal/Program.cs new file mode 100644 index 0000000..6640c6c --- /dev/null +++ b/PortsTerminal/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PortEngine; + +namespace PortsTerminal +{ + class Program + { + static void Main(string[] args) + { + bool RunConsole = true; + PortsTerminalAPI.InitializeConsole(); + + while(RunConsole == true) + { + PortsTerminalAPI.RunCommand(Console.ReadLine()); + } + + + Console.ReadLine(); + } + } +} diff --git a/PortsTerminal/Properties/AssemblyInfo.cs b/PortsTerminal/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c530a10 --- /dev/null +++ b/PortsTerminal/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PortsTerminal")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PortsTerminal")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("51b19b80-b154-4efe-b838-fec598f9e6d9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Project Ports.sln b/Project Ports.sln index 97db25d..ff72833 100644 --- a/Project Ports.sln +++ b/Project Ports.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project Ports", "Project Po EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortEngine", "PortEngine\PortEngine.csproj", "{C1B21B60-7CCC-42FC-83AA-B41644FAA952}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PortsTerminal", "PortsTerminal\PortsTerminal.csproj", "{51B19B80-B154-4EFE-B838-FEC598F9E6D9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {C1B21B60-7CCC-42FC-83AA-B41644FAA952}.Debug|Any CPU.Build.0 = Debug|Any CPU {C1B21B60-7CCC-42FC-83AA-B41644FAA952}.Release|Any CPU.ActiveCfg = Release|Any CPU {C1B21B60-7CCC-42FC-83AA-B41644FAA952}.Release|Any CPU.Build.0 = Release|Any CPU + {51B19B80-B154-4EFE-B838-FEC598F9E6D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {51B19B80-B154-4EFE-B838-FEC598F9E6D9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {51B19B80-B154-4EFE-B838-FEC598F9E6D9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {51B19B80-B154-4EFE-B838-FEC598F9E6D9}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE -- cgit v1.2.3