Esempio n. 1
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to.</param>
        /// <param name="v">The view to connect to.</param>
        /// <param name="parentPresenter">The parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter parentPresenter)
        {
            if (model is ITestable t)
            {
                t.Test(false, true);
            }

            presenter                = parentPresenter;
            view                     = v as IDualGridView;
            tableModel               = model as IModelAsTable;
            tables                   = tableModel.Tables;
            view.Grid1.DataSource    = tables[0];
            view.Grid2.DataSource    = tables.Count > 1 ? tables[1] : null;
            view.Grid1.CellsChanged += OnCellValueChanged1;
            view.Grid2.CellsChanged += OnCellValueChanged2;

            bool readOnly = !tableModel.GetType().GetProperty("Tables").CanWrite;

            view.Grid1.ReadOnly = readOnly;
            view.Grid2.ReadOnly = readOnly;

            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            gridPresenter1 = new GridPresenter();
            gridPresenter1.Attach(model, view.Grid1, parentPresenter);
            gridPresenter2 = new GridPresenter();
            gridPresenter2.Attach(model, view.Grid2, parentPresenter);

            intellisense = new IntellisensePresenter(view.Grid2 as ViewBase);
            intellisense.ItemSelected     += OnIntellisenseItemSelected;
            view.Grid2.ContextItemsNeeded += OnIntellisenseItemsNeeded;
        }
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                // Create the grid to display data in
                gridView = new GridView(clemPresenter.view as ViewBase);
                GridPresenter gridPresenter = new GridPresenter();

                // Generate the table using the model
                pivot = clemPresenter.clemModel as ReportPivot;
                gridView.DataSource = pivot.GenerateTable();
                gridPresenter.Attach(null, gridView, clemPresenter.explorerPresenter);

                // Attach the view to display data

                clem = clemPresenter.view as CLEMView;
                clem.AddTabView("Data", gridView);
                clemPresenter.presenterList.Add("Data", this);

                //clem.TabSelected += Refresh;
            }
            catch (Exception err)
            {
                clemPresenter.explorerPresenter.MainPresenter.ShowError(err);
            }
        }
Esempio n. 3
0
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                // Create the grid to display data in
                gridView = new GridView(clemPresenter.View as ViewBase);
                GridPresenter gridPresenter = new GridPresenter();

                // Create the SQL display
                sqlView = new TextInputView(clemPresenter.View as ViewBase);

                // Generate the table using the model
                pivot = clemPresenter.ClemModel as ReportPivot;
                gridPresenter.Attach(null, gridView, clemPresenter.ExplorerPresenter);

                // Attach the views to display data
                clem = clemPresenter.View as CLEMView;

                clem.AddTabView("Data", gridView);
                clemPresenter.PresenterList.Add("Data", this);

                clem.AddTabView("SQL", sqlView);
                clemPresenter.PresenterList.Add("SQL", this);
            }
            catch (Exception err)
            {
                clemPresenter.ExplorerPresenter.MainPresenter.ShowError(err);
            }
        }
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to.</param>
        /// <param name="v">The view to connect to.</param>
        /// <param name="parentPresenter">The parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter parentPresenter)
        {
            explorerPresenter = parentPresenter;
            view         = v as IPropertyAndGridView;
            intellisense = new IntellisensePresenter(view as ViewBase);
            intellisense.ItemSelected += OnIntellisenseItemSelected;
            tableModel = model as IModelAsTable;
            if (tableModel.Tables.Count != 1)
            {
                throw new Exception("PropertyAndTablePresenter must have a single data table.");
            }
            table = tableModel.Tables[0];
            view.Grid2.DataSource          = table;
            view.Grid2.CellsChanged       += OnCellValueChanged2;
            view.Grid2.NumericFormat       = null;
            view.Grid2.ContextItemsNeeded += OnContextItemsNeeded;
            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            if (Configuration.Settings.UseNewPropertyPresenter)
            {
                propertyPresenter = new SimplePropertyPresenter();
            }
            else
            {
                propertyPresenter = new PropertyPresenter();
            }
            explorerPresenter.ApsimXFile.Links.Resolve(propertyPresenter);
            propertyPresenter.Attach(model, view.PropertiesView, parentPresenter);
            gridPresenter = new GridPresenter();
            gridPresenter.Attach(model, view.Grid2, parentPresenter);
        }
Esempio n. 5
0
        /// <summary>
        /// Attach the presenter to the model and view.
        /// </summary>
        /// <param name="model">The model object.</param>
        /// <param name="view">The view object.</param>
        /// <param name="explorerPresenter">The explorer presenter.</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            forestryModel  = model as TreeProxy;
            forestryViewer = view as TreeProxyView;
            presenter      = explorerPresenter;

            AttachData();
            forestryViewer.OnCellEndEdit          += OnCellEndEdit;
            presenter.CommandHistory.ModelChanged += OnModelChanged;

            propertyPresenter = new PropertyPresenter();
            propertyPresenter.Attach(forestryModel, forestryViewer.ConstantsGrid, explorerPresenter);
            spatialGridPresenter.Attach(forestryModel, forestryViewer.SpatialDataGrid, explorerPresenter);
            temporalGridPresenter.Attach(forestryModel, forestryViewer.TemporalDataGrid, explorerPresenter);
        }
