Exemple #1
0
 public SetCardItemViewModel(Card c) //for loading an existing collection
 {
     Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action));
     Messenger.Default.Register <CardSizeChangedMesssage>(this, action => CardSizeChanged(action));
     AddAltCommand = new RelayCommand(AddAlt);
     _card         = c;
     Items         = new ObservableCollection <IdeListBoxItemBase>();
     foreach (var alt in c.Properties)
     {
         var AltItem = new SetCardAltItemViewModel(alt.Value)
         {
             ItemSource = Items,
             Parent     = this
         };
         if (alt.Key == "") // deals with the default card alt
         {
             BaseCardAlt           = AltItem;
             BaseCardAlt.IsDefault = true;
         }
         else
         {
             Items.Add(AltItem);
         }
     }
     Items.CollectionChanged += (a, b) =>
     {
         UpdateCardAlts();
     };
     SelectedItem = BaseCardAlt;
 }
Exemple #2
0
        public SetCardItemViewModel() //for adding new items
        {
            Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action));
            Messenger.Default.Register <CardSizeChangedMesssage>(this, action => CardSizeChanged(action));
            AddAltCommand = new RelayCommand(AddAlt);
            var guid = Guid.NewGuid();  //every card has a new GUID

            _card = new Card(
                guid,
                ViewModelLocator.SetTabViewModel.SelectedItem.Id,
                "Card",
                guid.ToString(),
                "",
                ViewModelLocator.PreviewTabViewModel.DefaultSize._size,
                new Dictionary <string, CardPropertySet>());

            Items = new ObservableCollection <IdeListBoxItemBase>();
            Items.CollectionChanged += (a, b) =>
            {
                UpdateCardAlts();
            };
            BaseCardAlt = new SetCardAltItemViewModel()
            {
                IsDefault = true,
                Parent    = this
            };
            BaseCardAlt.Name = "";
        }
Exemple #3
0
        public SetCardItemViewModel(SetCardItemViewModel c) //for copying the item
        {
            Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action));
            Messenger.Default.Register <CardSizeChangedMesssage>(this, action => CardSizeChanged(action));
            AddAltCommand = new RelayCommand(AddAlt);
            Parent        = c.Parent;
            ItemSource    = c.ItemSource;
            var guid = Guid.NewGuid();

            _card = new Card(c._card)
            {
                Id       = Guid.NewGuid(),
                ImageUri = guid.ToString()
            };
            Items = new ObservableCollection <IdeListBoxItemBase>();
            foreach (SetCardAltItemViewModel alt in c.Items)
            {
                Items.Add(new SetCardAltItemViewModel(alt)
                {
                    ItemSource = c.ItemSource, Parent = c.Parent
                });
            }
            BaseCardAlt              = new SetCardAltItemViewModel(c.BaseCardAlt);
            Items.CollectionChanged += (a, b) =>
            {
                UpdateCardAlts();
            };
        }
 public CardPropertyItemModel(PropertyItemViewModel prop, KeyValuePair <PropertyDef, object> propDef, SetCardAltItemViewModel parent) // initial load of property
 {
     Parent     = parent;
     Property   = prop;
     _isDefined = !propDef.Key.IsUndefined;
     _value     = propDef.Value;
 }
Exemple #5
0
        public void AddAlt()
        {
            var ret = new SetCardAltItemViewModel()
            {
                Parent     = this,
                ItemSource = Items,
                Name       = "Alt"
            };

            Items.Add(ret);
            SelectedItem = ret;
            RaisePropertyChanged("SelectedAlt");
        }
 public SetCardAltItemViewModel(SetCardAltItemViewModel a) //for copying the item
 {
     DeleteImageCommand = new RelayCommand(DeleteImage);
     Parent             = a.Parent;
     ItemSource         = a.ItemSource;
     _altDef            = a._altDef.Clone() as CardPropertySet;
     _altDef.Type       = Utils.GetUniqueName(a.Name, a.ItemSource.Select(x => (x as SetCardAltItemViewModel).Name));
     CardSize           = a.CardSize;
     Items = new ObservableCollection <CardPropertyItemModel>();
     Items.CollectionChanged += (x, b) =>
     {
         UpdateAltPropertySet();
     };
     foreach (var alt in _altDef.Properties)
     {
         var LinkedProperty = ViewModelLocator.PropertyTabViewModel.Items.First(x => (x as PropertyItemViewModel).Name == alt.Key.Name) as PropertyItemViewModel;
         Items.Add(new CardPropertyItemModel(LinkedProperty, alt, this));
     }
     // UpdateProxyTemplate();
 }