Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     openFileDialog1.ShowDialog();
     if (!openFileDialog1.SafeFileName.Contains(".py"))
     {
         return;
     }
     if (!ScriptNames.Contains(openFileDialog1.SafeFileName))
     {
         var file   = openFileDialog1.FileName;
         var engine = new Scripting_Engine(openFileDialog1.SafeFileName);
         setupVars(engine);
         var scriptloaded = engine.loadScriptFromFile(file);
         allScripts.Add(engine);
         engine.runScript(scriptloaded);
         string desc = engine.getDescription();
         ScriptNames.Add(openFileDialog1.SafeFileName);
         Console.WriteLine(openFileDialog1.SafeFileName + " was succesfully loaded");
         var stringBuilder = "Selected Scripts:\n";
         foreach (var name in ScriptNames)
         {
             stringBuilder += name + ": " + desc + "\n";
         }
         label1.Text = stringBuilder;
     }
     else
     {
         MessageBox.Show("Script already loaded!");
     }
 }
Exemplo n.º 2
0
 private void setupVars(Scripting_Engine PyEngine)
 {
     PyEngine.addVar("MessageBox", new Action <string>(ShowMessageBox));
     PyEngine.addVar("user", user);
     PyEngine.addVar("sendMessage", new Action <string, string>(Core.sendMessage));
     PyEngine.addVar("sendMessageToChat", new Action <Chat, string>(Core.sendMessageToChat));
     PyEngine.addVar("log", new Action <string>(PyEngine.logSkript));
     PyEngine.addVar("setStatus", new Action <string>(Core.setStatus));
     PyEngine.addVar("isInCall", new Func <bool>(Core.isInCall));
     PyEngine.addVar("acceptCall", new Action <Call>(Core.acceptCall));
     PyEngine.addVar("declineCall", new Action <Call>(Core.declineCall));
 }