private void Directory_OnDirPlacesReply(object sender, DirPlacesReplyEventArgs e) { if (InvokeRequired) { BeginInvoke((MethodInvoker) delegate { Directory_OnDirPlacesReply(sender, e); }); return; } BeginInvoke((MethodInvoker) delegate { PlacesReply(e.QueryID, e.MatchedParcels); }); }
void Directory_DirPlacesReply(object sender, DirPlacesReplyEventArgs e) { if (e.QueryID != placeSearch) { return; } if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => Directory_DirPlacesReply(sender, e))); return; } lvwPlaces.BeginUpdate(); if (e.MatchedParcels.Count == 0) { lvwPlaces.Items.Clear(); } foreach (DirectoryManager.DirectoryParcel parcel in e.MatchedParcels) { if (parcel.ID == UUID.Zero) { continue; } ListViewItem item = new ListViewItem { Name = parcel.ID.ToString(), Text = parcel.Name, Tag = parcel }; item.SubItems.Add(new ListViewItem.ListViewSubItem(item, parcel.Dwell.ToString(CultureInfo.InvariantCulture))); lvwPlaces.Items.Add(item); } lvwPlaces.Sort(); lvwPlaces.EndUpdate(); placeMatches += e.MatchedParcels.Count; btnNextPlace.Enabled = placeMatches > 100; btnPrevPlace.Enabled = placeStart != 0; if (e.MatchedParcels.Count > 0 && e.MatchedParcels[e.MatchedParcels.Count - 1].ID == UUID.Zero) { placeMatches -= 1; } lblNrPlaces.Visible = true; lblNrPlaces.Text = string.Format("{0} places found", placeMatches > 100 ? "More than " + (placeStart + 100) : (placeStart + placeMatches).ToString()); }