예제 #1
0
        public void AddNewGroup(NoteGroup group)
        {
            NoteGroup newGroup = new NoteGroup();

            group.Elements.Add(newGroup);
            newGroup.SetParent(group);
            OnElementAdded(newGroup);
        }
예제 #2
0
        public static NoteGroup ConvertNoteGroup(NoteGroup srcGroup, string password, bool decrypt)
        {
            ICryptoService _crypto     = CryptoFactory.Instance.GetMainService();
            NoteGroup      targetGroup = new NoteGroup();

            if (decrypt)
            {
                targetGroup.Name = _crypto.Decrypt(password, srcGroup.Name);
            }
            else
            {
                targetGroup.Name = _crypto.Encrypt(password, srcGroup.Name);
            }
            foreach (Note srcNote in srcGroup.GetNotes())
            {
                Note targetNote = new Note();
                if (decrypt)
                {
                    targetNote.Name = _crypto.Decrypt(password, srcNote.Name);
                    targetNote.Text = _crypto.Decrypt(password, srcNote.Text);
                }
                else
                {
                    targetNote.Name = _crypto.Encrypt(password, srcNote.Name);
                    targetNote.Text = _crypto.Encrypt(password, srcNote.Text);
                }
                targetGroup.Elements.Add(targetNote);
                targetNote.SetParent(targetGroup);
            }

            foreach (NoteGroup subSrcGroup in srcGroup.GetGroups())
            {
                NoteGroup subTargetGroup = ConvertNoteGroup(subSrcGroup, password, decrypt);
                targetGroup.Elements.Add(subTargetGroup);
                subTargetGroup.SetParent(targetGroup);
            }

            return(targetGroup);
        }