Esempio n. 1
0
        /// <inheritdoc/>
        public override string ModelSummary()
        {
            using (StringWriter htmlWriter = new StringWriter())
            {
                if (this.Parent.GetType() != typeof(LabourActivityFeed))
                {
                    htmlWriter.Write("<div class=\"warningbanner\">This Labour Feed Group must be placed beneath a Labour Activity Feed component</div>");
                    return(htmlWriter.ToString());
                }

                LabourFeedActivityTypes ft = (this.Parent as LabourActivityFeed).FeedStyle;
                htmlWriter.Write("\r\n<div class=\"activityentry\">");
                switch (ft)
                {
                case LabourFeedActivityTypes.SpecifiedDailyAmountPerAE:
                case LabourFeedActivityTypes.SpecifiedDailyAmountPerIndividual:
                    htmlWriter.Write("<span class=\"" + ((Value <= 0) ? "errorlink" : "setvalue") + "\">" + Value.ToString() + "</span>");
                    break;

                default:
                    break;
                }

                ZoneCLEM           zoneCLEM  = FindAncestor <ZoneCLEM>();
                ResourcesHolder    resHolder = zoneCLEM.FindChild <ResourcesHolder>();
                HumanFoodStoreType food      = resHolder.FindResourceType <HumanFoodStore, HumanFoodStoreType>(this, (this.Parent as LabourActivityFeed).FeedTypeName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore);
                if (food != null)
                {
                    htmlWriter.Write(" " + food.Units + " ");
                }

                htmlWriter.Write("<span class=\"setvalue\">");
                switch (ft)
                {
                case LabourFeedActivityTypes.SpecifiedDailyAmountPerIndividual:
                    htmlWriter.Write(" per individual per day");
                    break;

                case LabourFeedActivityTypes.SpecifiedDailyAmountPerAE:
                    htmlWriter.Write(" per AE per day");
                    break;

                default:
                    break;
                }
                htmlWriter.Write("</span> ");
                switch (ft)
                {
                case LabourFeedActivityTypes.SpecifiedDailyAmountPerAE:
                case LabourFeedActivityTypes.SpecifiedDailyAmountPerIndividual:
                    htmlWriter.Write("is fed to each individual");
                    break;
                }
                htmlWriter.Write(" that matches the following conditions:");

                htmlWriter.Write("</div>");
                return(htmlWriter.ToString());
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the names of all the items for each ResourceGroup whose items you want to put into a dropdown list.
        /// eg. "AnimalFoodStore,HumanFoodStore,ProductStore"
        /// Will create a dropdown list with all the items from the AnimalFoodStore, HumanFoodStore and ProductStore.
        /// A blank list of ResourceNameResourceGroups will result in all available resources types being created in the list
        ///
        /// To help uniquely identify items in the dropdown list will need to add the ResourceGroup name to the item name.
        /// eg. The names in the drop down list will become AnimalFoodStore.Wheat, HumanFoodStore.Wheat, ProductStore.Wheat, etc.
        /// </summary>
        /// <returns>Will create a string array with all the items from the AnimalFoodStore, HumanFoodStore and ProductStore.
        /// to help uniquely identify items in the dropdown list will need to add the ResourceGroup name to the item name.
        /// eg. The names in the drop down list will become AnimalFoodStore.Wheat, HumanFoodStore.Wheat, ProductStore.Wheat, etc. </returns>
        private string[] GetCLEMResourceNames(Type[] resourceNameResourceGroups)
        {
            List <string> result   = new List <string>();
            ZoneCLEM      zoneCLEM = model as ZoneCLEM;

            if (zoneCLEM == null)
            {
                zoneCLEM = model.FindAncestor <ZoneCLEM>();
            }
            ResourcesHolder resHolder = zoneCLEM.FindChild <ResourcesHolder>();

            foreach (Type resGroupType in resourceNameResourceGroups)
            {
                IModel resGroup = resHolder.Children.Find(c => resGroupType.IsAssignableFrom(c.GetType()));
                if (resGroup != null)  //see if this group type is included in this particular simulation.
                {
                    foreach (IModel item in resGroup.Children)
                    {
                        result.Add(resGroup.Name + "." + item.Name);
                    }
                }
            }
            return(result.ToArray());
        }