public void OnSelectedStepChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { var treeView = sender as TreeView; var model = treeView.SelectedItem as CraftingStepViewModel; if (model?.Value == null || _selected == model.Value) { return; } var craftingStep = model.Value; ConditionModel?.Save(); if (model.HasCondition) { ConditionModel = new ConditionControlViewModel(model.Condition, _itemBase, _affixes.ToList()); Condition = new ConditionControlView(ConditionModel); OnPropertyChanged(nameof(Condition)); } else { Condition = null; OnPropertyChanged(nameof(Condition)); } CraftingTree.Select(craftingStep); _selected = model.Value; Tree.UpdateTree(CraftingTree, _selected); }
public void Initialize(CraftingTree craftingTree, EquipmentFactory equipmentFactory, CurrencyFactory currencyFactory, List <ItemPrototypeModel> itemPrototypes, double baseItemCost) { _craftingTree = craftingTree; _craftingTree.ClearCurrencySpent(); _currencyFactory = currencyFactory; _equipmentFactory = equipmentFactory; _itemPrototypes = itemPrototypes.OrderByDescending(x => x.Value).ThenBy(x => x.ItemName).ToList(); MatchingItems.Clear(); EquipmentList.Clear(); foreach (var prototype in _itemPrototypes) { MatchingItems.Add(prototype, new List <Equipment>()); } if (_task != null && _task.Status == TaskStatus.Running) { _cancellationTokenSource.Cancel(); } Progress = -1; ScourCount = 0; BaseItemCount = 0; BaseItemCost = baseItemCost; OnPropertyChanged(nameof(Message)); OnPropertyChanged(nameof(Progress)); OnPropertyChanged(nameof(MessageVisibility)); }
public CraftingTreeViewModel(CraftingTree craftingTree, ICraftingStep selected) { var craftingSteps = craftingTree.CraftingSteps.Select(x => new CraftingStepViewModel(x, selected)); Tree = new ObservableCollection <CraftingStepViewModel>(craftingSteps.ToArray()); OnPropertyChanged(nameof(Tree)); }
public CraftingProcessView(CurrencyFactory factory, IItemConfigRepository configRepository, EquipmentFactory equipmentFactory) { _configRepository = configRepository; _equipmentFactory = equipmentFactory; CraftingTree = new CraftingTree(factory); Tree = new CraftingTreeViewModel(CraftingTree, _selected); InitializeComponent(); DataContext = this; }
private void OnDeleteClick(object sender, RoutedEventArgs e) { if (_selected != null) { CraftingTree.Delete(_selected); Tree.UpdateTree(CraftingTree, _selected); _selected = null; } }
public void UpdateTree(CraftingTree craftingTree, ICraftingStep selected) { Tree.Clear(); var steps = craftingTree.CraftingSteps.Select(x => new CraftingStepViewModel(x, selected)).ToList(); for (int i = 0; i < steps.Count(); i++) { steps[i].UpdateStatus(); Tree.Add(steps[i]); } OnPropertyChanged(nameof(Tree)); }
public void Clear() { if (CraftingTree != null) { foreach (var item in CraftingTree.Items.Where(x => x is ICraftingTreeCompoundItem)) { (item as ICraftingTreeCompoundItem).RemoveIngredientParents(); } CraftingTree.Clear(); } if (GatheringList != null) { GatheringList.Clear(); } }
private void OnInsertOptionSelected(object sender, SelectionChangedEventArgs e) { var comboBox = sender as ComboBox; if (comboBox.DataContext == BindingOperations.DisconnectedSource) { return; } var model = comboBox.DataContext as CraftingStepViewModel; var craftingStep = model.Value; var selection = comboBox.SelectedItem as string; CraftingTree.Replace(craftingStep, selection); Tree.UpdateTree(CraftingTree, _selected); }
public void Initialize() { var baseInfo = _configRepository.GetItemConfig(); if (_baseInfo != null && _baseInfo.Equals(baseInfo)) { return; } _baseInfo = baseInfo; _equipmentFactory.Initialize(baseInfo.ItemBase, baseInfo.Category, baseInfo.ItemLevel); _itemBase = _equipmentFactory.GetBaseItem(); _affixes = new ObservableCollection <Affix>(_equipmentFactory.GetPossibleAffixes()); CraftingTree.ClearConditions(); CraftingTree.Initialize(); Condition = null; _selected = Tree.Tree[0].Value; Tree.UpdateTree(CraftingTree, _selected); OnPropertyChanged(nameof(Condition)); OnPropertyChanged(nameof(Tree)); }