src/Lurker.UI/ViewModels/OutgoingbarViewModel.cs
/// <summary>
/// Handles the CollectionChanged event of the Offers control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Collections.Specialized.NotifyCollectionChangedEventArgs"/> instance containing the event data.</param>
Handles the CollectionChanged event of the Offers control.
Handles the CollectionChanged event of the Offers control .
private void Offers_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (this.Offers.Any(o => !o.Waiting))
            {
                this._timer.Start();
            }
            else
            {
                this._timer.Stop();
            }
            if (e.NewItems != null)
            {
                foreach (var offer in e.NewItems)
                {
                    var outgoingOffer = offer as OutgoingOfferViewModel;
                    if (string.IsNullOrEmpty(this.SearchValue))
                    {
                        this.FilteredOffers.Insert(this.Offers.IndexOf(outgoingOffer), outgoingOffer);
                    }
                    else if (outgoingOffer.PlayerName.ToLower().Contains(this.SearchValue.ToLower()))
                    {
                        this.FilteredOffers.Insert(0, outgoingOffer);
                    }
                }
            }
            if (e.OldItems != null)
            {
                foreach (var offer in e.OldItems)
                {
                    this.FilteredOffers.Remove(offer as OutgoingOfferViewModel);
                }
            }
            if (!this.AnyOffer)
            {
                this.SearchValue = string.Empty;
            }
            this.NotifyOfPropertyChange("AnyOffer");
        }
private void Offers_CollectionChanged ( object sender , System . Collections . Specialized . NotifyCollectionChangedEventArgs e ) { if ( this . Offers . Any ( o => ! o . Waiting ) ) { this . _timer . Start ( ) ; } else { this . _timer . Stop ( ) ; } if ( e . NewItems != null ) { foreach ( var offer in e . NewItems ) { var outgoingOffer = offer as OutgoingOfferViewModel ; if ( string . IsNullOrEmpty ( this . SearchValue ) ) { this . FilteredOffers . Insert ( this . Offers . IndexOf ( outgoingOffer ) , outgoingOffer ) ; } else if ( outgoingOffer . PlayerName . ToLower ( ) . Contains ( this . SearchValue . ToLower ( ) ) ) { this . FilteredOffers . Insert ( 0 , outgoingOffer ) ; } } } if ( e . OldItems != null ) { foreach ( var offer in e . OldItems ) { this . FilteredOffers . Remove ( offer as OutgoingOfferViewModel ) ; } } if ( ! this . AnyOffer ) { this . SearchValue = string . Empty ; } this . NotifyOfPropertyChange ( " " ) ; }
Handles the CollectionChanged event of the Offers control.
Handles the CollectionChanged event of the Offers control .
sender
object
The source of the event.
The source of the event .
e
System.Collections.Specialized.NotifyCollectionChangedEventArgs
The  instance containing the event data.
The instance containing the event data .