Пример #1
0
        private async void Groups_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Remove:
                var oldIndex = e.OldStartingIndex;
                _reorderedGroup = _group.Groups[oldIndex];
                break;

            case NotifyCollectionChangedAction.Add:
                if (_reorderedGroup == null)
                {
                    var group = (GroupVm)e.NewItems[0];
                    await _mediator.Send(new AddGroupCommand()
                    {
                        GroupId = group.Id, ParentGroupId = Id
                    });
                }
                else
                {
                    await _mediator.Send(new MoveGroupCommand { Group = _reorderedGroup, ParentGroup = _group, Index = e.NewStartingIndex });
                }
                break;
            }
            SaveCommand.RaiseCanExecuteChanged();
        }
Пример #2
0
        public async Task Initialize(GroupVm group)
        {
            if (group == null)
            {
                return;
            }

            GoBackCommand.RaiseCanExecuteChanged();
            ParentGroupName = group.Title;
            ParentGroupIcon = group.Icon;

            BreadcrumbItems.Add(new BreadcrumbItem {
                Path = group.Id, Name = group.Title, Icon = group.Icon
            });
            var parentGroup = group;

            while (!string.IsNullOrEmpty(parentGroup.ParentGroupId))
            {
                parentGroup = await _mediator.Send(new GetGroupQuery { Id = parentGroup.ParentGroupId });

                BreadcrumbItems.Add(new BreadcrumbItem {
                    Path = parentGroup.Id, Name = parentGroup.Title, Icon = parentGroup.Icon
                });
            }
        }
Пример #3
0
        public async Task Initialize(string groupId)
        {
            _group = await _mediator.Send(new GetGroupQuery { Id = groupId });

            if (!string.IsNullOrEmpty(_group.ParentGroupId))
            {
                Parent = await _mediator.Send(new GetGroupQuery { Id = _group.ParentGroupId });
            }
            else
            {
                Parent = null;
            }

            Entries = new ObservableCollection <EntryVm>(_group.Entries);
            Entries.CollectionChanged += Entries_CollectionChanged;
            Groups = new ObservableCollection <IEntityVm>(_group.Groups);
            Groups.CollectionChanged += Groups_CollectionChanged;
        }