Example #1
0
        public AlternateModel(AlternateModel a, IdeCollection <IdeBaseItem> source) : base(source) //for copying the item
        {
            _altDef = new CardPropertySet()
            {
                Size       = a._altDef.Size,
                Properties = a._altDef.Properties.ToDictionary(x => x.Key, x => x.Value),
                Name       = a.Name
            };
            Type  = a.Type;
            Items = new IdeCollection <CardPropertyModel>(this);
            Items.CollectionChanged += (c, b) =>
            {
                BuildAltDef(b);
            };
            foreach (var prop in _altDef.Properties)
            {
                Items.Add(new CardPropertyModel
                {
                    Property   = ViewModelLocator.PropertyTabViewModel.Items.First(y => (y as PropertyItemModel)._property.Equals(prop.Key)) as PropertyItemModel,
                    _value     = prop.Value,
                    _isDefined = prop.Value != null,
                    Parent     = this
                });
            }

            DeleteImageCommand = new RelayCommand(DeleteImage);
            Messenger.Default.Register <CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action));
            Messenger.Default.Register <CardSizeChangedMesssage>(this, action => CardSizeChanged(action));
        }
Example #2
0
        public CardModel(IdeCollection <IdeBaseItem> src) : base(src) //for adding new items
        {
            var guid = Guid.NewGuid();                                //every card has a new GUID

            _card = new Card(
                guid,                                                                              //card guid
                ((SetModel)Source.Parent).Id,                                                      //set guid
                "Card",                                                                            //card name
                guid.ToString(),                                                                   //imageuri
                "",                                                                                //alternate
                ((SizeItemModel)ViewModelLocator.PreviewTabViewModel.CardSizes.DefaultItem)._size, //size
                new Dictionary <string, CardPropertySet>());                                       //property sets

            Items = new IdeCollection <IdeBaseItem>(this);
            Items.CollectionChanged += (a, b) =>
            {
                BuildCardDef(b);
            };
            var baseCardAlt = new AlternateModel(Items)
            {
                CanRemove   = false,
                CanDragDrop = false
            };

            Items.DefaultItem = baseCardAlt;
            Items.Add(baseCardAlt);

            AddAltCommand = new RelayCommand(AddAlt);
        }
Example #3
0
        public CardModel(CardModel c, IdeCollection <IdeBaseItem> src) : base(src) //for copying the item
        {
            var guid = Guid.NewGuid();

            _card = new Card(c._card)
            {
                Id       = Guid.NewGuid(),
                ImageUri = guid.ToString()
            };
            Items = new IdeCollection <IdeBaseItem>(this);
            Items.CollectionChanged += (a, b) =>
            {
                BuildCardDef(b);
            };
            foreach (AlternateModel alt in c.Items)
            {
                AlternateModel newAlt = new AlternateModel(alt, Items);
                if (alt.IsDefault)
                {
                    newAlt.CanDragDrop = false;
                    newAlt.CanRemove   = false;
                    Items.DefaultItem  = newAlt;
                }
                Items.Add(newAlt);
            }

            AddAltCommand = new RelayCommand(AddAlt);
        }
Example #4
0
        public void AddAlt()
        {
            var ret = new AlternateModel(Items);

            Items.Add(ret);
            Items.SelectedItem = ret;
        }
Example #5
0
        public CardModel(CardModel c, IdeCollection <IdeBaseItem> src) : base(src) //for copying the item
        {
            var guid = Guid.NewGuid();

            _card = new Card(c._card)
            {
                Id = Guid.NewGuid()
            };
            Items = new IdeCollection <IdeBaseItem>(this, typeof(AlternateModel));
            Items.CollectionChanged += (a, b) =>
            {
                BuildCardDef(b);
            };
            foreach (AlternateModel alt in c.Items)
            {
                AlternateModel newAlt = new AlternateModel(alt, Items);
                if (alt.IsDefault)
                {
                    Items.DefaultItem  = newAlt;
                    Items.SelectedItem = newAlt;
                }
                Items.Add(newAlt);
            }

            AddAltCommand = new RelayCommand(AddAlt);
        }
Example #6
0
        public AlternateModel(AlternateModel a, IdeCollection <IdeBaseItem> source) : base(source) //for copying the item
        {
            _altDef = new CardPropertySet()
            {
                Size       = a._altDef.Size,
                Properties = a._altDef.Properties.ToDictionary(x => x.Key, x => x.Value),
                Name       = a.Name
            };
            Type = a.Type;

            DeleteImageCommand = new RelayCommand(DeleteImage);
            //  Messenger.Default.Register<CustomPropertyChangedMessage>(this, action => CustomPropertyChanged(action));
            Messenger.Default.Register <CardSizeChangedMesssage>(this, action => CardSizeChanged(action));
        }
Example #7
0
 public CardModel(Card c, IdeCollection <IdeBaseItem> src) : base(src) //for loading an existing collection
 {
     _card = c;
     Items = new IdeCollection <IdeBaseItem>(this, typeof(AlternateModel));
     foreach (var alt in c.PropertySets)
     {
         var AltItem = new AlternateModel(alt.Value, Items);
         if (alt.Key == "") // deals with the default card alt
         {
             Items.DefaultItem  = AltItem;
             Items.SelectedItem = AltItem;
         }
         Items.Add(AltItem);
     }
     Items.CollectionChanged += (a, b) =>
     {
         BuildCardDef(b);
     };
     AddAltCommand = new RelayCommand(AddAlt);
 }
Example #8
0
 public CardPropertyModel(AlternateModel parent, PropertyItemModel property)
 {
     Parent         = parent;
     LinkedProperty = property;
 }