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);
        }
        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);
            }
        }
        private static void CheckKeeTheme(Control c)
        {
            Control check = GetControl("Rookiestyle_KeeTheme_Check", m_of);

            if (check != null)
            {
                return;
            }
            PluginDebug.AddInfo("Checking for KeeTheme");
            check         = new Control();
            check.Name    = "Rookiestyle_KeeTheme_Check";
            check.Visible = false;
            m_of.Controls.Add(check);
            KeePass.Plugins.Plugin p = (KeePass.Plugins.Plugin)GetPluginInstance("KeeTheme");
            if (p == null)
            {
                return;
            }
            var t = GetField("_theme", p);

            if (t == null)
            {
                return;
            }
            bool bKeeThemeEnabled = (bool)t.GetType().GetProperty("Enabled").GetValue(t, null);

            if (!bKeeThemeEnabled)
            {
                return;
            }
            var v = GetField("_controlVisitor", p);

            if (v == null)
            {
                return;
            }
            MethodInfo miVisit = v.GetType().GetMethod("Visit", new Type[] { typeof(Control) });

            if (miVisit == null)
            {
                return;
            }
            miVisit.Invoke(v, new object[] { c });
        }
Beispiel #4
0
        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()); }
        }