コード例 #1
0
ファイル: GroupDetailVm.cs プロジェクト: wismna/ModernKeePass
        private async Task DeleteEntry(EntryVm entry)
        {
            await _mediator.Send(new DeleteEntryCommand
            {
                EntryId        = entry.Id,
                ParentGroupId  = Id,
                RecycleBinName = _resource.GetResourceValue("RecycleBinTitle")
            });

            Entries.Remove(entry);
        }
コード例 #2
0
ファイル: EntryDetailVm.cs プロジェクト: wismna/ModernKeePass
        public async Task Initialize(string entryId)
        {
            SelectedIndex = 0;
            _current      = await _mediator.Send(new GetEntryQuery { Id = entryId });

            SetCurrentEntry(_current);
            Parent = await _mediator.Send(new GetGroupQuery { Id = _current.ParentGroupId });

            History = new ObservableCollection <IEntityVm> {
                _current
            };
            foreach (var entry in _current.History.Skip(1))
            {
                History.Add(entry);
            }
            History.CollectionChanged += (sender, args) =>
            {
                SelectedIndex = 0;
                SaveCommand.RaiseCanExecuteChanged();
            };
        }
コード例 #3
0
ファイル: EntryDetailVm.cs プロジェクト: wismna/ModernKeePass
        private void SetCurrentEntry(EntryVm entry)
        {
            _current         = entry;
            AdditionalFields =
                new ObservableCollection <EntryFieldVm>(
                    entry.AdditionalFields.Select(f =>
            {
                var field = new EntryFieldVm(_cryptography);
                field.Initialize(f.Name, f.Value, f.IsProtected);
                return(field);
            }));

            Attachments = new ObservableCollection <Attachment>(entry.Attachments.Select(f => new Attachment
            {
                Name    = f.Key,
                Content = f.Value
            }));
            Attachments.CollectionChanged += (sender, args) =>
            {
                UpdateDirtyStatus(true);
            };
            RaisePropertyChanged(string.Empty);
        }
コード例 #4
0
ファイル: GroupDetailVm.cs プロジェクト: wismna/ModernKeePass
        private async void Entries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Remove:
                var oldIndex = e.OldStartingIndex;
                _reorderedEntry = _group.Entries[oldIndex];
                break;

            case NotifyCollectionChangedAction.Add:
                if (_reorderedEntry == null)
                {
                    var entry = (EntryVm)e.NewItems[0];
                    await _mediator.Send(new AddEntryCommand { EntryId = entry.Id, ParentGroupId = Id });
                }
                else
                {
                    await _mediator.Send(new MoveEntryCommand { Entry = _reorderedEntry, ParentGroup = _group, Index = e.NewStartingIndex });
                }
                break;
            }
            SaveCommand.RaiseCanExecuteChanged();
        }
コード例 #5
0
ファイル: GroupDetailVm.cs プロジェクト: wismna/ModernKeePass
        private async Task AskForDeleteEntry(EntryVm entry)
        {
            if (IsRecycleOnDelete)
            {
                await DeleteEntry(entry);

                _notification.Show(_resource.GetResourceValue("EntityDeleting"), string.Format(_resource.GetResourceValue("EntryRecycled"), entry.Title));
            }
            else
            {
                await _dialog.ShowMessage(
                    string.Format(_resource.GetResourceValue("EntryDeletingConfirmation"), entry.Title),
                    _resource.GetResourceValue("EntityDeleting"),
                    _resource.GetResourceValue("EntityDeleteActionButton"),
                    _resource.GetResourceValue("EntityDeleteCancelButton"),
                    async isOk =>
                {
                    if (isOk)
                    {
                        await DeleteEntry(entry);
                    }
                });
            }
        }