private void profileOther_SelectedIndexChanged(object sender, EventArgs e)
        {
            m_ProfilesOther.Clear();
            if (cbProfileOther.SelectedIndex == 0)
            {
                foreach (var profile in KeePass.Program.Config.PasswordGenerator.UserProfiles)
                {
                    if (!profile.IsDBOnlyProfile())
                    {
                        m_ProfilesOther.Add(profile.Name);
                    }
                }
            }
            else
            {
                bool found = false;
                for (int i = 0; i < KeePass.Program.MainForm.DocumentManager.DocumentCount; i++)
                {
                    m_otherDB = KeePass.Program.MainForm.DocumentManager.Documents[i].Database;
                    if (!m_otherDB.IsOpen)
                    {
                        continue;
                    }
                    if (m_otherDB.IOConnectionInfo.Path != ((DBInfo)cbProfileOther.Items[cbProfileOther.SelectedIndex]).path)
                    {
                        continue;
                    }
                    m_ProfilesOther = m_otherDB.GetDBProfileNames();
                    found           = true;
                    break;
                }
                if (!found)
                {
                    m_otherDB = null;
                }
            }
            lbProfilesOther.Items.Clear();
            foreach (string profile in m_ProfilesOther)
            {
                lbProfilesOther.Items.Add(profile);
            }

            int index = lbProfilesDB.SelectedIndex;

            lbProfilesDB.Items.Clear();
            foreach (string profile in m_ProfilesDB)
            {
                lbProfilesDB.Items.Add(profile);
            }
            if (index > -1)
            {
                lbProfilesDB.SelectedIndex = index;
            }
        }
Ejemplo n.º 2
0
        //Return DB specific profiles stored in database
        public static List <PwProfile> GetDBProfiles(this PwDatabase db)
        {
            List <string>    profileNames = db.GetDBProfileNames();
            List <PwProfile> profiles     = new List <PwProfile>();

            foreach (string profileName in profileNames)
            {
                try
                {
                    PwProfile profile = db.GetProfile(profileName);
                    if (profile != null)
                    {
                        profiles.Add(profile);
                    }
                }
                catch (Exception) { }
            }
            return(profiles);
        }
        public void SetHomeDB(PwDatabase db)
        {
            if ((db == null) || !db.IsOpen)
            {
                Init(false);
                return;
            }
            m_homeDB = db.IOConnectionInfo.Path;
            string dbname = FriendlyName(db);

            if (dbname.Length > 30)
            {
                dbname = dbname.Substring(0, 10) + "..." + dbname.Substring(dbname.Length - 10);
            }
            ;
            lActiveDB.Text = string.Format(PluginTranslate.OptionsActiveDB, dbname);
            m_ProfilesDB   = db.GetDBProfileNames();
            lbProfilesDB.Items.AddRange(m_ProfilesDB.ToArray());
            Init(true);
        }