public static void AddPluginToOptionsForm(KeePass.Plugins.Plugin p, UserControl uc) { m_OptionsShown = m_PluginContainerShown = false; TabPage tPlugin = new TabPage(DefaultCaption); tPlugin.CreateControl(); tPlugin.Name = m_TabPageName = c_tabRookiestyle + p.GetType().Name; uc.Dock = DockStyle.Fill; uc.Padding = new Padding(15, 10, 15, 10); tPlugin.Controls.Add(uc); PluginDebug.AddInfo("Adding/Searching " + c_tabControlRookiestyle); TabControl tcPlugins = AddPluginTabContainer(); int i = 0; bool insert = false; for (int j = 0; j < tcPlugins.TabPages.Count; j++) { if (string.Compare(tPlugin.Text, tcPlugins.TabPages[j].Text, StringComparison.CurrentCultureIgnoreCase) < 0) { i = j; insert = true; break; } } if (!insert) { i = tcPlugins.TabPages.Count; PluginDebug.AddInfo(p.GetType().Name + " tab index : " + i.ToString() + " - insert!", 0); } else { PluginDebug.AddInfo(p.GetType().Name + " tab index : " + i.ToString(), 0); } tcPlugins.TabPages.Insert(i, tPlugin); AddPluginToOverview(tPlugin.Name.Replace(c_tabRookiestyle, string.Empty), tcPlugins); if (p.SmallIcon != null) { tcPlugins.ImageList.Images.Add(tPlugin.Name, p.SmallIcon); tPlugin.ImageKey = tPlugin.Name; } TabControl tcMain = Tools.GetControl("m_tabMain", m_of) as TabControl; if (!string.IsNullOrEmpty(PluginURL)) { AddPluginLink(uc); } }
public static UserControl GetPluginFromOptions(KeePass.Plugins.Plugin p, out bool PluginOptionsShown) { PluginOptionsShown = m_OptionsShown && m_PluginContainerShown; TabPage tPlugin = Tools.GetControl(c_tabRookiestyle + p.GetType().Name, m_of) as TabPage; if (tPlugin == null) { return(null); } return(tPlugin.Controls[0] as UserControl); }
private void CheckPEDCalc() { List <string> lMsg = new List <string>(); try { PwEntry pe = Program.MainForm.GetSelectedEntry(true); if (pe == null) { lMsg.Add("Error identifying selected entry"); return; } KeePass.Plugins.Plugin ped = (KeePass.Plugins.Plugin)Tools.GetPluginInstance("PEDCalc"); if (ped == null) { lMsg.Add("PEDCalc not found"); return; } lMsg.Add("PEDCalc found"); Type tC = ped.GetType().Assembly.GetType("PEDCalc.Configuration"); if (tC != null) { bool bActive = false; PropertyInfo piActive = tC.GetProperty("Active", BindingFlags.Public | BindingFlags.Static); if (piActive != null) { bActive = (bool)piActive.GetValue(null, null); } if (!bActive) { lMsg.Add("PEDCalc inactive"); return; } } Type tEE = ped.GetType().Assembly.GetType("PEDCalc.EntryExtensions"); if (tEE == null) { lMsg.Add("Error retrieving PEDCalc.EntryExtensions"); return; } MethodInfo miGetPEDValue = tEE.GetMethod("GetPEDValue", BindingFlags.NonPublic | BindingFlags.Static); if (miGetPEDValue == null) { lMsg.Add("Error retrieving method GetPEDValue"); return; } try { object pedNewExpireDate = miGetPEDValue.Invoke(null, new object[] { pe, true }); bool bOff = (bool)pedNewExpireDate.GetType().GetProperty("Off").GetValue(pedNewExpireDate, null); if (bOff) { lMsg.Add("PEDCalc result: Off, no recalculation neccessary"); return; } DateTime dtNewExpireDate = (DateTime)pedNewExpireDate.GetType().GetProperty("NewExpiryDateUtc").GetValue(pedNewExpireDate, null);; EntryExpiry.Value = dtNewExpireDate.ToLocalTime(); lMsg.Add("PEDCalc result: " + pedNewExpireDate.ToString()); lMsg.Add("nNew expiry date:" + dtNewExpireDate.ToLocalTime().ToString()); } catch { } } finally { PluginDebug.AddInfo("Adjust expiry date according to PEDCalc", 0, lMsg.ToArray()); } }