/// <summary> /// Attach inherited class additional presenters is needed /// </summary> public void AttachExtraPresenters(CLEMPresenter clemPresenter) { //UI Results try { ActivityLedgerGridView ledgerView = new ActivityLedgerGridView(clemPresenter.View as ViewBase); ReportView rv = new ReportView(clemPresenter.View as ViewBase); ViewBase reportView = new ViewBase(rv, "ApsimNG.Resources.Glade.DataStoreView.glade"); Model report = clemPresenter.Model as Model; Simulations simulations = report.FindAncestor <Simulations>(); if (simulations != null) { dataStore = simulations.FindChild <IDataStore>(); } DataStorePresenter dataStorePresenter = new DataStorePresenter(); ActivityLedgerGridPresenter activityGridPresenter = new ActivityLedgerGridPresenter(); Simulation simulation = report.FindAncestor <Simulation>(); Zone paddock = report.FindAncestor <Zone>(); if (paddock != null) { dataStorePresenter.ZoneFilter = paddock; } if (simulation != null) { if (simulation.Parent is Experiment) { dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment; } else { dataStorePresenter.SimulationFilter = simulation; } } dataStorePresenter.Attach(dataStore, reportView, clemPresenter.ExplorerPresenter); activityGridPresenter.CreateHtml = (clemPresenter.Model as ReportActivitiesPerformed).CreateHTML; activityGridPresenter.ModelReport = report as Report; activityGridPresenter.ModelName = report.Name; activityGridPresenter.SimulationName = simulation.Name; activityGridPresenter.ZoneName = paddock.Name; activityGridPresenter.Attach(dataStore, ledgerView, clemPresenter.ExplorerPresenter); dataStorePresenter.tableDropDown.SelectedValue = report.Name; (clemPresenter.View as CLEMView).AddTabView("Display", ledgerView); clemPresenter.PresenterList.Add("Display", activityGridPresenter); (clemPresenter.View as CLEMView).AddTabView("Data", reportView); clemPresenter.PresenterList.Add("Data", dataStorePresenter); } catch (Exception err) { this.explorerPresenter.MainPresenter.ShowError(err); } }
/// <summary>Attach the model (report) and the view (IReportView)</summary> public void Attach(object model, object view, ExplorerPresenter explorerPresenter) { this.report = model as Report; this.explorerPresenter = explorerPresenter; this.view = view as IReportActivityLedgerView; this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged; Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations; if (simulations != null) { dataStore = Apsim.Child(simulations, typeof(IDataStore)) as IDataStore; } dataStorePresenter = new DataStorePresenter(); activityGridPresenter = new ActivityLedgerGridPresenter(); Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation; Zone paddock = Apsim.Parent(report, typeof(Zone)) as Zone; if (paddock != null) { dataStorePresenter.ZoneFilter = paddock; } if (simulation != null) { if (simulation.Parent is Experiment) { dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment; } else { dataStorePresenter.SimulationFilter = simulation; } } dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter); activityGridPresenter.ModelName = this.report.Name; activityGridPresenter.SimulationName = simulation.Name; activityGridPresenter.ZoneName = paddock.Name; activityGridPresenter.Attach(dataStore, this.view.DisplayView, explorerPresenter); dataStorePresenter.tableDropDown.SelectedValue = this.report.Name; }
/// <summary>Attach the model (report) and the view (IReportView)</summary> public void Attach(object Model, object View, ExplorerPresenter explorerPresenter) { this.report = Model as Report; this.explorerPresenter = explorerPresenter; this.view = View as IReportActivityLedgerView; this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged; Simulations simulations = Apsim.Parent(report, typeof(Simulations)) as Simulations; if (simulations != null) { dataStore = Apsim.Child(simulations, typeof(IStorageReader)) as IStorageReader; } /// TBI this.view.VariableList.SetSyntaxHighlighter("Report"); dataStorePresenter = new DataStorePresenter(); activityGridPresenter = new ActivityLedgerGridPresenter(); Simulation simulation = Apsim.Parent(report, typeof(Simulation)) as Simulation; if (simulation != null) { if (simulation.Parent is Experiment) { dataStorePresenter.ExperimentFilter = simulation.Parent as Experiment; } else { dataStorePresenter.SimulationFilter = simulation; } } dataStorePresenter.Attach(dataStore, this.view.DataStoreView, explorerPresenter); activityGridPresenter.ModelName = this.report.Name; activityGridPresenter.Attach(dataStore, this.view.DisplayView, explorerPresenter); this.view.DataStoreView.TableList.SelectedValue = this.report.Name; }