Пример #1
0
        public EditViewNoteWindow(NoteSimplified current, List <string> keyIdentifiers, Action <NoteSimplified, bool /* Was Security Modified */, string /* Key identifier */> editNote)
        {
            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            DataContext = new EditViewNoteViewModel(current, keyIdentifiers, EditClose, CancelClose, editNote);
        }
        private void GenerateNoteSimplifiedsFromCommonSecrets()
        {
            this.notes.Clear();
            List <NoteSimplified> newNotes = NoteSimplified.TurnIntoUICompatible(this.csc.notes, this.csc.noteSecrets, this.derivedPasswords, this.settingsData);

            foreach (NoteSimplified note in newNotes)
            {
                this.notes.Add(note);
            }
        }
        private void AddNoteToCollection(NoteSimplified newNote, string keyIdentifier)
        {
            Note noteToAdd = new Note(newNote.Title, newNote.Text);

            if (newNote.IsSecure)
            {
                this.csc.AddNoteSecret(this.derivedPasswords[keyIdentifier], noteToAdd, keyIdentifier);
            }
            else
            {
                this.csc.notes.Add(noteToAdd);
            }

            // Adding a note modifies the structure
            this.isModified = true;
            this.UpdateMainTitle(this.filePath != null ? this.filePath : untitledTempName);

            this.GenerateNoteSimplifiedsFromCommonSecrets();
        }
Пример #4
0
        public EditViewNoteViewModel(NoteSimplified current, List <string> keyIds, Action positiveAction, Action negativeAction, Action <NoteSimplified, bool /* Was Security Modified */, string /* Key identifier */> edit)
        {
            this.KeyIdentifiers = new ObservableCollection <string>();
            foreach (string keyIdentifier in keyIds)
            {
                this.KeyIdentifiers.Add(keyIdentifier);
            }

            if (keyIds.Count > 0)
            {
                this.SelectedKeyIdentifier = keyIds[0];
            }

            this.onPositiveClose = positiveAction;
            this.onNegativeClose = negativeAction;
            this.editNote        = edit;

            this.zeroBasedIndexNumber = current.zeroBasedIndexNumber;
            this.wasOriginallySecret  = current.IsSecure;
            this.IsSecret             = current.IsSecure;
            this.Title = current.Title;
            this.Text  = current.Text;
        }
        private void EditNoteInCollection(NoteSimplified editedNote, bool wasSecurityModified, string keyIdentifier)
        {
            Note noteToAdd = new Note(editedNote.Title, editedNote.Text);

            if (wasSecurityModified)
            {
                // If note jumps from secure <-> unsecure
                if (editedNote.IsSecure)
                {
                    this.csc.notes.RemoveAt(editedNote.zeroBasedIndexNumber);
                    this.csc.AddNoteSecret(this.derivedPasswords[keyIdentifier], noteToAdd, keyIdentifier);
                }
                else
                {
                    this.csc.noteSecrets.RemoveAt(editedNote.zeroBasedIndexNumber);
                    this.csc.notes.Add(noteToAdd);
                }
            }
            else
            {
                if (editedNote.IsSecure)
                {
                    this.csc.ReplaceNoteSecret(editedNote.zeroBasedIndexNumber, this.derivedPasswords[keyIdentifier], noteToAdd, keyIdentifier);
                }
                else
                {
                    this.csc.notes[editedNote.zeroBasedIndexNumber] = noteToAdd;
                }
            }

            // Editing a note modifies the structure
            this.isModified = true;
            this.UpdateMainTitle(this.filePath != null ? this.filePath : untitledTempName);

            this.GenerateNoteSimplifiedsFromCommonSecrets();
        }