Esempio n. 1
0
        /// <summary>
        /// Process console input sent while script was running.
        /// </summary>
        public static void ProcessConsoleInput()
        {
            if (Native.API.IsKeyDown(Native.VirtualKeyCode.PAUSE))
            {
                Scripter.Stop();
            }

            if (ConsoleInputQueue.Count > 0)
            {
                try
                {
                    ConsoleInputQueue.ForEach(x =>
                    {
                        Scripter.Environment.DoString(x);
                    });

                    ConsoleInputQueue.Clear();
                }
                catch (SyntaxErrorException exception)
                {
                    WriteLine(new ColorContainer(177, 31, 41), $"Syntax Error: {exception.Message}");
                }
                catch (ScriptRuntimeException exception)
                {
                    WriteLine(new ColorContainer(177, 31, 41), $"Runtime Error: {exception.Message}");
                }
                catch (Exception exception)
                {
                    WriteLine(new ColorContainer(177, 31, 41), $"Error: {exception.Message}");
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes object-based enumerations, loads fonts, opens user interface etc. basically anything that has to be done once the program starts.
        /// </summary>
        public static void Initialize()
        {
            Fonts.AddFontFile($@"{Application.StartupPath}\Data\Fonts\OfficeCodePro-Medium.ttf");

            InterfaceThread = new Thread(() =>
            {
                Application.EnableVisualStyles();

                MainWindow = new Window();
                MainWindow.ShowDialog();
            })
            {
                Name = "Interface Thread"
            };
            InterfaceThread.Start();

            Scripter.Initialize();
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes object-based enumerations, loads fonts, opens user interface etc. basically anything that has to be done once the program starts.
        /// </summary>
        public static void Initialize()
        {
            var Info = JsonConvert.DeserializeObject <Dictionary <string, string> >(File.ReadAllText("info.json"));

            Version = Info["Version"];

            Fonts.AddFontFile($@"{Application.StartupPath}\Data\Fonts\OfficeCodePro-Medium.ttf");

            InterfaceThread = new Thread(() =>
            {
                Application.EnableVisualStyles();

                MainWindow = new Window();
                MainWindow.ShowDialog();
            })
            {
                Name = "Interface Thread"
            };
            InterfaceThread.Start();

            Scripter.Initialize();
        }
Esempio n. 4
0
        /// <summary>
        /// Execute a package at specified entry point (defined inside info.json).
        /// </summary>
        /// <param name="silent">Defines whether console shouldn't output the executed code.</param>
        public void Run(bool silent = true)
        {
            var info = GetInfo();

            Scripter.Execute(ReadFileContents(info["EntryPoint"]), silent);
        }