public frmPluginManager() { InitializeComponent(); SetupPlugins(); ipsel = null; UpdateButtons(); }
static bool CheckTrial(PluginEntry pe) { TrialMaker t = new TrialMaker("TT1", Application.StartupPath + "\\RegFile.reg", //Environment.GetFolderPath(Environment.SpecialFolder.System) + "\\TMSetp.dbf", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\TMSetp.dbf", "", 30, 1000, "745"); //Environment.SpecialFolder.ApplicationData byte[] MyOwnKey = { 97, 250, 1, 5, 84, 21, 7, 63, 4, 54, 87, 56, 123, 10, 3, 62, 7, 9, 20, 36, 37, 21, 101, 57}; t.TripleDESKey = MyOwnKey; TrialMaker.RunTypes RT = t.ShowDialog(); bool is_trial; if (RT != TrialMaker.RunTypes.Expired) { if (RT == TrialMaker.RunTypes.Full) is_trial = false; else is_trial = true; return true; //Application.Run(new Form1(is_trial)); } return false; }
private void lvplugins_SelectedIndexChanged(object sender, EventArgs e) { if(lvplugins.SelectedIndices.Count >0 ) { int idx = lvplugins.SelectedIndices[0]; ipsel = UVDLPApp.Instance().m_plugins[idx]; UpdateButtons(); } }
private void lvplugins_SelectedIndexChanged(object sender, EventArgs e) { try { int idx = lvplugins.SelectedIndices[0]; m_ip = UVDLPApp.Instance().m_plugins[idx]; ListContents(); } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } }
private void cmdEnable_Click(object sender, EventArgs e) { if (cmdEnable.Text == "Disable") { ipsel.m_enabled = false; } else { ipsel.m_enabled = true; } UpdateButtons(); SetupPlugins(); ipsel = null; UpdateButtons(); }
/* private PluginEntry Find(string fname) { foreach (PluginEntry pe in UVDLPApp.Instance().m_plugins) { if (pe.m_filename.Equals(fname)) { return pe; } } return null; } * */ public void Load(string fname) { try { if (File.Exists(fname)) { //string fname = UVDLPApp.Instance().m_apppath + UVDLPApp.m_pathsep + "pluginconfig.cfg"; using (StreamReader reader = new StreamReader(fname)) { string line; while ((line = reader.ReadLine()) != null) { PluginEntry pe = new PluginEntry(null, line.Trim());//Find(line.Trim()); m_entries.Add(pe); } reader.Close(); } } } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } }
/* * private PluginEntry Find(string fname) * { * foreach (PluginEntry pe in UVDLPApp.Instance().m_plugins) * { * if (pe.m_filename.Equals(fname)) * { * return pe; * } * } * return null; * } * */ public void Load(string fname) { try { if (File.Exists(fname)) { //string fname = UVDLPApp.Instance().m_apppath + UVDLPApp.m_pathsep + "pluginconfig.cfg"; using (StreamReader reader = new StreamReader(fname)) { string line; while ((line = reader.ReadLine()) != null) { PluginEntry pe = new PluginEntry(null, line.Trim());//Find(line.Trim()); m_entries.Add(pe); } reader.Close(); } } } catch (Exception ex) { DebugLogger.Instance().LogError(ex); } }
/// <summary> /// Loading 'lite' plugins from zip file .plg files /// </summary> public void ScanForPluginsLite() { // load the list of plugin states string picn = m_apppath + m_pathsep + "pluginconfig.cfg"; // plugin configuration name m_pluginstates.Load(picn); // get a list of dll's in this current directory // try to register them as a plug-in string[] filePaths = Directory.GetFiles(m_apppath, "*.plg"); foreach (String pluginname in filePaths) { try { // create an instance of the plugin PluginLite pll = new PluginLite(); pll.m_filename = pluginname; pll.LoadManifest(); IPlugin plug = (IPlugin)pll; string args = Path.GetFileNameWithoutExtension(pluginname); // create an entry for the plugin PluginEntry pe = new PluginEntry(plug, args); //add the entry to the list of plugins m_plugins.Add(pe); //mark the plugin as enabled by default pe.m_enabled = true; if (m_pluginstates.InList(args)) { // this plugin is listed in the disabled list. DebugLogger.Instance().LogInfo("Plugin " + args + " marked disabled"); pe.m_enabled = false; } //get the vendor id of the newly loaded plugin int vid = plug.GetInt("VendorID"); //look for the license key for this plugin LicenseKey lk = KeyRing.Instance().Find(vid); // if we found it, mark it as licensed if (lk != null) { //initialize the plugin by setting the host. if (pe.m_enabled) { plug.Host = this; // this will initialize the plugin - the plugin's init function will be called DebugLogger.Instance().LogInfo("Loaded licensed plugin " + args); } } DebugLogger.Instance().LogInfo("Loaded plugin " + args); } catch (Exception ex) { DebugLogger.Instance().LogError(ex.Message); } } }
//licenses can be in a few states: // licensed and enabled - load the plugin and use it // licensed and disabled - do not use the plugin, do not initialize // un-licensed and enabled - prompt the user for license key, do not initialize it // un-licensed and disabled - ignore this plugin, keep entry for it, do not initialize public void ScanForPlugins() { // load the list of plugin states string picn = m_apppath + m_pathsep + "pluginconfig.cfg"; // plugin configuration name m_pluginstates.Load(picn); // get a list of dll's in this current directory // try to register them as a plug-in string[] filePaths = Directory.GetFiles(m_apppath, "*.dll"); foreach (String pluginname in filePaths) { string args = Path.GetFileNameWithoutExtension(pluginname); if (args.ToLower().StartsWith("pl")) { // located a dll that is a potential plugin Type ObjType = null; try { // load it Assembly ass = null; //string args = Path.GetFileNameWithoutExtension(pluginname); ass = Assembly.Load(args); if (ass != null) { ObjType = ass.GetType(args + ".PlugIn"); // look for the plugin interface // OK Lets create the object as we have the Report Type if (ObjType != null) { // create an instance of the plugin IPlugin plug = (IPlugin)Activator.CreateInstance(ObjType); // create an entry for the plugin PluginEntry pe = new PluginEntry(plug,args); //add the entry to the list of plugins m_plugins.Add(pe); //mark the plugin as enabled by default pe.m_enabled = true; if (m_pluginstates.InList(args)) { // this plugin is listed in the disabled list. DebugLogger.Instance().LogInfo("Plugin " + args + " marked disabled"); pe.m_enabled = false; } //get the vendor id of the newly loaded plugin int vid = plug.GetInt("VendorID"); //look for the license key for this plugin LicenseKey lk = KeyRing.Instance().Find(vid); // if we found it, mark it as licensed if (lk != null) { //initialize the plugin by setting the host. if(pe.m_enabled) { plug.Host = this; // this will initialize the plugin - the plugin's init function will be called DebugLogger.Instance().LogInfo("Loaded licensed plugin " + args); } } DebugLogger.Instance().LogInfo("Loaded plugin " + args); } } } catch (Exception ex) { DebugLogger.Instance().LogError(ex.Message); } } } }