/// <summary> /// /// </summary> protected virtual void OnSelectedItemsChanged(object sender, EventArgs e) { var Collection = new List <object>(); SelectedItems.ForEach <object>(i => Collection.Add(i)); SelectedItemsChanged?.Invoke(this, new EventArgs <IList <object> >(Collection)); }
private void StopTransmitingCommand_Execute() { SelectedItems.ForEach((el) => el.StopTransmiting()); StartTransmitingCommand.RaiseCanExecuteChanged(); StopTransmitingCommand.RaiseCanExecuteChanged(); ShotCommand.RaiseCanExecuteChanged(); }
private void SelectItem([NotNull] BaseTreeViewItem selected, bool acceptKeys) { Debug.ArgumentNotNull(selected, nameof(selected)); if (SelectionMode == SelectionMode.Single) { Clear(); selected.IsSelected = true; } else { var isShift = KeyboardManager.IsActive == 0 && acceptKeys && (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)); var isCtrl = KeyboardManager.IsActive == 0 && acceptKeys && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)); if (!isCtrl && !isShift && SelectedItems.Count > 1 && selected.IsItemSelected) { selected.IsSelected = true; } else { if (!isCtrl) { SelectedItems.ForEach(delegate(BaseTreeViewItem f) { f.IsSelected = false; f.IsItemSelected = false; }); SelectedItems.Clear(); if (!isShift) { _lastSelectedItem = null; } } if (isShift) { ShiftSelect(selected); } else { SingleSelect(selected); } } } var changed = SelectedItemsChanged; if (changed != null) { changed(this, new RoutedPropertyChangedEventArgs <object>(null, null)); } }
private void StartTransmitingCommand_Execute() { SelectedItems.ForEach((el) => { el.StartTransmiting(); el.TransmitToSelectedChannels = TransmitToSelectedChannels; }); StartTransmitingCommand.RaiseCanExecuteChanged(); StopTransmitingCommand.RaiseCanExecuteChanged(); ShotCommand.RaiseCanExecuteChanged(); }
public void LoadCommands() { LoadEquippedItemsCommand = new RelayCommand(parameter => { try { if (ZetaDia.Me == null || !ZetaDia.IsInGame) { if (!ChangeEvents.IsInGame.Value) { Core.Logger.Log("Must be in a game to use this feature"); } else { using (ZetaDia.Memory.AcquireFrame()) { ZetaDia.Actors.Update(); Core.Logger.Log("Scanning Character for Equipped Items"); SelectItems(InventoryManager.Equipped); } } } else { if (!BotMain.IsRunning) { ZetaDia.Actors.Update(); } Core.Logger.Log("Scanning Character for Equipped Items"); SelectItems(InventoryManager.Equipped); } } catch (Exception ex) { Core.Logger.Error("Exception in SelectAllCommand {0}", ex); } }); LoadStashedItemsCommand = new RelayCommand(parameter => { try { if (ZetaDia.Me == null || !ZetaDia.IsInGame) { if (BotMain.IsRunning) { Core.Logger.Log("Must be in a game to use this feature"); } else { using (ZetaDia.Memory.AcquireFrame()) { ZetaDia.Actors.Update(); Core.Logger.Log("Scanning Character for Stashed Items"); SelectItems(InventoryManager.StashItems); } } } else { ZetaDia.Actors.Update(); Core.Logger.Log("Scanning Character for Stashed Items"); SelectItems(InventoryManager.StashItems); } } catch (Exception ex) { Core.Logger.Error("Exception in SelectAllCommand {0}", ex); } }); AdvancedOptionCommand = new RelayCommand(parameter => { try { if (parameter == null) { return; } Core.Logger.Verbose("AdvancedOptionCommand Fired {0}", parameter.ToString()); var item = parameter as ComboBoxItem; var selectedPropertyName = item != null ? item.Tag.ToString() : parameter.ToString(); switch (selectedPropertyName) { case "SelectAllCommand": SelectAllCommand.Execute(null); break; case "SelectNoneCommand": SelectNoneCommand.Execute(null); break; case "ClearRulesCommand": ClearRulesCommand.Execute(null); break; case "AddAllSetsCommand": AddAllSetsCommand.Execute(null); break; case "AddAllLegendaryAffixCommand": AddAllLegendaryAffixCommand.Execute(null); break; case "Add24ItemsCommand": Add24ItemsCommand.Execute(null); break; } } catch (Exception ex) { Core.Logger.Error("Exception in AdvancedOptionCommand: {0} {1}", ex.Message, ex.InnerException); } }); SelectAllCommand = new RelayCommand(parameter => { try { if (SelectedTab == Tab.Legendary) { Core.Logger.Log("Selecting all items"); using (Collection.DeferRefresh()) { SelectedItems = new List <LItem>(DisplayItems); UpdateSelectedItems(); } return; } if (SelectedTab == Tab.ItemType) { Core.Logger.Log("Selecting all item types."); ItemTypes.ForEach(i => i.IsSelected = true); } } catch (Exception ex) { Core.Logger.Error("Exception in SelectAllCommand {0}", ex); } }); Add24ItemsCommand = new RelayCommand(parameter => { try { Core.Logger.Log("Add24ItemsCommand Not Implemented"); AddToSelection(item => ItemListPresets.Patch24Items.Contains(item.Id)); } catch (Exception ex) { Core.Logger.Error("Exception in SelectAllCommand {0}", ex); } }); AddAllSetsCommand = new RelayCommand(parameter => { try { Core.Logger.Log("AddAllSetsCommand Not Implemented"); AddToSelection(item => item.IsSetItem); } catch (Exception ex) { Core.Logger.Error("Exception in SelectAllCommand {0}", ex); } }); AddAllLegendaryAffixCommand = new RelayCommand(parameter => { try { Core.Logger.Log("Selecting all items with a legendary affix"); AddToSelection(item => !string.IsNullOrEmpty(item.LegendaryAffix)); } catch (Exception ex) { Core.Logger.Error("Exception in SelectAllLegendaryAffixCommand {0}", ex); } }); SelectNoneCommand = new RelayCommand(parameter => { try { if (SelectedTab == Tab.Legendary) { Core.Logger.Log("Deselecting all legendary items"); using (Collection.DeferRefresh()) { SelectedItems = new List <LItem>(); CreateView(); UpdateSelectedItems(); } return; } if (SelectedTab == Tab.ItemType) { using (ItemTypes.ViewSource.DeferRefresh()) { foreach (var itemType in ItemTypes) { itemType.IsSelected = false; } } } } catch (Exception ex) { Core.Logger.Error("Exception in SelectNoneCommand {0}", ex); } }); ClearRulesCommand = new RelayCommand(parameter => { try { if (SelectedTab == Tab.Legendary) { Core.Logger.Log("Removing rules from all legendary items."); using (Collection.DeferRefresh()) { SelectedItems.ForEach(i => i.Rules = new ObservableCollection <LRule>()); UpdateSelectedItems(); } return; } if (SelectedTab == Tab.ItemType) { Core.Logger.Log("Removing rules from all item types."); ItemTypes.ForEach(i => i.Rules = new FullyObservableCollection <LRule>()); } } catch (Exception ex) { Core.Logger.Error("Exception in ClearAllRulesCommand {0}", ex); } }); ResetFilterCommand = new RelayCommand(parameter => { FilterText = string.Empty; }); EnableItemListCommand = new RelayCommand(parameter => { Core.Logger.Log("Setting ItemFilterMode to ItemList"); UILoader.DataContext.Items.LegendaryMode = LegendaryMode.ItemList; }); LoadModalCommand = new RelayCommand(parameter => { if (parameter == null) { return; } ModalPage page; if (Enum.TryParse(parameter.ToString(), out page)) { if (page != ModalPage.None) { SelectedModalPage = page; IsModalVisible = true; } ExportCode = string.Empty; if (page == ModalPage.Export) { ExportCommand.Execute(parameter); } } Core.Logger.Log("Selecting modal content... {0}", parameter.ToString()); }); CloseModalCommand = new RelayCommand(parameter => { IsModalVisible = false; }); ImportCommand = new RelayCommand(parameter => { Core.Logger.Log("Importing ItemList..."); var oldSlected = _selectedItems.Count; ImportFromCode(ExportCode); Core.Logger.Log("Selected Before = {0} After = {1}", oldSlected, _selectedItems.Count); IsModalVisible = false; }); ExportCommand = new RelayCommand(parameter => { Core.Logger.Log("Exporting ItemList... {0}", parameter); ExportCode = CreateExportCode(); }); }
private void ShotCommand_Execute() { SelectedItems.ForEach((el) => el.Shot()); }