Exemplo n.º 1
0
        public void InitSuperglobals()
        {
            FileVersionInfo CoreVersion = ShellCore.GetVersion();
            FileVersionInfo Version     = GetVersion();

            ShxmlInitVariable("ShellUIVer", $"{Version.FileMajorPart}.{Version.FileMinorPart}.{Version.FileBuildPart}.{Version.FilePrivatePart}");
            ShxmlInitVariable("ShellCoreVer", $"{CoreVersion.FileMajorPart}.{CoreVersion.FileMinorPart}.{CoreVersion.FileBuildPart}.{CoreVersion.FilePrivatePart}");
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            ShellTest     ShellTest = new ShellTest();
            ShellCore     ShellCore = new ShellCore();
            ShellUI       ShellUI   = new ShellUI(); // initalize shellui
            List <double> arguments = new List <double> {
                4, 3
            };                                                  // v5.5+


            FileVersionInfo shellcore_ver = ShellCore.GetVersion();

            if (shellcore_ver.ProductMajorPart < 8) // version check
            {
                ShellTest.SorryIncompatible();
            }
            else if (shellcore_ver.ProductMajorPart < 8 & shellcore_ver.ProductBuildPart < 87)
            {
                ShellTest.SorryIncompatible();
            }

            ShellCore.InitShellCore();
            ShellCore.ElmInitExceptionManager();
            Console.Title = "Shell Test Application";
            Console.WriteLine("This is an automated testing application designed for testing Shell. This will bring up standard Windows dialogs and create registry keys to verify the functionality of the Shell DLLs. Press enter to continue.");
            Console.ReadKey();


            // V2+, last modified v7.0 build 24 iirc
            double        result   = ShellCore.BaseMath(ShellCore.BaseMathOperation.Add, 1, arguments);
            double        result2  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Subtract, 1, arguments);
            double        result3  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Divide, 1, arguments);
            double        result4  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Multiply, 1, arguments);
            double        result5  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Modulus, 1, arguments);
            double        result6  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Sqrt, 1, arguments);
            double        result7  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Sin, 1, arguments);
            double        result8  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Cos, 1, arguments);
            double        result9  = ShellCore.BaseMath(ShellCore.BaseMathOperation.Tan, 1, arguments);
            double        result10 = ShellCore.BaseMath(ShellCore.BaseMathOperation.Asin, 1, arguments);
            double        result11 = ShellCore.BaseMath(ShellCore.BaseMathOperation.Acos, 1, arguments);
            double        result12 = ShellCore.BaseMath(ShellCore.BaseMathOperation.Atan, 1, arguments);
            double        result13 = ShellCore.Power(4, 3);
            List <double> result14 = ShellCore.Ratio(6, 4, 3); // v7+

            Console.WriteLine($"Basic Math arg 0 result: {result}");
            Console.WriteLine($"Basic Math arg 1 result: {result2}");
            Console.WriteLine($"Basic Math arg 2 result: {result3}");
            Console.WriteLine($"Basic Math arg 3 result: {result4}");
            Console.WriteLine($"Basic Math arg 4 result: {result5}");
            Console.WriteLine($"Basic Math arg 5 result: {result6}");
            Console.WriteLine($"Basic Math arg 6 result: {result7}");
            Console.WriteLine($"Basic Math arg 7 result: {result8}");
            Console.WriteLine($"Basic Math arg 8 result: {result9}");
            Console.WriteLine($"Basic Math arg 9 result: {result10}");
            Console.WriteLine($"Basic Math arg 10 result: {result11}");
            Console.WriteLine($"Basic Math arg 11 result: {result12}");
            Console.WriteLine($"Power result: {result13}");
            Console.WriteLine($"Ratio result: {result14[0]}, {result14[1]}");

            ShellCore.WinMsgBox("Shell", "This is a message box!");                                                                // v6+
            string openResult = ShellCore.WinOpenDialog("ShellCore Version 6 open dialog", ".txt", "Text documents (.txt)|*.txt"); // v6+

            if (openResult == null)
            {
                Console.WriteLine("No file selected.");
            }
            else
            {
                Console.WriteLine(openResult);
            }

            string saveResult = ShellCore.WinSaveDialog("ShellCore Version 6 save dialog", ".txt", "Text documents (.txt)|*.txt"); // v6+

            if (saveResult == null)
            {
                Console.WriteLine("No file selected.");
            }

            ShellCore.ShlBeep(1000, 400);
            ShellCore.CreateFileEx("dummy.tmp");
            ShellCore.CopyFileEx("dummy.tmp", "dummy2.tmp");
            ShellCore.MoveFileEx("dummy2.tmp", "dummy3.tmp");
            ShellCore.CreateFileEx("dummy4.tmp");
            ShellCore.CreateFolderEx("TestFolder");  // v0.8.7x+
            ShellCore.SetFileHiddenEx("dummy4.tmp"); // v7+
            Console.WriteLine("Now testing ShellUI...");
            ShellUI.UiDrawMultiple('T', 8);
            ShellUI.UiDrawBlankSpace(16);
            ShellUI.UiSetConsoleColour(ConsoleColor.Black, ConsoleColor.White);
            ShellUI.UiSetWindowSize(25, 10);
            ShellUI.UiSetWindowSize(100, 63);
            ShellUI.UiSetCursorPosition(24, 24);
            ShellUI.UiSetCursorSize(5);
            ShellCore.WinPlaySound("tada.wav"); // v8.0.50+
            ShellUI.UiSetWindowTitle("ddddddddddddddddddddddddd");
            Console.WriteLine("Now testing ShellCore ExceptionsLite");

            ShellCore.ShlWriteLog("ShellLog.txt", "This is a test");                           // v6+
            ShellCore.ShlCloseLog();                                                           // v6+
            ShellCore.WinCreateRegKey(RegistryHive.CurrentUser, "ShellTest");                  // v7+
            ShellCore.WinCreateRegKey(RegistryHive.CurrentUser, "ShellTest2");                 // v7+
            RegistryKey Reg = ShellCore.WinOpenRegKey(RegistryHive.CurrentUser, "ShellTest");  // v7+

            ShellCore.WinSetRegValue(Reg, "Test", "TestThis");                                 // v7+
            ShellCore.WinSetRegValue(Reg, "Test3", "This");                                    // v7+
            ShellCore.WinDeleteRegValue(Reg, "Test3");                                         // v7+
            ShellCore.WinDeleteRegKey(RegistryHive.CurrentUser, "ShellTest2");                 // v7+
            ShellCore.DownloadFileEx("http://shell.x10.mx/dummy.txt", "dummy2.txt");           // v8.0.62+
            ShellCore.ElmRegisterExceptionP("ErrorTestException", 3001, "This is a test.", 0); // v4+
            ShellCore.ElmRegisterExceptionP("ErrorTestException", 3002, "This is a test.", 1); // v4+
            ShellCore.ElmRegisterExceptionP("ErrorTestException", 3003, "This is a test.", 2); // v4+

            ShellCore.ElmThrowException(3001);                                                 // v4+
            ShellCore.ElmThrowException(3002);                                                 // v4+
            ShellCore.ElmThrowException(3003);                                                 // v4+

            XmlDocument XmlTest = ShellCore.XmlCreateFile("Test.xml");                         // v8.0.8x+

            XmlTest = ShellCore.XmlAddNode(XmlTest, "ShellCoreXMLServicesTest", "test");
            ShellCore.XmlSaveFile(XmlTest, "Test.xml");

            // clean up

            Console.WriteLine("Testing complete. If it didn't crash or display any exceptions (excluding the test exceptions triggered, #3001, 3002, and 3003), that means it's all good. Press enter to exit.");
            Console.ReadKey();

            ShellCore.DeleteFileEx("dummy.tmp");    // v4+
            ShellCore.DeleteFileEx("dummy2.tmp");   // v4+
            ShellCore.DeleteFileEx("dummy2.txt");   // v4+
            ShellCore.DeleteFileEx("dummy3.tmp");   // v4+
            ShellCore.DeleteFileEx("dummy4.tmp");   // v4+
            ShellCore.DeleteFolderEx("TestFolder"); // v8.0.7x+
            ShellCore.DeleteFileEx("Test.xml");     // v4/v8.0.94+
            Environment.Exit(0xD15EA5E);
        }
