Esempio n. 1
0
        private void buttonShowConsole_Click(object sender, EventArgs e)
        {
            var kntEngine = new KntSEngine(new InOutDeviceForm(), new MyLibrary());

            KntScriptConsoleForm f = new KntScriptConsoleForm(kntEngine);

            f.Show();
        }
Esempio n. 2
0
        public KntScriptConsoleForm(KntSEngine engine, string file = null)
        {
            InitializeComponent();
            PersonalizeTabStop();

            _engine         = engine;
            _sourceCodeFile = file;
        }
Esempio n. 3
0
        public void ShowKntScriptConsole()
        {
            var kntEngine = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(Store));

            var kntScriptCom = new KntScriptConsoleComponent(Store);

            kntScriptCom.KntSEngine = kntEngine;

            kntScriptCom.Run();
        }
Esempio n. 4
0
        public KntScriptConsoleForm(KntScriptConsoleComponent com) // , KntSEngine engine, string file = null
        {
            InitializeComponent();
            PersonalizeTabStop();

            _com = com;

            _engine         = _com.KntSEngine;
            _sourceCodeFile = _com.CodeFile;
        }
Esempio n. 5
0
    private void buttonRunSample_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(_selectedFile))
        {
            MessageBox.Show("File no seleted.");
            return;
        }

        var kntScript = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(_store));

        kntScript.RunFile(_pathSampleScripts + _selectedFile);
    }
Esempio n. 6
0
    private void buttonShowConsole_Click(object sender, EventArgs e)
    {
        var kntEngine = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(_store));

        var com = new KntScriptConsoleComponent(_store);

        com.KntSEngine = kntEngine;

        com.Run();
        //KntScriptConsoleForm f = new KntScriptConsoleForm(com);
        //f.Show();
    }
Esempio n. 7
0
        private void buttonShowSample_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_selectedFile))
            {
                MessageBox.Show("File no seleted.");
                return;
            }

            var kntEngine = new KntSEngine(new InOutDeviceForm(), new MyLibrary());

            KntScriptConsoleForm f = new KntScriptConsoleForm(kntEngine, _pathSampleScripts + _selectedFile);

            f.Show();
        }
Esempio n. 8
0
        private void buttonInteract_Click(object sender, EventArgs e)
        {
            //
            // Demo, inject variables and personalized api library
            //

            var kntScript = new KntSEngine(new InOutDeviceForm(), new MyLibrary());

            var a = new DocumentDummy();

            a.Description = "My object, to inject in script.";

            // inject variable
            kntScript.AddVar("_a", a);

            var code = @"printline ""Demo external variables / MyLibrary injected"";

                        ' This variable (_a) comes from the host application
                        printline _a.Description;
                        printline _a.IdDocument;
                        printline _a.CreationDateTime;
                        printline _a.Folder.Name;
                        _a.DocumentTestMethodA("" param A "");
                        var b = _a.DocumentTestMethodB("" == param C =="");
                        printline b;

                        ' Test MyLibrary (injected library)
                        printline """";
                        printline ""Test MyLibrary"";
                        var colec = ColecDocDemo();
                        foreach x in colec
                            printline x.Description;
                        end foreach;

                        printline """";
                        _a.Description = ""KntScript - changed description property !!"";                                                
                        printline _a.Description;
                        printline """";

                        printline ""<< end >>""; 
                        ";

            kntScript.Run(code);

            var b = (DocumentDummy)kntScript.GetVar("_a");  // -> a

            MessageBox.Show(a.Description + " <==> " + b.Description);
        }
Esempio n. 9
0
    private void buttonRunScript_Click(object sender, EventArgs e)
    {
        var kntScript = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(_store));

        kntScript.Run(@"
                        var i = 1;
                        var str = ""Hello world "";
                        for i = 1 to 10
                            printline str + i;
                        end for;                            
                        printline """";
                        str = ""(type text here ...) "";
                        readvar {""Example input str var:"": str };
                        printline str;
                        printline ""<< end >>"";                            
                    ");
    }
Esempio n. 10
0
    private void buttonShowSample_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(_selectedFile))
        {
            MessageBox.Show("File no seleted.");
            return;
        }

        var kntEngine = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(_store));

        var com = new KntScriptConsoleComponent(_store);

        com.KntSEngine = kntEngine;
        com.CodeFile   = Path.Combine(_pathSampleScripts, _selectedFile);

        com.Run();
        //KntScriptConsoleForm f = new KntScriptConsoleForm(com);
        //f.Show();
    }
Esempio n. 11
0
        public void RunScript(string code, bool newThread = true)
        {
            if (string.IsNullOrEmpty(code))
            {
                return;
            }

            var kntScript = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(this));

            if (newThread)
            {
                var t = new Thread(() => kntScript.Run(code));
                t.IsBackground = false;
                t.Start();
            }
            else
            {
                kntScript.Run(code);
            }
        }
Esempio n. 12
0
    private void buttonRunBackground_Click(object sender, EventArgs e)
    {
        var kntScript = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(_store));

        var code = @"
                    var i = 1;
                    var str = ""Hello world "";
                    for i = 1 to 1000
                        printline str + i;
                    end for;                            
                    printline ""<< end >>"";
                ";

        // --- Synchronous version
        // kntScript.Run(code);

        // --- Asynchronous version
        var t = new Thread(() => kntScript.Run(code));

        t.IsBackground = false;
        t.Start();
    }
Esempio n. 13
0
    private void buttonInteract_Click(object sender, EventArgs e)
    {
        //
        // Demo, inject variables and personalized api library
        //

        var kntScript = new KntSEngine(new InOutDeviceForm(), new KNoteScriptLibrary(_store));

        var a = new FolderDto();

        a.Name             = "My folder, to inject in script.";
        a.Tags             = "my tags";
        a.CreationDateTime = DateTime.Now;

        // inject variable
        kntScript.AddVar("_a", a);

        var code = @"printline ""Demo external variables / KNoteScriptLibrary injected"";

                    ' This variable (_a) comes from the host application
                    printline _a.Name;
                    printline _a.Tags;
                    printline _a.CreationDateTime;                        

                    _a.Name = ""KntScript - changed description property !!"";                                                
                    printline _a.Name;
                    printline """";

                    printline ""<< end >>""; 
                    ";

        kntScript.Run(code);

        var b = (FolderDto)kntScript.GetVar("_a");  // -> a

        MessageBox.Show(a.Name + " <==> " + b.Name);
    }