public void InsertOption(int index, ICharacterOption characterOption) { OptionGroup <T> group = (optionGroup as OptionGroup <T>); var existingIndex = group.IndexOf((T)characterOption); if (existingIndex >= 0) { group.RemoveAt(existingIndex); if (index > 0 && index >= group.Count) { index -= 1; } } group.Insert(index, (T)characterOption); }
public OptionGroupViewModel(IBusyService busyService, IUnityContainer container, IMessageBoxService messageBoxService, IDesktopKeyEventHandler keyEventHandler, EventAggregator eventAggregator, OptionGroup <T> optionGroup, Character owner) : base(busyService, container) { this.eventAggregator = eventAggregator; this.messageBoxService = messageBoxService; this.desktopKeyEventHandler = keyEventHandler; this.Owner = owner; this.Owner.PropertyChanged += Owner_PropertyChanged; this.OptionGroup = optionGroup; this.eventAggregator.GetEvent <AttackInitiatedEvent>().Subscribe(this.AttackInitiated); this.eventAggregator.GetEvent <AttackExecutionsFinishedEvent>().Subscribe(this.OnAttackExecutionFinished); this.eventAggregator.GetEvent <CombatMovementChangedEvent>().Subscribe((CharacterMovement cm) => { OnPropertyChanged("IsNonCombatMovementSelected"); OnPropertyChanged("IsCombatMovementSelected"); }); if (!this.IsStandardOptionGroup) { this.eventAggregator.GetEvent <RemoveOptionEvent>().Subscribe(this.RemoveOption); } clickTimer_AbilityPlay.AutoReset = false; clickTimer_AbilityPlay.Interval = 2000; clickTimer_AbilityPlay.Elapsed += new ElapsedEventHandler(clickTimer_AbilityPlay_Elapsed); InitializeCommands(); SetTooltips(); this.InitializeDesktopKeyEventHandlers(); }