/// <summary> /// Lurkers the outgoing offer. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void Lurker_OutgoingOffer(object sender, Patreon.Events.OutgoingTradeEvent e) { if (this.Offers.Any(o => o.Event.Equals(e))) { return; } Execute.OnUIThread(() => { var index = 0; if (this.AnyOffer) { var value = e.Price.CalculateValue(); var closestOffer = this.Offers.Aggregate((x, y) => Math.Abs(x.PriceValue - value) < Math.Abs(y.PriceValue - value) ? x : y); index = this.Offers.IndexOf(closestOffer); if (value >= closestOffer.PriceValue) { index++; } } this.Offers.Insert(index, new OutgoingOfferViewModel(e, this._keyboardHelper, this._context, this.DockingHelper)); }); }
/// <summary> /// Lurkers the outgoing offer. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void Lurker_OutgoingOffer(object sender, Patreon.Events.OutgoingTradeEvent e) { if (this.Offers.Any(o => o.Event.Equals(e))) { return; } Execute.OnUIThread(() => this.Offers.Insert(0, new OutgoingOfferViewModel(e, this._keyboardHelper, this._context))); }