public void RefreshSpouse() { this._spouses = new List <Hero>(); if (null != this._spouseViews) { this._spouseViews.Clear(); } this._spouseViews = new MBBindingList <SpouseServiceItemVM>(); if (null != Hero.MainHero.Spouse) { this._spouses.Add(Hero.MainHero.Spouse); } Hero.MainHero.ExSpouses.ToList().ForEach((obj) => { if (!this._spouses.Contains(obj)) { if (obj.IsAlive) { this._spouses.Add(obj); } } }); this._spouses.ForEach((obj) => { if (null != obj) { SpouseServiceItemVM vm = new SpouseServiceItemVM(obj, OnSelectedSpouse); this._spouseViews.Add(vm); if (obj == Hero.MainHero.Spouse) { this._lastPrimaryView = vm; } } }); if (this._spouses.Count > 0) { this._selectedHero = this._spouses.First(); SpouseServiceItemVM defaultItem = this._spouseViews.First(); defaultItem.IsSelected = true; OnSelectedSpouse(defaultItem); } }
public void SetPrimarySpouse() { if (this._selectedHero == Hero.MainHero.Spouse) { return; } SpouseOperation.SetPrimarySpouse(this._selectedHero); this.IsNotPrimarySpouse = false; if (null != this._currentSpouseView) { this._currentSpouseView.RefreshValues(); } if (null != this._lastPrimaryView) { this._lastPrimaryView.RefreshValues(); } this._lastPrimaryView = this._currentSpouseView; }
public void OnSelectedSpouse(SpouseServiceItemVM spouseItemVM) { if (spouseItemVM != this._currentSpouseView) { if (null != _currentSpouseView) { this._currentSpouseView.IsSelected = false; } this._currentSpouseView = spouseItemVM; this._selectedHero = spouseItemVM.Hero; if (null == this.SelectedCharacter) { this.SelectedCharacter = new SpouseCharacterVM(SpouseCharacterVM.StanceTypes.None); } this.SelectedCharacter.FillFrom(_selectedHero.CharacterObject, -1); this.CanGetPregnancy = !this._selectedHero.IsPregnant; this.IsNotPrimarySpouse = this._selectedHero != Hero.MainHero.Spouse; } }