Example #1
0
 public CardsViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService)
 {
     _cardGameDataStore = cardGameDataStore ?? throw new ArgumentNullException(nameof(cardGameDataStore));
     _dialogService     = dialogService ?? throw new ArgumentNullException(nameof(cardGameDataStore));
     _cardTypes         = _cardGameDataStore.GetCardTypes();
     SelectedCardType   = _cardTypes.FirstOrDefault();
 }
Example #2
0
        public CardEditorViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService, Card card, Action <Card> cardUpdated)
        {
            _cardGameDataStore = cardGameDataStore ?? throw new ArgumentNullException(nameof(cardGameDataStore));
            _dialogService     = dialogService ?? throw new ArgumentNullException(nameof(dialogService));
            _cardUpdated       = cardUpdated;
            _card = card ?? throw new ArgumentNullException(nameof(card));

            _cardValues = _card.AttributeValues.Select(attr => new CardAttributeValueViewModel(attr)).Cast <NamedValueViewModel>().ToList();
            _cardValues.Insert(0, new CardNameValueViewModel(_card));
            _cardValues.Insert(1, new CardTypeValueViewModel(_card));

            _layout   = _cardGameDataStore.GetLayout(card.CardType.Id);
            _elements = LayoutConverter.ToDesignerElements(_layout.Elements);

            foreach (var cardValue in _cardValues)
            {
                cardValue.PropertyChanged += (s, e) =>
                {
                    if (e.PropertyName == nameof(NamedValueViewModel.Value))
                    {
                        UpdatePreview(cardValue);
                    }
                };
            }
        }
Example #3
0
        public LayoutViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService, CardTypeViewModel cardTypeViewModel)
        {
            _dialogService     = dialogService ?? throw new ArgumentNullException(nameof(dialogService));
            _cardGameDataStore = cardGameDataStore ?? throw new ArgumentNullException(nameof(cardGameDataStore));
            _cardTypeViewModel = cardTypeViewModel ?? throw new ArgumentNullException(nameof(cardTypeViewModel));
            _layoutDocument    = new LayoutDocument();
            _actionManager     = new ActionManager();
            LoadLayout();

            _layoutDocument.Elements.CollectionChanged += (s, e) => RaisePropertyChanged(nameof(SelectedElement));
        }
Example #4
0
        public CardTypeViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService, CardType original, Action <bool> updateCallback)
        {
            _dialogService     = dialogService;
            _updateCallback    = updateCallback;
            _cardGameDataStore = cardGameDataStore ?? throw new ArgumentNullException(nameof(cardGameDataStore));
            _original          = original;
            _layoutViewModel   = new LayoutViewModel(cardGameDataStore, _dialogService, this);
            LoadAttributes();

            _clone = new CardType
            {
                Id   = _original.Id,
                Name = _original.Name
            };
        }
Example #5
0
        public CardAttributeViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService, Guid cardTypeId, CardAttribute original, Action cancelEdit, Action updated)
        {
            _dialogService      = dialogService ?? throw new ArgumentNullException(nameof(dialogService));
            _cardGameDataStore  = cardGameDataStore ?? throw new ArgumentNullException(nameof(cardGameDataStore));
            _original           = original ?? throw new ArgumentNullException(nameof(original));
            _cardTypeId         = cardTypeId;
            _cancelEdit         = cancelEdit;
            _existingAttributes = _cardGameDataStore.GetCardAttributes(_cardTypeId);
            _isDeleted          = false;
            Name = _original.Name ?? String.Empty;

            PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == nameof(HasChanges))
                {
                    updated?.Invoke();
                }
            };
        }
Example #6
0
 public ProjectViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService)
 {
     _cardGameDataStore = cardGameDataStore ?? throw new ArgumentNullException();
     _dialogService     = dialogService ?? throw new ArgumentNullException();
     LoadModule(ModuleNames.CardTypes);
 }
Example #7
0
 public CardTypesViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService)
 {
     _dialogService     = dialogService ?? throw new ArgumentNullException(nameof(dialogService));
     _cardGameDataStore = cardGameDataStore ?? throw new ArgumentNullException(nameof(cardGameDataStore));
     _projectName       = _cardGameDataStore.GetProjectInfo().Name;
 }
Example #8
0
 public void ProjectLoaded(ICardGameDataStore dataStore)
 {
     _viewModel = new ProjectViewModel(dataStore, _dialogService);
     RaisePropertyChanged(nameof(CurrentViewModel));
 }