コード例 #1
0
ファイル: CardsViewModel.cs プロジェクト: vinla/cgwo
 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();
 }
コード例 #2
0
ファイル: CardEditorViewModel.cs プロジェクト: vinla/cgwo
        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);
                    }
                };
            }
        }
コード例 #3
0
ファイル: LayoutViewModel.cs プロジェクト: vinla/cgwo
        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));
        }
コード例 #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
            };
        }
コード例 #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();
                }
            };
        }
コード例 #6
0
ファイル: ProjectViewModel.cs プロジェクト: vinla/cgwo
 public ProjectViewModel(ICardGameDataStore cardGameDataStore, IDialogService dialogService)
 {
     _cardGameDataStore = cardGameDataStore ?? throw new ArgumentNullException();
     _dialogService     = dialogService ?? throw new ArgumentNullException();
     LoadModule(ModuleNames.CardTypes);
 }
コード例 #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;
 }
コード例 #8
0
 public void ProjectLoaded(ICardGameDataStore dataStore)
 {
     _viewModel = new ProjectViewModel(dataStore, _dialogService);
     RaisePropertyChanged(nameof(CurrentViewModel));
 }