예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TreeWatch.InformationViewModel"/> class.
        /// </summary>
        /// <param name="field">The field which information should be shown.</param>
        /// <param name="block">The block which information should be shown.</param>
        public InformationViewModel(Field field, Block block)
        {
            Field = field;
            Block = block;

            if (Field != null)
            {
                this.VarietyGroups = new ObservableCollection <Varieties>();

                Field.Blocks.Sort();
                Varieties varieties = null;
                foreach (var item in Field.Blocks)
                {
                    if ((this.VarietyGroups.Count == 0 && varieties == null) || string.Compare(varieties.Variety, item.TreeType.Name, StringComparison.Ordinal) != 0)
                    {
                        varieties = new Varieties(item.TreeType.Name, item.TreeType.ID.ToString(), item.TreeType.ColorProp);

                        varieties.Add(item);

                        this.VarietyGroups.Add(varieties);
                    }
                    else if (this.VarietyGroups.Contains(varieties))
                    {
                        varieties.Add(item);
                    }
                }
            }
        }
예제 #2
0
        private async void GetVarieties()
        {
            if (Varieties != null)
            {
                Varieties.Clear();
            }
            var varieties = await _plantManager.GetVarieties(_selectedPlant.ID);

            Varieties = new ObservableCollection <Variety>(varieties);
        }
예제 #3
0
 protected override bool UseValue(BrushVariety value)
 {
     return(Varieties.HasFlag(value));
 }
예제 #4
0
        public FitnessFunctions(RunItem runItem, bool singleRun, List <OptiParameter> ParamList, List <OptiObservation> ObservList, ObservationItem ObservItem)
            : this()
        {
            if (runItem == null)
            {
                throw new Exception("RunItem is empty: Select a run in the combobox");
            }
            this.RunInfos  = RunDefinitions(runItem, singleRun).ToList();
            multiMultiYear = runItem.MultiMultiYear;
            multiFirstYear = runItem.MultiFirstYear;
            multiLastYear  = runItem.MultiLastYear;

            observItem_ = ObservItem;
            observItem_.updateObservationDictionary();

            observList_ = ObservList;

            foreach (var item in this.RunInfos)
            {
                item.Management = item.Management.Clone();
                item.RunOptions = item.RunOptions.Clone();
                item.Site       = item.Site.Clone();
                item.Soil       = item.Soil.Clone();
                item.Variety    = item.Variety.Clone();
                item.NonVariety = item.NonVariety.Clone();

                this.Managements.Add(item.Management);
                this.RunOptions.Add(item.RunOptions);
                this.Sites.Add(item.Site);
                this.Soils.Add(item.Soil);
                this.Varieties.Add(item.Variety);
                this.NonVarieties.Add(item.NonVariety);
            }

            // Update of ParamSubModel

            foreach (var item in this.Varieties.First().ParamValue.Keys)
            {
                this.ParamSubModel.Add(item, "Variety");
            }

            foreach (var item in this.NonVarieties.First().ParamValue.Keys)
            {
                this.ParamSubModel.Add(item, "NonVariety");
            }


            // Initialisation of ParamList
            List <string> temp = new List <string>();

            foreach (var item in ParamList)
            {
                switch (this.ParamSubModel[item.Name])
                {
                case "Management":
                    temp = Managements.Select(ii => ii.Name).ToList(); optimizeManagementParameter = true;
                    break;

                case "Soil":
                    temp = Soils.Select(ii => ii.Name).ToList(); optimizeSoilParameter = true;
                    break;

                case "NonVariety":
                    temp = NonVarieties.Select(ii => ii.Name).ToList(); optimizeNonVarietalParameter = true;
                    break;

                case "Variety":
                    temp = Varieties.Select(ii => ii.Name).ToList(); optimizeVarietalParameter = true;
                    break;

                default: break;
                }

                while (temp.Count != 0)
                {
                    if (!ParamValueDictio.ContainsKey(temp[0]))
                    {
                        ParamValueDictio.Add(temp[0], new Dictionary <string, double>());
                    }
                    if (!ParamValueDictio[temp[0]].ContainsKey(item.Name))// should always be true
                    {
                        ParamValueDictio[temp[0]].Add(item.Name, 0);
                        paramValueDictioSize++;
                    }

                    string typeToRemove = temp[0];
                    temp.RemoveAll(elem => elem == typeToRemove);
                }
            }
        }