/// <summary>The user has clicked the add button.</summary> /// <param name="sender">Event sender</param> /// <param name="e">Event arguments</param> private void OnAddButtonClicked(object sender, EventArgs e) { Type selectedModelType = allowableChildModels.Find(m => m.Name == view.List.SelectedValue); if (selectedModelType != null) { explorerPresenter.ShowWaitCursor(true); try { // Use the pre built serialization assembly. string binDirectory = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location); string deserializerFileName = Path.Combine(binDirectory, "Models.XmlSerializers.dll"); object child = Activator.CreateInstance(selectedModelType, true); string childXML = XmlUtilities.Serialise(child, false, deserializerFileName); this.explorerPresenter.Add(childXML, Apsim.FullPath(model)); this.explorerPresenter.HideRightHandPanel(); } finally { explorerPresenter.ShowWaitCursor(false); } } }