Esempio n. 6
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to.</param>
        /// <param name="v">The view to connect to.</param>
        /// <param name="parentPresenter">The parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter parentPresenter)
        {
            presenter                = parentPresenter;
            view                     = v as IDualGridView;
            tableModel               = model as IModelAsTable;
            tables                   = tableModel.Tables;
            view.Grid1.DataSource    = tables[0];
            view.Grid2.DataSource    = tables[1];
            view.Grid1.CellsChanged += OnCellValueChanged1;
            view.Grid2.CellsChanged += OnCellValueChanged2;
            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            gridPresenter1 = new GridPresenter();
            gridPresenter1.Attach(model, view.Grid1, parentPresenter);
            gridPresenter2 = new GridPresenter();
            gridPresenter2.Attach(model, view.Grid2, parentPresenter);

            intellisense = new IntellisensePresenter(view.Grid2 as ViewBase);
            intellisense.ItemSelected     += OnIntellisenseItemSelected;
            view.Grid2.ContextItemsNeeded += OnIntellisenseItemsNeeded;
        }
Esempio n. 7
0
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The model to connect to.</param>
        /// <param name="v">The view to connect to.</param>
        /// <param name="parentPresenter">The parent explorer presenter.</param>
        public void Attach(object model, object v, ExplorerPresenter parentPresenter)
        {
            explorerPresenter = parentPresenter;
            view       = v as IDualGridView;
            tableModel = model as IModelAsTable;
            if (tableModel.Tables.Count != 1)
            {
                throw new Exception("PropertyAndTablePresenter must have a single data table.");
            }
            table = tableModel.Tables[0];
            view.Grid2.DataSource    = table;
            view.Grid2.CellsChanged += OnCellValueChanged2;
            view.Grid2.NumericFormat = null;
            parentPresenter.CommandHistory.ModelChanged += OnModelChanged;

            propertyPresenter = new PropertyPresenter();
            explorerPresenter.ApsimXFile.Links.Resolve(propertyPresenter);
            propertyPresenter.Attach(model, view.Grid1, parentPresenter);
            gridPresenter = new GridPresenter();
            gridPresenter.Attach(model, view.Grid2, parentPresenter);
        }
Esempio n. 8
0
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                clem  = clemPresenter.View as CLEMView;
                query = clemPresenter.ClemModel as ReportQuery;

                var store = query.FindInScope <IDataStore>();

                // Create the Data presenter
                gridView = new GridView(clemPresenter.View as ViewBase);

                var gridPresenter = new GridPresenter();
                gridPresenter.Attach(null, gridView, clemPresenter.ExplorerPresenter);

                // Attach the tab
                clem.AddTabView("Data", gridView);
                clemPresenter.PresenterList.Add("Data", this);
            }
            catch (Exception err)
            {
                clemPresenter.ExplorerPresenter.MainPresenter.ShowError(err);
            }
        }
        /// <summary>
        /// Attach the model to the view.
        /// </summary>
        /// <param name="model">The underlying model we are to use</param>
        /// <param name="view">The underlying view we are to attach to</param>
        /// <param name="explorerPresenter">Our parent explorerPresenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model = model as Model;
            this.view  = view as IProfileView;
            profileGrid.Attach(model, this.view.ProfileGrid, explorerPresenter);
            this.explorerPresenter = explorerPresenter;

            this.view.ShowView(false);

            // Setup the property presenter and view. Hide the view if there are no properties to show.
            this.propertyPresenter = new PropertyPresenter();
            this.propertyPresenter.Attach(this.model, this.view.PropertyGrid, this.explorerPresenter);

            // Create a list of profile (array) properties. Create a table from them and
            // hand the table to the profile grid.
            this.FindAllProperties(this.model);

            // Populate the grid
            this.PopulateGrid();

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");

            if (this.graph == null)
            {
                this.view.ShowGraph(false);
            }
            else
            {
                this.parentForGraph = this.model.Parent as IModel;
                if (this.parentForGraph != null)
                {
                    this.parentForGraph.Children.Add(this.graph);
                    this.graph.Parent = this.parentForGraph;
                    this.view.ShowGraph(true);
                    int padding = (this.view as ProfileView).MainWidget.Allocation.Width / 2 / 2;
                    this.view.Graph.LeftRightPadding = padding;
                    this.graphPresenter = new GraphPresenter();
                    for (int col = 0; col < this.propertiesInGrid.Count; col++)
                    {
                        VariableProperty property   = this.propertiesInGrid[col];
                        string           columnName = property.Description;

                        // crop colours
                        if (property.CropName != null && columnName.Contains("LL"))
                        {
                            Series cropLLSeries = new Series();
                            cropLLSeries.Name         = columnName;
                            cropLLSeries.Colour       = ColourUtilities.ChooseColour(this.graph.Children.Count);
                            cropLLSeries.Line         = LineType.Solid;
                            cropLLSeries.Marker       = MarkerType.None;
                            cropLLSeries.Type         = SeriesType.Scatter;
                            cropLLSeries.ShowInLegend = true;
                            cropLLSeries.XAxis        = Axis.AxisType.Top;
                            cropLLSeries.YAxis        = Axis.AxisType.Left;
                            cropLLSeries.YFieldName   = "[Soil].DepthMidPoints";
                            cropLLSeries.XFieldName   = "[" + (property.Object as Model).Name + "]." + property.Name;
                            cropLLSeries.Parent       = this.graph;

                            this.graph.Children.Add(cropLLSeries);
                        }
                    }

                    this.graphPresenter.Attach(this.graph, this.view.Graph, this.explorerPresenter);
                }
            }

            // Trap the invoking of the ProfileGrid 'CellValueChanged' event so that
            // we can save the contents.
            this.view.ProfileGrid.CellsChanged += this.OnProfileGridCellValueChanged;

            // Trap the right click on column header so that we can potentially put
            // units on the context menu.
            this.view.ProfileGrid.GridColumnClicked += this.OnGridColumnClicked;

            // Trap the model changed event so that we can handle undo.
            this.explorerPresenter.CommandHistory.ModelChanged += this.OnModelChanged;

            this.view.ShowView(true);
        }