示例#1
0
        public ConditionControlViewModel(CraftingCondition condition, PoeCrafting.Entities.ItemBase itemBase, List <Affix> affixes)
        {
            _itemBase          = itemBase;
            _affixes           = affixes;
            _craftingCondition = condition;

            SubconditionControls = new ObservableCollection <SubconditionControlView>();

            for (int i = condition.CraftingSubConditions.Count - 1; i >= 0; i--)
            {
                var model = new SubconditionControlViewModel(condition.CraftingSubConditions[i], affixes, GetNextIndex(), _itemBase);
                var subconditionControl = new SubconditionControlView(model);
                model.OnDeleteEvent += (x, y) => RemoveSubcondition(y.Control);
                SubconditionControls.Add(subconditionControl);
            }

            if (SubconditionControls.Count == 0)
            {
                AddSubcondition();
            }

            SelectedSubcondition = SubconditionControls[0];

            OnPropertyChanged(nameof(SelectedSubcondition));
            OnPropertyChanged(nameof(SubconditionControls));
        }
示例#2
0
        public void AddSubcondition()
        {
            var subcondition = new CraftingSubcondition();

            var model = new SubconditionControlViewModel(subcondition, _affixes, GetNextIndex(), _itemBase);
            var subconditionControl = new SubconditionControlView(model);

            model.OnDeleteEvent += (x, y) => RemoveSubcondition(y.Control);

            _craftingCondition.CraftingSubConditions.Add(subcondition);
            SubconditionControls.Add(subconditionControl);
            SelectedSubcondition = subconditionControl;
            OnPropertyChanged(nameof(SelectedSubcondition));
            OnPropertyChanged(nameof(SubconditionControls));
        }
示例#3
0
        public void RemoveSubcondition(SubconditionControlViewModel model)
        {
            SubconditionControls.Remove(SubconditionControls.First(x => x.ViewModel == model));
            _craftingCondition.CraftingSubConditions.Remove(model.SubCondition);
            SelectedSubcondition = null;

            if (SubconditionControls.Count == 0)
            {
                AddSubcondition();
            }

            SelectedSubcondition = SubconditionControls[0];

            OnPropertyChanged(nameof(SelectedSubcondition));
            OnPropertyChanged(nameof(SubconditionControls));
        }
 public SubconditionControlView(SubconditionControlViewModel viewModel)
 {
     ViewModel = viewModel;
     InitializeComponent();
 }
示例#5
0
 public OnDeleteEventArgs(SubconditionControlViewModel c)
 {
     Control = c;
 }