private static void DrawDesktop(Mode mode) { try { Console.WriteLine("Initialising Mouse"); Graphics.MousePointer.InitMouse(mode); //Draw the desktop background API.DisplayDriver.DrawFilledRectangle(backgroundColor, new Cosmos.System.Graphics.Point(0, 0), mode.Columns, mode.Rows); /* A filled rectange */ //As the taskbar Console.WriteLine("Rendering Taskbar"); Graphics.Taskbar.RenderTaskbar(mode); //CreateWindow("Program Manager", 60, 30, 500, 400, aCanvas); manager.CreateWindow("Testing Window", 40, 40, 500, 500, API.DisplayDriver.aCanvas); Bitmap map = new Bitmap(three); API.DisplayDriver.aCanvas.DrawImage(map, 10, 10); while (true) { Run(); } } catch (Exception e) { CustomConsole.ErrorLog(e.ToString()); } }
public void LoadConfig() { string pathSave = Path.Combine(CommandExecutor.currentDirectory + "accounts.cfg"); if (API.FileExplorer.fileExists(pathSave)) { accounts = JsonConvert.DeserializeObject <List <account> >(pathSave); } else { CustomConsole.ErrorLog("Unable to find the config, please create a new one!"); } }
public void LoadApplications(string file) { try { //Load the application //Check if there is a .meta file if so then read it //string[] data = File.ReadAllLinesAsync(file + "/application.meta/"); } catch (Exception e) { CustomConsole.ErrorLog("Could not load application: Error: " + e); if (e.InnerException != null) { CustomConsole.ErrorLog("InnerException: " + e.InnerException.GetType() + " Message: " + e.InnerException.Message + " Stacktrace: " + e.InnerException.StackTrace); } } }
public static void StartApplication(string[] application) { //Run through the runtime and decide if the application needs to be run or not! foreach (string m in application) { //Check for application specific protocols CustomConsole.WarningLog("Initating Application Runtime..."); string[] args = m.Split(' '); for (int i = 0; i < args.Length; i++) { args[i] = args[i].ToLower(); } switch (args[0]) { case "if": //if condition bool exitLoop = false; for (int i = 1; i < args.Length; i++) { switch (args[i]) { case "stop": //Stop the program and start to read the program if (exitLoop != true) { //Continue and execute the program after args[4] if (args[4] == null || args[4] == " " || args[4] == "") { CustomConsole.WarningLog("umm you need to add a executing function after the if condition!!!"); } else { ExecuteCommand(args[4]); } } break; case "readInt": //Check if an int from the registry is equal to this!!!! if (args[1] == null || args[2] == null || args[3] == null || args[1] == " " || args[2] == " " || args[3] == " ") { CustomConsole.ErrorLog("Argument either 1-3 is empty please fill them up!"); } else { //Try to execute that read code bool adressExists = API.RegistryEditor.IntegerExists(args[1]); if (adressExists == true) { int adress = API.RegistryEditor.returnInteger(args[1]); if (args[2] != " " && args[2] == "equals") { string possibleinteger = args[3]; if (possibleinteger.Contains("0") || possibleinteger.Contains("1") || possibleinteger.Contains("2") || possibleinteger.Contains("3") || possibleinteger.Contains("4") || possibleinteger.Contains("5") || possibleinteger.Contains("6") || possibleinteger.Contains("7") || possibleinteger.Contains("8") || possibleinteger.Contains("9")) { int parsedPossibleInteger = int.Parse(possibleinteger); if (adress != parsedPossibleInteger) { exitLoop = true; } } else { CustomConsole.ErrorLog("Seems like that isnt an integer!!!"); } } else if (args[2] != " " && args[2] == "notequals") { string possibleinteger = args[3]; if (possibleinteger.Contains("0") || possibleinteger.Contains("1") || possibleinteger.Contains("2") || possibleinteger.Contains("3") || possibleinteger.Contains("4") || possibleinteger.Contains("5") || possibleinteger.Contains("6") || possibleinteger.Contains("7") || possibleinteger.Contains("8") || possibleinteger.Contains("9")) { int parsedPossibleInteger = int.Parse(possibleinteger); if (adress != parsedPossibleInteger) { exitLoop = true; } } else { CustomConsole.ErrorLog("Seems like that isnt an integer!!!"); } } else { CustomConsole.ErrorLog("Incorrect or wrong operation defined!!!!"); } } else { CustomConsole.ErrorLog("That adress doesnt exist!"); } } break; case "readString": //Check if an string from the registry is equal to this!!!! if (args[1] == null || args[2] == null || args[3] == null || args[1] == " " || args[2] == " " || args[3] == " ") { CustomConsole.ErrorLog("Argument either 1-3 is empty please fill them up!"); } else { //Try to execute that read code bool adressExists = API.RegistryEditor.StringExists(args[1]); if (adressExists == true) { string adress = API.RegistryEditor.returnString(args[1]); if (args[2] != " " && args[2] == "equals") { string possiblestring = args[3]; if (adress != possiblestring) { exitLoop = true; } } else if (args[2] != " " && args[2] == "notequals") { string possiblestring = args[3]; if (adress == possiblestring) { exitLoop = true; } } else { CustomConsole.ErrorLog("Incorrect or wrong operation defined!!!"); } } else { CustomConsole.ErrorLog("That adress doesnt exist!"); } } break; case "readFloat": //Check if an int from the registry is equal to this!!!! if (args[1] == null || args[2] == null || args[3] == null || args[1] == " " || args[2] == " " || args[3] == " ") { CustomConsole.ErrorLog("Argument either 1-3 is empty please fill them up!"); } else { //Try to execute that read code bool adressExists = API.RegistryEditor.FloatExists(args[1]); if (adressExists == true) { float adress = API.RegistryEditor.returnFloat(args[1]); if (args[2].ToLower() != " " && args[2].ToLower() == "equals") { string possibleinteger = args[3]; if (possibleinteger.Contains("0") || possibleinteger.Contains("1") || possibleinteger.Contains("2") || possibleinteger.Contains("3") || possibleinteger.Contains("4") || possibleinteger.Contains("5") || possibleinteger.Contains("6") || possibleinteger.Contains("7") || possibleinteger.Contains("8") || possibleinteger.Contains("9")) { float parsedPossibleInteger = float.Parse(possibleinteger); if (adress != parsedPossibleInteger) { exitLoop = true; } } } else if (args[2] != " " && args[2] == "notequals") { string possiblefloat = args[3]; if (possiblefloat.Contains("0") || possiblefloat.Contains("1") || possiblefloat.Contains("2") || possiblefloat.Contains("3") || possiblefloat.Contains("4") || possiblefloat.Contains("5") || possiblefloat.Contains("6") || possiblefloat.Contains("7") || possiblefloat.Contains("8") || possiblefloat.Contains("9")) { float parsedPossibleFLOAT = float.Parse(possiblefloat); if (adress == parsedPossibleFLOAT) { exitLoop = true; } } else { CustomConsole.ErrorLog("Seems like that isnt an integer!!!"); } } else { CustomConsole.ErrorLog("Seems like that isnt an integer!!!"); } } else { CustomConsole.ErrorLog("That adress doesnt exist!"); } } break; } if (exitLoop) { break; } } break; case "while": for (int i = 1; i < args.Length; i++) { bool exitLoopWhile = false; //while condition switch (args[i].ToLower()) { case "readint": //write to this etc string nextString = args[2]; bool integerExists = API.RegistryEditor.IntegerExists(nextString); if (integerExists == true) { //Continue and execute code string parseSymbol = args[3]; string parsedObject = args[4]; bool parsedObjectExisted = API.RegistryEditor.IntegerExists(parsedObject); if (parsedObjectExisted == true) { int newlyParsedObject = API.RegistryEditor.returnInteger(parsedObject); int nextStringParsed = API.RegistryEditor.returnInteger(nextString); switch (parseSymbol.ToLower()) { //Doesnt really matter if it is the lower invariant or not it still should work case "==": //Execute if the integer defined is equal to the parsing argument if (newlyParsedObject != nextStringParsed) { exitLoopWhile = true; } break; case "!=": //Same as the first but the complete opposite!!! if (newlyParsedObject == nextStringParsed) { exitLoopWhile = true; } break; } } else { CustomConsole.ErrorLog("The right side variable of the while loop doesnt exist!!!"); } } else { CustomConsole.ErrorLog("That integer doesnt exist in the registry!!!"); } break; case "readfloat": CustomConsole.WarningLog("Reading floats with while loops are not supported!!!"); break; case "readstring": CustomConsole.WarningLog("Reading strings with while loops are not supported!!!"); break; case "stop": CustomConsole.WarningLog("While loops are still in manufacturing and can not be operated yet sadly :(!!!"); break; } } break; } CustomConsole.SuccessLog("Finished executing application runtime..."); CustomConsole.WarningLog("Executing the command execution"); ExecuteCommand(m); } }
public static void InitTextMode(string command) { string[] args = command.ToLower().Split(' '); try { switch (args[0].ToLower()) { case "readreg": string VariableType = args[1]; switch (VariableType.ToLower()) { case "string": case "word": //Word find if (API.RegistryEditor.StringExists(args[2])) { CustomConsole.SuccessLog("The value for " + args[2] + " is " + API.RegistryEditor.returnString(args[2])); } else { CustomConsole.ErrorLog("That string either doesnt have a value or doesnt exist."); } break; case "integer": case "number": //Number find if (API.RegistryEditor.IntegerExists(args[2])) { CustomConsole.SuccessLog("The value for " + args[2] + " is " + API.RegistryEditor.returnString(args[2])); } else { CustomConsole.ErrorLog("That integer either doesnt have a value or doesnt exist."); } break; case "float": //Float find if (API.RegistryEditor.FloatExists(args[2])) { CustomConsole.SuccessLog("The value for " + args[2] + " is " + API.RegistryEditor.returnString(args[2])); } else { CustomConsole.ErrorLog("That integer either doesnt have a value or doesnt exist."); } break; } break; case "editreg": API.Commands.editreg regEdit = new API.Commands.editreg(); regEdit.Start(args); break; case "getinfo": Console.WriteLine("Directories: "); string[] pathsDirectories = API.FileExplorer.GetDirectories(currentDirectory); for (int i = 0; i < pathsDirectories.Length; i++) { Console.WriteLine(pathsDirectories[i]); } Console.WriteLine("Files: "); string[] pathsFiles = API.FileExplorer.GetFiles(currentDirectory); for (int m = 0; m < pathsFiles.Length; m++) { Console.WriteLine(pathsFiles[m]); } break; case "changedirectory": case "cd": try { if (args[1] != "" || args[1] != null) { if (API.FileExplorer.DirectoryExists(args[1]) != false) { currentDirectory = args[1]; } else { CustomConsole.ErrorLog("Seems like that this isnt a directory"); currentDirectory = "0:\\"; } } else if (args[1] == "" || args[1] == null) { currentDirectory = "0:\\"; } else { currentDirectory = "0:\\"; } } catch (Exception e) { CustomConsole.ErrorLog("" + e); currentDirectory = "0:\\"; } break; case "getdir": case "getd": Console.WriteLine("Directories: "); string[] pathsDirectoriesM = API.FileExplorer.GetDirectories(currentDirectory); for (int i = 0; i < pathsDirectoriesM.Length; i++) { Console.WriteLine(pathsDirectoriesM[i]); } break; case "getfiles": case "getf": case "gfiles": Console.WriteLine("Files: "); string[] pathsFilesM = API.FileExplorer.GetFiles(currentDirectory); for (int m = 0; m < pathsFilesM.Length; m++) { Console.WriteLine(pathsFilesM[m]); } break; case "createdir": case "cdir": //string[] argsSplit = command.ToLower().Split(' '); API.FileExplorer.CreateDirectory(currentDirectory + args[1]); break; case "rmdir": case "removedir": API.FileExplorer.DeleteDirectory(currentDirectory + args[1]); break; case "createfile": case "cfile": case "cf": API.FileExplorer.CreateFile(currentDirectory + args[1]); break; case "rmfile": case "deletefile": API.FileExplorer.DeleteFile(currentDirectory + args[1]); break; case "readText": string[] files = API.FileExplorer.ReadTextArray(currentDirectory + args[1]); foreach (string m in files) { Console.WriteLine(m); } break; case "ping": ping.Run(command); break; case "power": switch (args[1].ToLower()) { case "shutdown": case "powerdown": Cosmos.System.Power.Shutdown(); break; case "restart": case "reboot": Cosmos.System.Power.Reboot(); break; default: CustomConsole.ErrorLog("No Power State was defined!"); break; } break; case "cgsinit": case "initgraphics": case "initg": case "cgs": switch (args[1].ToLower()) { case "launch": Desktop.InitGraphics(); break; case "drawfilledsquare": //API.DisplayDriver.DrawFilledRectangle(Color.FromName(args[2].ToLower()), int.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), int.Parse(args[6])); CustomConsole.WarningLog("Drawing a filled square is not a supported function yet..."); break; case "clear": //API.DisplayDriver.Clear(Color.FromName(args[2].ToLower())); CustomConsole.WarningLog("Clear is not a supported function yet."); break; default: CustomConsole.ErrorLog("No Cosmos Graphics System Launch Paremeter was defined!"); break; } break; case "echo": case "message": string message = string.Join(' ', args); message = message.Replace(args[0].ToLower(), " "); Console.WriteLine(string.Join(' ', args)); break; case "cls": case "clear": Console.Clear(); break; case "repeat": if (args[1] != "") { try { int parse = int.Parse(args[1]); for (int i = 0; i < parse; i++) { if (args[2] != "") { InitTextMode(args[2]); } else { //No command is defined CustomConsole.ErrorLog("Unable to execute... no command defined!"); } } } catch (Exception e) { CustomConsole.ErrorLog(e.Message); //Error occured try to execute the first parameter InitTextMode(args[1]); } } else { CustomConsole.ErrorLog("no count is defined!"); } break; default: CustomConsole.ErrorLog("unknown command"); break; case "loop": if (args[1] != "") { try { if (args[2] != null) { while (true) { InitTextMode(args[2]); } } }catch (Exception e) { CustomConsole.ErrorLog(e.Message); } } break; } //Just for shits and giggles lets let the user run a command from the runtime //Convert the string command to an array to run on the command executor string[] fakeProgram = { command }; ApplicationRuntime.StartApplication(fakeProgram); ExecuteCommand(); } catch (Exception e) { CustomConsole.ErrorLog(e.ToString()); ExecuteCommand(); } }