Exemplo n.º 3
0
        internal bool?Init(string[] args)  // initalizes the shell
        {
            ShellCore   = new ShellCore();
            ShellUI     = new ShellUI();
            ShellModule = new ShellModule();
            ShellCore.InitShellCore();
            ShellCore.CheckCompatibility();
            ShellCore.ElmInitExceptionManager();
            ShellCore.ShlWriteLog("Test.txt", "test.");
            ShellUI.InitShellUI();
            ShellModule.InitShellModule(ShellCore);
            ShellTask ShlTask = ShellCore.InitTask(new string[0], "task 1", 400, 150);

            ShlTask.Run();
            ShellTask ShlTask2 = ShellCore.InitTask(new string[0], "task 3", 360, 200);

            ShlTask2.Run();

            Console.Clear(); // so we can do stuff


            ShellCore.ShlHandleCmdArguments(args); // universal arguments (config - user name...)
            // SHELL MAIN ARGUMENTS
            string arg2 = "";

            if (args.Length > 0)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string thearg = args[i];
                    if (args.Length - i > 0)
                    {
                        arg2 = args[i + 1];
                    }
                    switch (thearg)
                    {
                    default:
                        ShellUI.ShXML.XmlParseScript(args[0]);
                        Console.WriteLine("Script has completed. Press enter to exit.");
                        Console.ReadKey();
                        ShellCore.Exit(0);
                        return(null);

                    case "installmodule":
                        ShellModule.InstallModule(false, arg2);
                        Console.WriteLine("Module successfully installed. Press any key to exit Shell.");
                        Console.ReadKey();
                        return(true);
                    }
                }
            }

            if (ShellCore == null || ShellUI == null)
            {
                return(null);
            }

            Console.WriteLine("Welcome to Shell\n");
            Console.WriteLine("Shell Embedded GUI Platform, version 8.0 alpha\n");

            Console.WriteLine("DLL Versions:");

            FileVersionInfo shellcore_ver   = ShellCore.GetVersion();
            FileVersionInfo shellui_ver     = ShellUI.GetVersion();
            FileVersionInfo shellmodule_ver = ShellModule.GetVersion();

            ShellCore.ShlSetWindowTitle($"Shell - core ver {shellcore_ver.FileMajorPart}.{shellcore_ver.FileMinorPart}.{shellcore_ver.FileBuildPart}.{shellcore_ver.FilePrivatePart}.");

            Console.WriteLine($"ShellCore Version: {shellcore_ver.FileMajorPart}.{shellcore_ver.FileMinorPart}.{shellcore_ver.FileBuildPart}.{shellcore_ver.FilePrivatePart}");
            Console.WriteLine($"ShellUI Version: {shellui_ver.FileMajorPart}.{shellui_ver.FileMinorPart}.{shellui_ver.FileBuildPart}.{shellui_ver.FilePrivatePart}\n");
            Console.WriteLine($"ShellModule Version: {shellmodule_ver.FileMajorPart}.{shellmodule_ver.FileMinorPart}.{shellmodule_ver.FileBuildPart}.{shellmodule_ver.FilePrivatePart}\n");

            ShellUI.ShXML.XmlParseScript("Whatsyourname.xml");

            Console.WriteLine("DEBUG: Variables created");

            foreach (ShxmlVariable ShxmlVar in ShellUI.ShXML.Varlist)
            {
                switch (ShxmlVar.Type)
                {
                case 0:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varint}. Type = Int.");
                    continue;

                case 1:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varstring}. Type = String.");
                    continue;

                case 2:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varchar}. Type = Char.");
                    continue;

                case 3:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.vardouble}. Type = Double.");
                    continue;

                case 4:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varfloat}. Type = Float.");
                    continue;

                case 5:
                    Console.WriteLine($"Variable: Name = {ShxmlVar.Name}. Value = {ShxmlVar.varbool}. Type = Boolean.");
                    continue;
                }
            }

            Console.ReadKey();
            return(true);
        }