Пример #1
0
        public PartyListElementViewModel(UserParty party, Action <UserParty, bool> onSelect)
        {
            Id          = party.Id;
            Party.Value = party;

            PartyUnits = new ReactiveCollection <UserUnitViewModel>();
            Tags       = new ReactiveCollection <TagViewModel>();

            IsExpandComment.Subscribe(x =>
            {
                if (x)
                {
                    Comment.Value = party.Comment;
                }
                else
                {
                    Comment.Value = party.Comment?.GetFirstLine() ?? string.Empty;
                }
            });

            EditParty.Subscribe(x =>
            {
                var editWindow = new EditParty((UserParty)x);
                editWindow.ShowDialog();
            });
            OnDelete.Subscribe(() => DeleteParty(party));

            OnExport.Subscribe(() => ExportParty(party));

            OnDuplicate.Subscribe(() => DuplicateParty(party));

            OnSelect.Subscribe(() =>
            {
                IsSelectedRoute.Value = !IsSelectedRoute.Value;
                onSelect?.Invoke(party, IsSelectedRoute.Value);
            });

            UpdateParty(party);
        }