示例#1
0
        /// <summary>The user has clicked the add button.</summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event arguments</param>
        private void OnAddButtonClicked(object sender, EventArgs e)
        {
            var namespaceWords = tree.SelectedNode.Split(".".ToCharArray()).ToList();
            var modelName      = namespaceWords.Last();

            var selectedModelType = this.allowableChildModels.FirstOrDefault(m => m.ModelName == modelName);

            if (selectedModelType != null)
            {
                this.explorerPresenter.MainPresenter.ShowWaitCursor(true);
                try
                {
                    IModel child = (IModel)Activator.CreateInstance(selectedModelType.ModelType, true);
                    child.Name = modelName;
                    if (child is ModelCollectionFromResource)
                    {
                        (child as ModelCollectionFromResource).ResourceName = selectedModelType.ModelName;
                    }
                    explorerPresenter.Add(child, Apsim.FullPath(this.model));
                }
                finally
                {
                    this.explorerPresenter.MainPresenter.ShowWaitCursor(false);
                }
            }
        }
示例#2
0
        /// <summary>The user has clicked the add button.</summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event arguments</param>
        private void OnAddButtonClicked(object sender, EventArgs e)
        {
            Type selectedModelType = this.allowableChildModels.Find(m => m.FullName == this.view.List.SelectedValue);

            if (selectedModelType != null)
            {
                this.explorerPresenter.MainPresenter.ShowWaitCursor(true);
                try
                {
                    IModel child = (IModel)Activator.CreateInstance(selectedModelType, true);
                    explorerPresenter.Add(child, Apsim.FullPath(this.model));
                }
                finally
                {
                    this.explorerPresenter.MainPresenter.ShowWaitCursor(false);
                }
            }
        }
示例#3
0
        /// <summary>The user has clicked the add button.</summary>
        /// <param name="sender">Event sender</param>
        /// <param name="e">Event arguments</param>
        private void OnAddButtonClicked(object sender, EventArgs e)
        {
            Type modelType = typeof(IModel).Assembly.GetType(tree.SelectedNode);

            if (modelType != null)
            {
                this.explorerPresenter.MainPresenter.ShowWaitCursor(true);
                try
                {
                    IModel child = (IModel)Activator.CreateInstance(modelType, true);
                    child.Name = modelType.Name;
                    explorerPresenter.Add(child, Apsim.FullPath(this.model));
                }
                finally
                {
                    this.explorerPresenter.MainPresenter.ShowWaitCursor(false);
                }
            }
        }