public InventoryViewModel( IExtendedDialogCoordinator dialogCoordinator, ItemAttributes itemAttributes, IEnumerable <ushort> jewelPassiveNodes) { _dialogCoordinator = dialogCoordinator; _itemAttributes = itemAttributes; Armor = CreateSlotVm(ItemSlot.BodyArmour); MainHand = CreateSlotVm(ItemSlot.MainHand); OffHand = CreateSlotVm(ItemSlot.OffHand); Ring = CreateSlotVm(ItemSlot.Ring); Ring2 = CreateSlotVm(ItemSlot.Ring2); Amulet = CreateSlotVm(ItemSlot.Amulet); Helm = CreateSlotVm(ItemSlot.Helm); Gloves = CreateSlotVm(ItemSlot.Gloves); Boots = CreateSlotVm(ItemSlot.Boots); Belt = CreateSlotVm(ItemSlot.Belt); Flasks = ItemSlotExtensions.Flasks.Select(s => CreateSlotVm(s)).ToList(); TreeJewels = jewelPassiveNodes.Select(i => CreateSlotVm(ItemSlot.SkillTree, i)).ToList(); ItemJewels = new Dictionary <ItemSlot, IReadOnlyList <InventoryItemViewModel> > { [ItemSlot.BodyArmour] = CreateItemJewelVms(ItemSlot.BodyArmour, 1), [ItemSlot.Helm] = CreateItemJewelVms(ItemSlot.Helm, 2), [ItemSlot.Gloves] = CreateItemJewelVms(ItemSlot.Gloves, 2), [ItemSlot.Boots] = CreateItemJewelVms(ItemSlot.Boots, 2), [ItemSlot.Belt] = CreateItemJewelVms(ItemSlot.Belt, 2), }; }
protected DraggableItemViewModel(IExtendedDialogCoordinator dialogCoordinator, EquipmentData equipmentData) { _dialogCoordinator = dialogCoordinator; _equipmentData = equipmentData; DeleteCommand = new RelayCommand(Delete, CanDelete); EditSocketedGemsCommand = new AsyncRelayCommand(EditSocketedGemsAsync, CanEditSocketedGems); }
public StashViewModel(IExtendedDialogCoordinator dialogCoordinator) { _dialogCoordinator = dialogCoordinator; EditStashTabCommand = new AsyncRelayCommand <StashBookmarkViewModel>(EditStashTabAsync); AddStashTabCommand = new AsyncRelayCommand(AddStashTabAsync); ScrollToStashTabCommand = new RelayCommand <StashBookmarkViewModel>(ScrollToStashTab); StashTabDropHandler = new StashTabDropTarget(this); }
public InventoryItemViewModel(IExtendedDialogCoordinator dialogCoordinator, EquipmentData equipmentData, ItemAttributes itemAttributes, ItemSlot slot) : base(dialogCoordinator, equipmentData) { _itemAttributes = itemAttributes; _slot = slot; // Item changes when the slotted item in ItemAttribute changes as they are the same _itemAttributes.PropertyChanged += (sender, args) => { if (args.PropertyName == slot.ToString()) { OnPropertyChanged(nameof(Item)); } }; }
public InventoryViewModel(IExtendedDialogCoordinator dialogCoordinator, ItemAttributes itemAttributes) { _dialogCoordinator = dialogCoordinator; _itemAttributes = itemAttributes; Armor = CreateSlotVm(ItemSlot.BodyArmour); MainHand = CreateSlotVm(ItemSlot.MainHand); OffHand = CreateSlotVm(ItemSlot.OffHand); Ring = CreateSlotVm(ItemSlot.Ring); Ring2 = CreateSlotVm(ItemSlot.Ring2); Amulet = CreateSlotVm(ItemSlot.Amulet); Helm = CreateSlotVm(ItemSlot.Helm); Gloves = CreateSlotVm(ItemSlot.Gloves); Boots = CreateSlotVm(ItemSlot.Boots); Belt = CreateSlotVm(ItemSlot.Belt); Flasks = ItemSlotExtensions.Flasks.Select(CreateSlotVm).ToList(); }
public InventoryViewModel(IExtendedDialogCoordinator dialogCoordinator, EquipmentData equipmentData, ItemAttributes itemAttributes) { _dialogCoordinator = dialogCoordinator; _equipmentData = equipmentData; _itemAttributes = itemAttributes; Armor = CreateSlotVm(ItemSlot.BodyArmour); MainHand = CreateSlotVm(ItemSlot.MainHand); OffHand = CreateSlotVm(ItemSlot.OffHand); Ring = CreateSlotVm(ItemSlot.Ring); Ring2 = CreateSlotVm(ItemSlot.Ring2); Amulet = CreateSlotVm(ItemSlot.Amulet); Helm = CreateSlotVm(ItemSlot.Helm); Gloves = CreateSlotVm(ItemSlot.Gloves); Boots = CreateSlotVm(ItemSlot.Boots); Belt = CreateSlotVm(ItemSlot.Belt); }
public void Initialize(IExtendedDialogCoordinator dialogCoordinator, IPersistentData persistentData) { _dialogCoordinator = dialogCoordinator; _persistentData = persistentData; // add view models for bookmarks and items // PersistentData.StashBookmarks and PersistentData.StashItems may only be changed through the stash after this BeginUpdate(); Bookmarks.AddRange(persistentData.StashBookmarks.Select(b => new StashBookmarkViewModel(b))); Bookmarks.CollectionChanged += (sender, args) => RowsChanged(); foreach (var stashItem in persistentData.StashItems) { var item = new StashItemViewModel(stashItem); item.PropertyChanging += ItemOnPropertyChanging; item.PropertyChanged += ItemOnPropertyChanged; Items.Add(item); } Items.CollectionChanged += ItemsOnCollectionChanged; EndUpdate(); }
public BuildsControlViewModel(IExtendedDialogCoordinator dialogCoordinator, IPersistentData persistentData, ISkillTree skillTree) { _dialogCoordinator = dialogCoordinator; PersistentData = persistentData; DropHandler = new CustomDropHandler(this); _buildValidator = new BuildValidator(PersistentData.Options); BuildRoot = new BuildFolderViewModel(persistentData.RootBuild, Filter, BuildOnCollectionChanged); _fileSystemWatcher = new FileSystemWatcher { Path = PersistentData.Options.BuildsSavePath, IncludeSubdirectories = true, NotifyFilter = NotifyFilters.DirectoryName | NotifyFilters.FileName | NotifyFilters.LastWrite }; _fileSystemWatcher.Error += FileSystemWatcherOnError; _fileSystemWatcher.Changed += FileSystemWatcherOnChanged; _fileSystemWatcher.Created += FileSystemWatcherOnChanged; _fileSystemWatcher.Deleted += FileSystemWatcherOnChanged; _fileSystemWatcher.Renamed += FileSystemWatcherOnChanged; _fileSystemWatcher.EnableRaisingEvents = true; // The monitor alone is not enough because delays are necessary and those shouldn't block other save // operations, which would happen if delays are awaited directly in the save method. // It could be done awaited with .ConfigureAwait(false) if SimpleMonitor would be thread safe. _changingFileSystemMonitor.Entered += (sender, args) => _changingFileSystemCounter++; _changingFileSystemMonitor.Freed += async(sender, args) => { // Wait because FileSystemWatcherOnChanged calls are delayed a bit. await Task.Delay(2000); // This is a counter and not boolean because other save operations may happen while waiting on delay. _changingFileSystemCounter--; }; CurrentBuild = TreeFindBuildViewModel(PersistentData.CurrentBuild); SelectedBuild = TreeFindBuildViewModel(PersistentData.SelectedBuild); PersistentData.PropertyChanged += PersistentDataOnPropertyChanged; PersistentData.Options.PropertyChanged += OptionsOnPropertyChanged; NewFolderCommand = new AsyncRelayCommand <IBuildFolderViewModel>( NewFolder, vm => vm != null && _buildValidator.CanHaveSubfolder(vm)); NewBuildCommand = new AsyncRelayCommand <IBuildFolderViewModel>(NewBuild); DeleteCommand = new AsyncRelayCommand <IBuildViewModel>( Delete, o => o != BuildRoot); OpenBuildCommand = new RelayCommand <BuildViewModel>(build => CurrentBuild = build); SaveBuildCommand = new AsyncRelayCommand <BuildViewModel>( SaveBuild, b => b != null && b.Build.IsDirty); SaveBuildAsCommand = new AsyncRelayCommand <BuildViewModel>(SaveBuildAs); SaveAllBuildsCommand = new AsyncRelayCommand( SaveAllBuilds, () => TreeFind <BuildViewModel>(b => b.Build.IsDirty, BuildRoot) != null); RevertBuildCommand = new RelayCommand <BuildViewModel>( build => build.Build.RevertChanges(), b => b != null && b.Build.IsDirty && b.Build.CanRevert); MoveUpCommand = new RelayCommand <IBuildViewModel>( MoveUp, o => o != BuildRoot && o.Parent.Children.IndexOf(o) > 0); MoveDownCommand = new RelayCommand <IBuildViewModel>( MoveDown, o => o != BuildRoot && o.Parent.Children.IndexOf(o) < o.Parent.Children.Count - 1); EditCommand = new AsyncRelayCommand <IBuildViewModel>(Edit); CutCommand = new AsyncRelayCommand <IBuildViewModel>( Cut, b => b != BuildRoot && b != CurrentBuild); CopyCommand = new RelayCommand <IBuildViewModel <PoEBuild> >(Copy); PasteCommand = new AsyncRelayCommand <IBuildViewModel>(Paste, CanPaste); ReloadCommand = new AsyncRelayCommand(Reload); OpenBuildsSavePathCommand = new RelayCommand(() => Process.Start(PersistentData.Options.BuildsSavePath)); ExpandAllCommand = new RelayCommand(ExpandAll); CollapseAllCommand = new RelayCommand(CollapseAll); SkillTree = skillTree; ClassFilterItems = GenerateAscendancyClassItems().ToList(); ClassFilter = NoFilterItem; }
public StashItemViewModel(IExtendedDialogCoordinator dialogCoordinator, EquipmentData equipmentData, Item item) : base(dialogCoordinator, equipmentData) { Item = item; }