Example #1
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs = model as XYPairs;
            this.xyPairsView = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent = this.xyPairs;
            (this.graph.Series[0] as Series).XFieldName = Apsim.FullPath(graph.Parent) + ".X";
            (this.graph.Series[0] as Series).YFieldName = Apsim.FullPath(graph.Parent) + ".Y";
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
            string xAxisTitle = LookForXAxisTitle();
            if (xAxisTitle != null)
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Bottom, xAxisTitle, false, double.NaN, double.NaN, double.NaN);

            string yAxisTitle = LookForYAxisTitle();
            if (yAxisTitle != null)
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Left, yAxisTitle, false, double.NaN, double.NaN, double.NaN);

            xyPairsView.Graph.FormatTitle(xyPairs.Parent.Name);
        }
Example #2
0
        /// <summary>
        /// Attaches the view to the model.
        /// </summary>
        /// <param name="model">The linear after threshold model.</param>
        /// <param name="viewObject">The view  - should be an XYPairsView.</param>
        /// <param name="parent">The explorer presenter for this tab.</param>
        public void Attach(object model, object viewObject, ExplorerPresenter parent)
        {
            function = model as LinearAfterThresholdFunction;
            if (function == null)
            {
                throw new ArgumentException(string.Format("Attempted to display a model of type {0} using the LinearAfterThresholdPresenter.", model.GetType().ToString()));
            }

            view = viewObject as XYPairsView;
            if (view == null)
            {
                throw new ArgumentException(string.Format("Attempted to use a view of type {0} from the LinearAfterThresholdPresenter. View should be an XYPairsView.", viewObject.GetType().ToString()));
            }

            presenter           = parent;
            propertiesPresenter = new PropertyPresenter();
            propertiesPresenter.Attach(function, view.VariablesGrid, presenter);
            DrawGraph();
            view.VariablesGrid.CellsChanged += OnCellsChanged;
        }
Example #3
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs = model as XYPairs;
            this.xyPairsView = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent = this.xyPairs;
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
        }
Example #4
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs           = model as XYPairs;
            this.xyPairsView       = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent   = this.xyPairs;
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
        }
Example #5
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public override void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xYPairs     = model as XYPairs;
            this.xYPairsView = view as XYPairsView;
            this.presenter   = explorerPresenter as ExplorerPresenter;
            base.Attach(model, xYPairsView.VariablesGrid, explorerPresenter);
            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xYPairs);

            this.PopulateView();

            this.presenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource("ApsimNG.Resources.XYPairsGraph.xml");
            this.xYPairs.Children.Add(this.graph);
            this.graph.Parent = this.xYPairs;
            (this.graph.Series[0] as Series).XFieldName = graph.Parent.FullPath + ".X";
            (this.graph.Series[0] as Series).YFieldName = graph.Parent.FullPath + ".Y";
            this.graphPresenter = new GraphPresenter();
            this.presenter.ApsimXFile.Links.Resolve(graphPresenter);
            this.graphPresenter.Attach(this.graph, this.xYPairsView.Graph, this.presenter);
            string xAxisTitle = LookForXAxisTitle();

            if (xAxisTitle != null)
            {
                xYPairsView.Graph.FormatAxis(Axis.AxisType.Bottom, xAxisTitle, false, double.NaN, double.NaN, double.NaN, false);
            }

            string yAxisTitle = LookForYAxisTitle();

            if (yAxisTitle != null)
            {
                xYPairsView.Graph.FormatAxis(Axis.AxisType.Left, yAxisTitle, false, double.NaN, double.NaN, double.NaN, false);
            }

            xYPairsView.Graph.FormatTitle(xYPairs.Parent.Name);
        }
Example #6
0
        /// <summary>
        /// Attach the view to the model.
        /// </summary>
        /// <param name="model">The initial water model</param>
        /// <param name="view">The initial water view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.xyPairs           = model as XYPairs;
            this.xyPairsView       = view as XYPairsView;
            this.explorerPresenter = explorerPresenter as ExplorerPresenter;

            // Create a list of profile (array) properties. PpoulateView wil create a table from them and
            // hand the table to the variables grid.
            this.FindAllProperties(this.xyPairs);

            this.PopulateView();

            this.explorerPresenter.CommandHistory.ModelChanged += OnModelChanged;

            // Populate the graph.
            this.graph = Utility.Graph.CreateGraphFromResource(model.GetType().Name + "Graph");
            this.xyPairs.Children.Add(this.graph);
            this.graph.Parent   = this.xyPairs;
            this.graphPresenter = new GraphPresenter();
            this.graphPresenter.Attach(this.graph, this.xyPairsView.Graph, this.explorerPresenter);
            string xAxisTitle = LookForXAxisTitle();

            if (xAxisTitle != null)
            {
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Bottom, xAxisTitle, false, double.NaN, double.NaN, double.NaN);
            }

            string yAxisTitle = LookForYAxisTitle();

            if (yAxisTitle != null)
            {
                xyPairsView.Graph.FormatAxis(Axis.AxisType.Left, yAxisTitle, false, double.NaN, double.NaN, double.NaN);
            }

            xyPairsView.Graph.FormatTitle(xyPairs.Parent.Name);
        }