Exemplo n.º 1
0
        /// <summary>Display a view on the right hand panel in view.</summary>
        public void ShowRightHandPanel()
        {
            if (this.view.SelectedNode != string.Empty)
            {
                object model = Apsim.Get(this.ApsimXFile,  this.view.SelectedNode);

                if (model != null)
                {
                    ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                    PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;

                    if (this.advancedMode)
                    {
                        viewName = new ViewNameAttribute("UserInterface.Views.GridView");
                        presenterName = new PresenterNameAttribute("UserInterface.Presenters.PropertyPresenter");
                    }

                    if (viewName != null && presenterName != null)
                    {
                        ShowInRightHandPanel(model, viewName.ToString(), presenterName.ToString());
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>Display a view on the right hand panel in view.</summary>
        private void ShowRightHandPanel()
        {
            if (this.view.SelectedNode != string.Empty)
            {
                object model = Apsim.Get(this.ApsimXFile, this.view.SelectedNode);

                if (model != null)
                {
                    ViewNameAttribute viewName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(ViewNameAttribute), false) as ViewNameAttribute;
                    PresenterNameAttribute presenterName = ReflectionUtilities.GetAttribute(model.GetType(), typeof(PresenterNameAttribute), false) as PresenterNameAttribute;

                    if (this.advancedMode)
                    {
                        viewName = new ViewNameAttribute("UserInterface.Views.GridView");
                        presenterName = new PresenterNameAttribute("UserInterface.Presenters.PropertyPresenter");
                    }

                    if (viewName != null && presenterName != null)
                    {
                        UserControl newView = Assembly.GetExecutingAssembly().CreateInstance(viewName.ToString()) as UserControl;
                        this.currentRightHandPresenter = Assembly.GetExecutingAssembly().CreateInstance(presenterName.ToString()) as IPresenter;
                        if (newView != null && this.currentRightHandPresenter != null)
                        {
                            try
                            {
                                this.view.AddRightHandView(newView);
                                this.currentRightHandPresenter.Attach(model, newView, this);
                            }
                            catch (Exception err)
                            {
                                string message = err.Message;
                                message += "\r\n" + err.StackTrace;
                                this.ShowMessage(message, DataStore.ErrorLevel.Error);
                            }
                        }
                    }
                }
            }
        }