/// <summary> /// This routine loads a CLR script assembly from disk and creates an /// initial script object from it. /// </summary> /// <param name="ScriptFileName">Supplies the file name of the script /// assembly to load.</param> /// <param name="CallerScript">Supplies the script object owned by the /// caller.</param> /// <returns>The script object for the newly loaded script. On failure /// an exception is raised.</returns> public static IGeneratedScriptProgram LoadScriptFromDisk(string ScriptFileName, CLRScriptBase CallerScript) { AppDomain CurrentDomain = AppDomain.CurrentDomain; Assembly ScriptAsm; Type ScriptObjectType; IGeneratedScriptProgram ScriptObject; // // Load the target assembly up from disk in preparation for // instantiation. // byte[] FileContents = File.ReadAllBytes(ScriptFileName); // // Establish a temporary assembly resolve handler to handle the // reference to the interface assembly. // CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadScriptFromDisk_AssemblyResolve); try { ScriptAsm = CurrentDomain.Load(FileContents); // // Locate the script object type and create an instance of the // script object. // ScriptObjectType = (from AsmType in ScriptAsm.GetTypes() where AsmType.IsVisible && AsmType.GetInterface("IGeneratedScriptProgram") != null select AsmType).FirstOrDefault(); if (ScriptObjectType == null) { throw new ApplicationException("Unable to resolve script object type for assembly " + ScriptFileName); } ScriptObject = (IGeneratedScriptProgram)ScriptAsm.CreateInstance( ScriptObjectType.FullName, false, BindingFlags.CreateInstance, null, new object[] { CallerScript.ScriptHost.Intrinsics, CallerScript.ScriptHost.Host }, null, null); } finally { CurrentDomain.AssemblyResolve -= new ResolveEventHandler(LoadScriptFromDisk_AssemblyResolve); } return(ScriptObject); }
public Window1() { InitializeComponent(); show_log_window(); debug("FFXIAI"); debug(" author: framerate"); debug(" version: 0.0.0.1"); debug(" Starting..."); ArrayList a = Processes.get_ffxi_processes(); process_list_cb.Items.Clear(); foreach (Process obj in a) { process_list_cb.Items.Add(obj.MainWindowTitle + " - " + obj.Id); debug("found PID: " + obj.MainWindowTitle + " - " + obj.Id); } if (process_list_cb.Items.Count == 1) { debug("Only one FFXI process found!"); string polID = process_list_cb.Text; debug("Word: " + polID); int polIDPosition = polID.IndexOf(" - "); polID = polID.Remove(0, polIDPosition + 3); int pid = (int)Convert.ToUInt32(polID); debug("Attached to Process"); //Processes.attach_process(pid); } debug(System.AppDomain.CurrentDomain.BaseDirectory); //System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"settings/nav"); //system.reflection.assembly.getexecutingassembly().location foreach (string Filename in Directory.GetFiles(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Plugins"), "*.dll")) { Assembly Asm = Assembly.LoadFile(Filename); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("IPluginInterface") != null) { IPluginInterface Plugin = (IPluginInterface)Activator.CreateInstance(AsmType); Plugins.Add(Plugin); debug("Plugin Loaded!"); } } } if (Plugins.Count == 0) { debug("No plugins found!"); } }
void buttonBarItem_Click(object sender, Janus.Windows.ButtonBar.ItemEventArgs e) { INewsPaperControl item = (INewsPaperControl)((Janus.Windows.ButtonBar.ButtonBarItem)(sender)).Tag; if (Directory.GetFiles(Path.Combine(Application.StartupPath, "Plugins"), "*.dll").Length > 0) { string Filename = Path.Combine(Application.StartupPath, "Plugins") + @"\" + item.getName() + ".dll"; Assembly Asm = Assembly.LoadFile(Filename); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("INewsPaperControl") != null && AsmType.Name != "NewsPaperControlBase") { NewsPaperControlBase Plugin = (NewsPaperControlBase)Activator.CreateInstance(AsmType); currentNewsPaperControl = Plugin; Point p = new Point(currentNewsPaperControl.getAttList().getLocation().X *zoomDegree, currentNewsPaperControl.getAttList().getLocation().Y *zoomDegree); Size s = new System.Drawing.Size(currentNewsPaperControl.getAttList().getSize().Width *zoomDegree, currentNewsPaperControl.getAttList().getSize().Height *zoomDegree); Plugin.getCtrl().Location = p; Plugin.getCtrl().Size = s; iObjNumber++; Plugin.getAttList().setInstanceName("Obj" + iObjNumber.ToString()); //Xử lý marker if (Plugin.getName() == "NewsPaperMarker") { lstMarker.Add(Plugin); } MarkerList.lstMarkerList = new List <string>(); foreach (INewsPaperControl c in lstMarker) { MarkerList.lstMarkerList.Add(c.getAttList().getInstanceName()); } break; } } } ((Control)(currentNewsPaperControl)).MouseDown += new MouseEventHandler(MainProgram_MouseDown); ((Control)(currentNewsPaperControl)).MouseUp += new MouseEventHandler(MainProgram_MouseUp); panelInnerScreen.Controls.Add((Control)currentNewsPaperControl); saveControlTraceAndSetRealLocationSize(); }
bool loadControlPlugin() { m_MyControlList = new NewsPaperControlManager(); if (Directory.GetFiles(Path.Combine(Application.StartupPath, "Plugins"), "*.dll").Length > 0) { foreach (string Filename in Directory.GetFiles(Path.Combine(Application.StartupPath, "Plugins"), "*.dll")) { Assembly Asm = Assembly.LoadFile(Filename); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("INewsPaperControl") != null && AsmType.Name != "NewsPaperControlBase") { NewsPaperControlBase Plugin = (NewsPaperControlBase)Activator.CreateInstance(AsmType); m_MyControlList.LstNewsPaperControl.Add(Plugin); } } } return(true); } return(false); }
void buttonBarItem_Click(object sender, Janus.Windows.ButtonBar.ItemEventArgs e) { INewsPaperControl item = (INewsPaperControl)((Janus.Windows.ButtonBar.ButtonBarItem)(sender)).Tag; if (Directory.GetFiles(Path.Combine(Application.StartupPath, "Plugins"), "*.dll").Length > 0) { string Filename = Path.Combine(Application.StartupPath, "Plugins") + @"\" + item.getName() + ".dll"; Assembly Asm = Assembly.LoadFile(Filename); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("INewsPaperControl") != null && AsmType.Name != "NewsPaperControlBase") { NewsPaperControlBase Plugin = (NewsPaperControlBase)Activator.CreateInstance(AsmType); currentNewsPaperControl = Plugin; } } } ((Control)(currentNewsPaperControl)).MouseDown += new MouseEventHandler(MainProgram_MouseDown); ((Control)(currentNewsPaperControl)).MouseUp += new MouseEventHandler(MainProgram_MouseUp); panelInnerScreen.Controls.Add((Control)currentNewsPaperControl); preState.Add(currentNewsPaperControl.clone()); currentState.Add(currentNewsPaperControl); }
public static CNewspaper readXML(string filename) { CNewspaper news = new CNewspaper(); news.Directory = filename.Substring(0, filename.LastIndexOf("\\")); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(filename); news.KindOfNews = xmlDoc.SelectSingleNode("//title").InnerText; news.Datetime = xmlDoc.SelectSingleNode("//date").InnerText; news.NumPages = int.Parse(xmlDoc.SelectSingleNode("//numpages").InnerText); news.Number = int.Parse(xmlDoc.SelectSingleNode("//number").InnerText); foreach (XmlNode n in xmlDoc.SelectNodes("//page")) { CPage p = new CPage(); p.HeightP = int.Parse(n.Attributes["height"].Value); p.WidthP = int.Parse(n.Attributes["width"].Value); string strBackURL = n.Attributes["backgroundURL"].Value; if (strBackURL == "") { p.StrBackground = ""; } else { p.StrBackground = news.Directory + "\\" + strBackURL; } foreach (XmlNode xmlNodeObject in n.SelectNodes("object")) { string strControlName = xmlNodeObject.SelectSingleNode("type").InnerText; for (int i = 0; i < MainProgram.m_MyControlList.LstNewsPaperControl.Count; i++) { if (MainProgram.m_MyControlList.LstNewsPaperControl[i].getName() == strControlName) { Assembly Asm = Assembly.LoadFile(MainProgram.m_MyControlList.LstNewsPaperControl[i].getDllPath()); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("INewsPaperControl") != null && AsmType.Name != "NewsPaperControlBase") { NewsPaperControlBase Plugin = (NewsPaperControlBase)Activator.CreateInstance(AsmType); Plugin.loadfromXML(xmlNodeObject.OuterXml, news.Directory + "\\"); p.lstNewsPaperControl.Add(Plugin); break; } } break; } } } foreach (XmlNode xmlNodeObject in n.SelectNodes("marker")) { string strControlName = "NewsPaperMarker"; for (int i = 0; i < MainProgram.m_MyControlList.LstNewsPaperControl.Count; i++) { if (MainProgram.m_MyControlList.LstNewsPaperControl[i].getName() == strControlName) { Assembly Asm = Assembly.LoadFile(MainProgram.m_MyControlList.LstNewsPaperControl[i].getDllPath()); foreach (Type AsmType in Asm.GetTypes()) { if (AsmType.GetInterface("INewsPaperControl") != null && AsmType.Name != "NewsPaperControlBase") { NewsPaperControlBase Plugin = (NewsPaperControlBase)Activator.CreateInstance(AsmType); Plugin.loadfromXML(xmlNodeObject.OuterXml, news.Directory + "\\"); p.lstNewsPaperControl.Add(Plugin); break; } } break; } } } news.LPages.Add(p); } foreach (CPage page in news.LPages) { List <INewsPaperControl> lstMarker = new List <INewsPaperControl>(); List <INewsPaperControl> lstControl = new List <INewsPaperControl>(); foreach (INewsPaperControl c in page.lstNewsPaperControl) { if (c.getName() == "NewsPaperMarker") { lstMarker.Add(c); } } ReCalculteRealLocation(page, lstMarker); } return(news); }