public SetItemViewModel(SetItemViewModel s) //for copying the item
        {
            var    id          = Guid.NewGuid();
            string installPath = Path.Combine(ViewModelLocator.GameLoader.GamePath, "Sets", id.ToString());

            _set = new Set()
            {
                Name        = s._set.Name,
                Id          = id,
                GameId      = s._set.GameId,
                Hidden      = s._set.Hidden,
                ShortName   = s._set.ShortName,
                Description = s._set.Description,
                ReleaseDate = s._set.ReleaseDate,
                InstallPath = installPath,
                Filename    = Path.Combine(installPath, "set.xml"),
                PackUri     = Path.Combine(installPath, "Cards")
            };
            CardItems = new ObservableCollection <IdeListBoxItemBase>();
            CardItems.CollectionChanged += (a, b) =>
            {
                _set.Cards = CardItems.Select(x => (x as SetCardItemViewModel)._card).ToList();
            };
            foreach (SetCardItemViewModel card in s.CardItems)
            {
                CardItems.Add(new SetCardItemViewModel(card)
                {
                    ItemSource = CardItems, Parent = this
                });
            }
            //     _set.Cards = CardItems.Select(x => (x as SetCardItemViewModel)._card).ToList();
            RaisePropertyChanged("CardItems");

            PackageItems = new ObservableCollection <IdeListBoxItemBase>();
            PackageItems.CollectionChanged += (a, b) =>
            {
                _set.Packs = PackageItems.Select(x => (x as SetPackageItemViewModel)._pack).ToList();
            };
            foreach (SetPackageItemViewModel package in s.PackageItems)
            {
                PackageItems.Add(new SetPackageItemViewModel(package)
                {
                    ItemSource = PackageItems, Parent = this
                });
            }
            //  _set.Packs = PackageItems.Select(x => (x as SetPackageItemViewModel)._pack).ToList();
            RaisePropertyChanged("PackItems");

            AddCardCommand    = new RelayCommand(AddCard);
            AddPackageCommand = new RelayCommand(AddPackage);

            ItemSource = s.ItemSource;
            Parent     = s.Parent;

            CanDragDrop = false;
        }
Beispiel #2
0
        public void AddSet()
        {
            var ret = new SetItemViewModel()
            {
                ItemSource = Items
            };

            Items.Add(ret);
            SelectedItem = ret;
        }