/// <summary> /// Attaches the model to the view. /// </summary> /// <param name="model">The BiomassRemoval model to connect.</param> /// <param name="view">The view. Should be a <see cref="GridView"/>.</param> /// <param name="explorerPresenter">The explorer presenter controlling this presenter.</param> public override void Attach(object model, object view, ExplorerPresenter explorerPresenter) { if (!(model is BiomassRemoval)) { throw new Exception(string.Format("{0} cannot be used to display a model of type {1}.", GetType().Name, model.GetType().Name)); } base.Attach(model, view, explorerPresenter); this.model = model as BiomassRemoval; grid.CanGrow = false; DataTable data = new DataTable(); List <IModel> removalTypes = Apsim.Children(model as IModel, typeof(OrganBiomassRemovalType)).ToList(); bool hasData = removalTypes.Any(); data.Columns.Add(hasData ? "Description" : "No values are currently available", typeof(string)); data.Columns.Add(hasData ? "Value" : " ", typeof(object)); foreach (IModel child in removalTypes) { data.Rows.Add(child.Name, " "); grid.SetRowAsSeparator(data.Rows.Count - 1); PropertyPresenter propertyHandler = new PropertyPresenter(); propertyHandler.FindAllProperties(child as Model); propertyHandler.FillTable(data); } grid.DataSource = data; grid.GetColumn(0).ReadOnly = true; grid.CellsChanged += OnGridChanged; }
/// <summary> /// The user has changed the code script. /// </summary> /// <param name="sender">Sending object</param> /// <param name="e">The arguments</param> public void OnEditorLeave(object sender, EventArgs e) { // explorerPresenter.CommandHistory.ModelChanged += CommandHistory_ModelChanged; if (!intellisense.Visible) { BuildScript(); } if (scriptModel != null) { propertyPresenter.FindAllProperties(scriptModel); propertyPresenter.PopulateGrid(scriptModel); } }