Beispiel #1
0
        public void MainThread(object coreInst)
        {
            core = (Core)coreInst;

            window         = core.RequestPlugin("ArkDesktop.LayeredWindow").CreateInstance("ArkDesktop.LayeredWindow") as LayeredWindow;
            manager        = core.RequestPlugin("ArkDesktop.LayeredWindowManager").CreateInstance("ArkDesktop.LayeredWindowManager") as LayeredWindowManager;
            manager.window = window;
            manager.config = core.config;
            manager.HelpPositionChange();
            manager.helpZoomChange    = true;
            configControl             = new ConfigControl();
            configControl.Dock        = DockStyle.Fill;
            configControl.makerParent = this;
            configControl.manager     = manager;
            core.AddControl("图片播放", configControl);

            if (core.config.GetElement(ns + "StaticPic") == null)
            {
                CreateConfig();
            }
            LoadConfig();
            while (!manager.Ready)
            {
                ;
            }

            if (core.config.GetElement(ns + "StaticPic").Element(ns + "LuaScript") != null)
            {
                LuaInterface.Lua lua    = new LuaInterface.Lua();
                LuaApi           luaApi = new LuaApi(this, lua);
                window.Click += (sender, e) => luaApi.OnClick();
                lua.DoString(core.config.GetElement(ns + "StaticPic").Element(ns + "LuaScript").Value);
            }
            else
            {
                while (!closed)
                {
                    int size = bitmaps.Count;
                    allowModify = size == 0;
                    for (int i = 0; i < size; ++i)
                    {
                        Thread.Sleep(1000 / frameTime);
                        if (needModify)
                        {
                            allowModify = true;
                            while (needModify)
                            {
                                ;
                            }
                            break;
                        }
                        manager.SetBits(bitmaps[i]);
                    }
                }
            }
            while (!manager.IsDisposed)
            {
                ;
            }
        }
Beispiel #2
0
        private void RunLua()
        {
            string cmd = "";

            object[] result;

            //MethodInfo info = methods.GetType().GetMethod("WriteEnum", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Instance, null, new Type[] { typeof(int) }, null);
            //lua.RegisterFunction("WriteEnum", methods, info);
            bool a = false;
            int  b = 5;

            while (cmd != "quit")
            {
                Console.Write(">");
                cmd = Console.ReadLine();
                try
                {
                    result = lua.DoString(cmd);
                    //lua.GetFunction("Out").Call(new object[] { a, b });
                    result = lua.GetFunction("Info").Call(new object[] {});
                    if (result != null)
                    {
                        foreach (object obj in result)
                        {
                            Logger.AddImportant("-" + obj.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.AddError(ex.ToString());
                }
            }
        }
Beispiel #3
0
        public void ExposeLibraries()
        {
            lua.NewTable("Console");
            lua.RegisterFunction("Console.Write", null, typeof(System.Console).GetMethod("Write", new Type[] { typeof(string) }));
            lua.RegisterFunction("Console.WriteLine", null, typeof(System.Console).GetMethod("WriteLine", new Type[] { typeof(string) }));

            lua.NewTable("Mouse");
            lua.RegisterFunction("Mouse.GetPos", null, typeof(LuaMouse).GetMethod("GetPos"));

            // Register GUI creation functions
            lua.RegisterFunction("_CreateFrame", null, typeof(LuaGUI).GetMethod("CreateFrame", new Type[] { }));
            lua.RegisterFunction("_CreateFrameAsChild", null, typeof(LuaGUI).GetMethod("CreateFrame", new Type[] { typeof(GUI.Frame) }));
            lua.RegisterFunction("_CreateButton", null, typeof(LuaGUI).GetMethod("CreateButton", new Type[] { }));
            lua.RegisterFunction("_CreateButtonAsChild", null, typeof(LuaGUI).GetMethod("CreateButton", new Type[] { typeof(GUI.Frame) }));
            lua.RegisterFunction("_CreateText", null, typeof(LuaGUI).GetMethod("CreateText", new Type[] { }));
            lua.RegisterFunction("_CreateTextAsChild", null, typeof(LuaGUI).GetMethod("CreateText", new Type[] { typeof(GUI.Frame) }));

            lua.NewTable("GUI");

            /*
             *	Because Lua can't dynamically call overloads of registered functions, a generic Lua function needs to do the decision making.
             *	This way we can also dynamically create different frame classes with the same function.
             */
            lua.DoString(@"
				CreateFrame = function(frameType, parent)
					frameType = string.lower(frameType):gsub('^%l', string.upper)
					if (parent == nil) then
						return _G['_Create' .. frameType]()
					else
						return _G['_Create' .. frameType .. 'AsChild'](parent)
					end
				end
			"            );
        }
 void DoLua()
 {
     using (LuaInterface.Lua lua = new LuaInterface.Lua())
     {
         lua.DoString("luanet.load_assembly('MyAssembly')");
         //... do what you want within Lua with MyAssembly
     }
 }
Beispiel #5
0
        } // func ExecuteScriptLoop

        private static long ExecuteLuaIntf(int i, string sScript)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            using (LuaInterface.Lua lua = new LuaInterface.Lua())
            {
                lua.RegisterFunction("test", null, typeof(Program).GetMethod("LuaTest"));
                lua.RegisterFunction("echo", null, typeof(Program).GetMethod("LuaEcho"));
                DebugOut("LuaIntf", i, lua.DoString(sScript, "test"));
            }
            return(sw.ElapsedMilliseconds);
        } // proc ExecuteLuaIntf
Beispiel #6
0
        public List <CTrigger> exec(string str, MapEditor mapEditor, bool IsTrigger)
        {
            this.IsTrigger = IsTrigger;

            str     = str.Replace("\\", "\\\\");
            mapData = mapEditor.mapdata;
            ParseToolInit();

            Triggers.Clear();
            try
            {
                Lua.DoString(str);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "TEP 컴파일 오류");
                return(null);
            }
            return(Triggers);
        }
Beispiel #7
0
    } // func ExecuteScriptLoop

    private static long ExecuteLuaIntf(int i, string sScript)
    {
      Stopwatch sw = new Stopwatch();
      sw.Start();
      using (LuaInterface.Lua lua = new LuaInterface.Lua())
      {
        lua.RegisterFunction("test", null, typeof(Program).GetMethod("LuaTest"));
        lua.RegisterFunction("echo", null, typeof(Program).GetMethod("LuaEcho"));
        DebugOut("LuaIntf", i, lua.DoString(sScript, "test"));
      }
      return sw.ElapsedMilliseconds;
    } // proc ExecuteLuaIntf
Beispiel #8
0
 /// <summary>
 /// This function is called by the preprocesor after the code has been compiled from the preprocessing template
 /// </summary>
 /// <param name="scriptCode">The string with the javascript code</param>
 /// <returns>True if sucess, false if failed </returns>
 public string Run(string scriptCode)
 {
     scriptEngine.DoString(scriptCode);
     return("");
 }
Beispiel #9
0
 public void OnClick(object par)
 {
     new System.Threading.Thread(() => lua.DoString("return Main();")).Start();
 }