Exemplo n.º 1
0
        //-///////////////////////////////////////////////////////////////////////
        //-///////////////////////////////////////////////////////////////////////

        public pydoodleModule(ScriptEngine se, MainForm mainForm, List <SavedAttrValue> savedAttrValues)
        {
            _mainForm        = mainForm;
            _savedAttrValues = savedAttrValues;

            ScriptScope ss = Python.CreateModule(se, "pydoodle");

            ss.SetVariable("run", new Action <object>(this.run));
            ss.SetVariable("V2", DynamicHelpers.GetPythonTypeFromType(typeof(V2)));

            ss.SetVariable("line", new Action <V2, V2>(this.line));

            ss.SetVariable("circlearc", new Action <V2, float, float, float>(this.circlearc));
            ss.SetVariable("fcirclearc", new Action <V2, float, float, float>(this.fcirclearc));

            ss.SetVariable("ellipsearc", new Action <V2, float, float, float, float>(this.ellipsearc));
            ss.SetVariable("fellipsearc", new Action <V2, float, float, float, float>(this.fellipsearc));

            ss.SetVariable("circle", new Action <V2, float>(this.circle));
            ss.SetVariable("fcircle", new Action <V2, float>(this.fcircle));

            ss.SetVariable("ellipse", new Action <V2, float, float>(this.ellipse));
            ss.SetVariable("fellipse", new Action <V2, float, float>(this.fellipse));

            ss.SetVariable("box", new Action <V2, V2>(this.box));
            ss.SetVariable("fbox", new Action <V2, V2>(this.fbox));

            ss.SetVariable("text", new Action <V2, string>(this.text));

            ss.SetVariable("set_colour", new Action <Colour>(this.set_colour));

            ss.SetVariable("tweaks", new Action <Attr[]>(this.tweaks));

            ss.SetVariable("add_translate_handles", new Action <Attr[]>(this.add_translate_handles));
            ss.SetVariable("add_rotate_handles", new Action <Attr[]>(this.add_rotate_handles));

            //ss.SetVariable("TranslateHandle", DynamicHelpers.GetPythonTypeFromType(typeof(TranslateHandle)));
            ss.SetVariable("attr", new Func <object, string, Attr>(this.attr));
            ss.SetVariable("attrs", new attrsType(this.attrs));

            {
                PythonType colourType = DynamicHelpers.GetPythonTypeFromType(typeof(Colour));
                ss.SetVariable("Colour", colourType);
                ss.SetVariable("Color", colourType);
            }

            _operations = se.CreateOperations();

            _attrPool = new List <Attr>();
        }
Exemplo n.º 2
0
        static void try2(string[] args)
        {
            ScriptRuntime ironPythonRuntime = Python.CreateRuntime();
            ScriptEngine  engine            = IronPython.Hosting.Python.CreateEngine();
            ScriptScope   engineModule      = Python.CreateModule(engine, "testmodule", "try2.py");

            try
            {
                dynamic loadedPython = ironPythonRuntime.UseFile("try2.py");
                loadedPython.function0();

                loadedPython.ifn0();
                Console.WriteLine(loadedPython.ifn0.__doc__);

                Console.WriteLine(loadedPython.class1.__doc__);
                ;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
        }