protected override void OnLoaded() { var max = DamageStatsComparisonHelper.MaxPresets[this.comparisonPreset]; var stoppingPower = this.damageDescription.FinalDamageMultiplier; var stoppingPowerMax = DamageStatsComparisonHelper.MaxPresets.Max(p => p.Value.FinalDamageMultiplier); stoppingPower -= 1; stoppingPowerMax -= 1; stoppingPower = stoppingPowerMax * Math.Sqrt(stoppingPower / stoppingPowerMax); var isRangedWeapon = this.comparisonPreset.IsRangedWeapon; this.viewModel = new ViewModelItemTooltipInfoDamageDescription( damage: this.damageDescription.DamageValue * this.damageMultiplier, damageMax: max.DamageValue, armorPiercing: this.damageDescription.ArmorPiercingCoef, armorPiercingMax: 1, displayStoppingPower: isRangedWeapon, stoppingPower: stoppingPower, stoppingPowerMax: stoppingPowerMax, displayRange: isRangedWeapon && this.displayRange, range: this.damageDescription.RangeMax * this.rangeMultiplier, rangeMax: max.RangeMax, hasSpread: isRangedWeapon && this.fireScatterPreset.HasValue, spread: isRangedWeapon ? CalculateFireSpread(this.fireScatterPreset) : 0, spreadMax: isRangedWeapon ? LazyMaxFireSpread.Value : 0, damageProportions: this.damageDescription.DamageProportions); this.DataContext = this.viewModel; }
protected override void OnUnloaded() { this.DataContext = null; this.viewModel.Dispose(); this.viewModel = null; }