private void btnDuplicateWeatherTypeList_Click(object sender, EventArgs e) { if (lbxWeatherTypeLists.SelectedIndex >= 0) { WeatherTypeList newCopy = prntForm.weathersList[lbxWeathers.SelectedIndex].weatherTypeLists[lbxWeatherTypeLists.SelectedIndex].DeepCopy(); newCopy.tag = "newWeatherTypeListTag_" + prntForm.mod.nextIdNumber.ToString(); prntForm.weathersList[lbxWeathers.SelectedIndex].weatherTypeLists.Add(newCopy); refreshListBox(); } }
public WeatherTypeList DeepCopy() { //WeatherTypeList other = (WeatherTypeList)this.MemberwiseClone(); WeatherTypeList other = new WeatherTypeList(); other._name = this._name; other.name = this.name; other._tag = this._tag; other.tag = this.tag; foreach (WeatherTypeListItem wtli in this.weatherTypeListItems) { WeatherTypeListItem wtli2 = wtli.DeepCopy(); other.weatherTypeListItems.Add(wtli2); } return(other); }
public Weather DeepCopy() { //Weather other = (Weather)this.Clone(); Weather other = new Weather(); other._name = this._name; other.name = this.name; other._tag = this._tag; other.tag = this.tag; foreach (WeatherTypeList wtl in this.weatherTypeLists) { WeatherTypeList wtl2 = wtl.DeepCopy(); other.weatherTypeLists.Add(wtl2); } return(other); }
private void btnAddWeatherTypeList_Click(object sender, EventArgs e) { if (lbxWeathers.SelectedIndex >= 0) { WeatherTypeList newTS = new WeatherTypeList(); if (lbxWeatherTypeLists.Items.Count == 0) { newTS.name = "entryList"; } else { newTS.name = "newWeatherTypeList"; } newTS.tag = "newWeatherTypeListTag_" + prntForm.mod.nextIdNumber.ToString(); prntForm.weathersList[lbxWeathers.SelectedIndex].weatherTypeLists.Add(newTS); refreshListBoxAdd2(); } }