/// <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 the list with all the places in a PlaceListSettings class (used to serialize places) /// </summary> /// <param name="pls">The PlaceListSettings class that contains all the places</param> public void FillListFromSettings(PlaceListSettings pls) { // clear the list this.Items.Clear(); if (pls.places == null) { return; // nothing to do } foreach (PlaceListSettings.PlaceData pd in pls.places) { PlaceItem pi = new PlaceItem(); pi.pn = new WorldWindPlacename(); pi.pn.Name = pd.Name; pi.pn.Lat = (float)pd.Lat; pi.pn.Lon = (float)pd.Lon; pi.pn.metaData = new Hashtable(); for (int i = 0; i < pd.metadata.Length; i++) { pi.pn.metaData.Add(pd.metadata[i].name, pd.metadata[i].value); } AddPlace(pi); } }
/// <summary> /// Fills the list with all the places in a PlaceListSettings class (used to serialize places) /// </summary> /// <param name="pls">The PlaceListSettings class that contains all the places</param> public void FillListFromSettings(PlaceListSettings pls) { // clear the list this.Items.Clear(); if(pls.places == null) return; // nothing to do foreach(PlaceListSettings.PlaceData pd in pls.places) { PlaceItem pi = new PlaceItem(); pi.pn = new WorldWindPlacename(); pi.pn.Name = pd.Name; pi.pn.Lat = (float)pd.Lat; pi.pn.Lon = (float)pd.Lon; pi.pn.metaData = new Hashtable(); for(int i=0; i < pd.metadata.Length; i++) { pi.pn.metaData.Add(pd.metadata[i].name, pd.metadata[i].value); } AddPlace(pi); } }
/// <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; } }