static Module AskUserAndLoadModule(Module M) { ModuleStartPromptForm F = null; foreach (ModuleStartPromptForm PF in PromptWindows) { if (M.Name.Equals(PF.DisplayedModule.Name)) { F = PF; } } if (F == null) { F = new ModuleStartPromptForm(); lock (PromptWindows) { PromptWindows.Add(F); } F.SetModule(M); F.ShowDialog(); } else { F.Activate(); return(null); } if (F.ModuleAuthroized) { return(Module.Get(M.Name)); } else { return(null); } }
internal static ModuleStartPromptForm RemovePromptWindowFromList(Module M) { ModuleStartPromptForm PF = null; lock (PromptWindows) { int RemoveAt = -1; for (int i = 0; i < PromptWindows.Count; i++) { if (M.Name.Equals(PromptWindows[i].DisplayedModule.Name)) { RemoveAt = i; PF = PromptWindows[i]; break; } } if (RemoveAt > -1) { PromptWindows.RemoveAt(RemoveAt); } } return(PF); }
static Module AskUserAndLoadModule(Module M) { ModuleStartPromptForm F = null; foreach (ModuleStartPromptForm PF in PromptWindows) { if (M.Name.Equals(PF.DisplayedModule.Name)) F = PF; } if (F == null) { F = new ModuleStartPromptForm(); lock (PromptWindows) { PromptWindows.Add(F); } F.SetModule(M); F.ShowDialog(); } else { F.Activate(); return null; } if (F.ModuleAuthroized) { return Module.Get(M.Name); } else { return null; } }
internal static Module LoadModule(Module M) { try { string FullName = string.Format("{0}\\modules\\{1}\\{2}", Config.RootDir, M.Name, M.FileName); if (M.FileName.EndsWith(".dll")) { Assembly MA = System.Reflection.Assembly.LoadFile(FullName); Module NewModule = (Module)Activator.CreateInstance(MA.GetTypes()[0]); Module.Add(NewModule.GetInstance()); } else { Engine = PluginEngine.GetScriptEngine(); if (M.FileName.EndsWith(".py")) { Engine.Runtime.TryGetEngine("py", out Engine); } else { Engine.Runtime.TryGetEngine("rb", out Engine); } List <string> ModulePaths = new List <string>(); foreach (Module ModuleFromXml in ModuleListFromXml) { ModulePaths.Add(string.Format("{0}\\modules\\{1}\\", Config.RootDir, ModuleFromXml.Name)); } Engine.SetSearchPaths(ModulePaths); if (M.FileName.Length == 0) { throw new Exception("Module is missing script files"); } ScriptSource ModuleSource = Engine.CreateScriptSourceFromFile(FullName); ScriptErrorReporter CompileErrors = new ScriptErrorReporter(); string ErrorMessage = ""; CompiledCode CompiledModule = ModuleSource.Compile(CompileErrors); ErrorMessage = CompileErrors.GetErrors(); if (M.FileName.EndsWith(".py")) { string IndentError = PluginEditor.CheckPythonIndentation(ModuleSource.GetCode())[1]; if (IndentError.Length > 0) { ErrorMessage = string.Format("{0}\r\n{1}", IndentError, ErrorMessage); } } if (ErrorMessage.Length == 0) { ModuleSource.ExecuteProgram(); } else { throw new Exception(string.Format("Syntax error in module file:{0}\r\n{1}", M.FileName, ErrorMessage)); } } } catch (Exception Exp) { ModuleStartPromptForm PF = GetPromptWindow(M); if (PF != null) { PF.ShowError("Error Loading Module."); } IronException.Report(string.Format("Error Loading Module - {0}", M.Name), Exp); return(null); } IronUI.BuildPluginTree(); ModuleStartPromptForm UsedPF = RemovePromptWindowFromList(M); if (UsedPF != null) { try { if (!UsedPF.IsClosed) { UsedPF.CloseForm(); } } catch { } } return(Get(M.Name)); }