Esempio n. 1
0
        private void RecursiveAddGroup(TreeGroupModel tree, GroupModel parent, PwGroup pgContainer, PwGroup pgFind)
        {
            if (pgContainer == null)
            return;

             IList<GroupModel> tnc;

             if (parent == null)
            tnc = tree.Nodes;
             else
            tnc = parent.Childs;

             foreach (PwGroup pg in pgContainer.Groups) {
            string strName = pg.Name; // + GetGroupSuffixText(pg);

            int nIconID = ((!pg.CustomIconUuid.EqualsValue (PwUuid.Zero)) ? ((int)PwIcon.Count + db.GetCustomIconIndex (pg.CustomIconUuid)) : (int)pg.IconId);
            bool bExpired = (pg.Expires && (pg.ExpiryTime <= m_dtCachedNow));

            if (bExpired)
               nIconID = (int) PwIcon.Expired;

            GroupModel node = new GroupModel ()
            {
               Name = strName,
               ImageIndex = nIconID,
               SelectedImageIndex = nIconID,
               Group = pg,
               Expires = pg.Expires,
               ExpiryTime = pg.ExpiryTime
            };

            tnc.Add (node);

            RecursiveAddGroup (tree, node, pg, pgFind);
             }
        }
Esempio n. 2
0
        public TreeGroupModel FindGroups()
        {
            TreeGroupModel model = new TreeGroupModel ();
             DateTime m_dtCachedNow = DateTime.Now;
             GroupModel root = null;

             // add root if exists
             if (db.RootGroup != null) {
            int nIconID = ((!db.RootGroup.CustomIconUuid.EqualsValue (PwUuid.Zero)) ?
                                                                                        ((int)PwIcon.Count + db.GetCustomIconIndex (
                                                                                           db.RootGroup.CustomIconUuid)) : (int)db.RootGroup.IconId);

            if (db.RootGroup.Expires && (db.RootGroup.ExpiryTime <= m_dtCachedNow))
               nIconID = (int) PwIcon.Expired;

            root = new GroupModel ()
               {
                  Name = db.RootGroup.Name,
                  ImageIndex = nIconID,
                  SelectedImageIndex = nIconID,
                  Group = db.RootGroup,
                  Expires = db.RootGroup.Expires,
                  ExpiryTime = db.RootGroup.ExpiryTime
               };

            model.Nodes.Add (root);
             }

             RecursiveAddGroup (model, root, db.RootGroup, null);

             return model;
        }