Пример #1
0
 public void MainThread(ResourceManager resources, InstanceHelper instanceHelper)
 {
     resourceManager = resources;
     config          = resources.GetConfig(Name);
     if (EnsureConfigCorrect() == false)
     {
         resourceManager.SaveConfig(Name);
         resourceManager.SaveConfig("ArkDesktop.LayeredWindowManager");
         return;
     }
     ;
     manager = new LayeredWindowManager(resources);
     instanceHelper.AddControl("", manager);
     if (loadPosition == LoadPosition.InConfig)
     {
         if (config.Element("Script") == null)
         {
             MessageBox.Show("似乎没有加载到脚本,请联系配置包制作者");
             return;
         }
         luaScript = config.Element("Script").Value;
     }
     else
     {
         using (var sr = new System.IO.StreamReader(resourceManager.OpenRead("script.lua"))) luaScript = sr.ReadToEnd();
         if (luaScript == "")
         {
             MessageBox.Show("似乎没有加载到脚本,请联系配置包制作者", "QAQ");
             return;
         }
     }
     using (Lua lua = new Lua())
     {
         dynamic env   = lua.CreateEnvironment();
         LuaApi  api   = new LuaApi(this, lua, env);
         var     chunk = lua.CompileChunk(luaScript, "script.lua", new LuaCompileOptions {
             DebugEngine = LuaStackTraceDebugger.Default
         });
         manager.window.Click += (sender, e) => api.OnClick();
         var luaThread = new Thread(new ThreadStart(() =>
         {
             if (launchType == LaunchType.Positive)
             {
                 while (true)
                 {
                     try
                     {
                         env.dochunk(chunk);
                     }
                     catch (ThreadAbortException)
                     {
                         break;
                     }
                 }
                 catch (Exception e)
                 {
                     MessageBox.Show("发生异常:" + e.Message + "\n" + e.StackTrace);
                 }
             }
Пример #2
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;
            core.AddControl("渲染窗口", manager);

            if (EnsureConfigCorrect() == false)
            {
                return;
            }

            Lua    lua = new Lua();
            LuaApi api = new LuaApi(this, lua);

            window.Click += (sender, e) => api.OnClick();

            while (true)
            {
                if (launchType == LaunchType.Positive)
                {
                    try
                    {
                        lua.DoString(config.Element(ns + "LuaScript").Value);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("发生异常:" + e.Message + "\n" + e.StackTrace);
                    }
                }
                if (isDisposed)
                {
                    break;
                }
            }
        }