/// <summary> /// Fills a PlaceListSettings class (used to serialize places) with all the places in the list /// </summary> /// <param name="pls">The PlaceListSettings class that will receive the places</param> public void FillSettingsFromList(PlaceListSettings pls) { pls.places = new PlaceListSettings.PlaceData [this.Items.Count]; for (int i = 0; i < this.Items.Count; i++) { PlaceItem pi = (PlaceItem)this.Items[i].Tag; PlaceListSettings.PlaceData pd = new PlaceListSettings.PlaceData(); pd.Name = pi.pn.Name; pd.Lat = pi.pn.Lat; pd.Lon = pi.pn.Lon; int mdCount = pi.pn.metaData == null ? 0 : pi.pn.metaData.Count; pd.metadata = new PlaceListSettings.MetaDataEntry [mdCount]; int j = 0; if (pi.pn.metaData != null) { foreach (DictionaryEntry de in pi.pn.metaData) { pd.metadata[j] = new PlaceListSettings.MetaDataEntry(); pd.metadata[j].name = de.Key.ToString(); pd.metadata[j].value = de.Value.ToString(); j++; } } pls.places[i] = pd; } }
/// <summary> /// Fills a PlaceListSettings class (used to serialize places) with all the places in the list /// </summary> /// <param name="pls">The PlaceListSettings class that will receive the places</param> public void FillSettingsFromList(PlaceListSettings pls) { pls.places = new PlaceListSettings.PlaceData [this.Items.Count]; for(int i = 0; i < this.Items.Count; i++) { PlaceItem pi = (PlaceItem)this.Items[i].Tag; PlaceListSettings.PlaceData pd = new PlaceListSettings.PlaceData(); pd.Name = pi.pn.Name; pd.Lat = pi.pn.Lat; pd.Lon = pi.pn.Lon; int mdCount = pi.pn.metaData == null ? 0 : pi.pn.metaData.Count; pd.metadata = new PlaceListSettings.MetaDataEntry [mdCount]; int j = 0; if(pi.pn.metaData != null) { foreach(DictionaryEntry de in pi.pn.metaData) { pd.metadata[j] = new PlaceListSettings.MetaDataEntry(); pd.metadata[j].name = de.Key.ToString(); pd.metadata[j].value = de.Value.ToString(); j++; } } pls.places[i] = pd; } }