Пример #1
0
 public string LoadVegetationParameter(Guid datasetid, string dataname, bool isLAI, string paramName, string value)
 {
     try
     {
         if (Crops == null || Crops.Count == 0)
         {
             Crops = new List <_CustomCropInputsModel>();
         }
         var crop = Crops.FirstOrDefault(x => x.Id == datasetid);
         if (crop == null)
         {
             if (isLAI)
             {
                 crop = new HowLeakyInputs_LAIVeg(datasetid, dataname);
             }
             else
             {
                 crop = new HowLeakyInputs_CoverVeg(datasetid, dataname);
             }
             Crops.Add(crop);
         }
         if (TryLoadParameter(crop, paramName, value) == false)
         {
             return(paramName);
         }
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
     return(null);
 }
                /// <summary>
                /// Applies the configuration to ensure only valid crops are kept and have the correct width/height.
                /// </summary>
                /// <param name="configuration">The configuration.</param>
                public void ApplyConfiguration(MediaPicker3Configuration?configuration)
                {
                    var crops = new List <ImageCropperValue.ImageCropperCrop>();

                    var configuredCrops = configuration?.Crops;

                    if (configuredCrops != null)
                    {
                        foreach (var configuredCrop in configuredCrops)
                        {
                            var crop = Crops?.FirstOrDefault(x => x.Alias == configuredCrop.Alias);

                            crops.Add(new ImageCropperValue.ImageCropperCrop
                            {
                                Alias       = configuredCrop.Alias,
                                Width       = configuredCrop.Width,
                                Height      = configuredCrop.Height,
                                Coordinates = crop?.Coordinates
                            });
                        }
                    }

                    Crops = crops;

                    if (configuration?.EnableLocalFocalPoint == false)
                    {
                        FocalPoint = null;
                    }
                }
Пример #3
0
 public ImageCrop this[string alias]
 {
     get
     {
         return(Crops.FirstOrDefault(x => x.Alias == alias));
     }
 }
Пример #4
0
 /// <summary>
 /// Initialises the instance from the db value
 /// </summary>
 public void Initialise(string dbValue)
 {
     if (!string.IsNullOrWhiteSpace(dbValue))
     {
         JsonConvert.PopulateObject(dbValue, this);
         _underlying = JsonConvert.DeserializeObject <ImageCropDataSet>(dbValue);                //This is useful as it has logic for generating the crop URLs
         Effects.SetUnderlyingDataset(_underlying);
         if (Crops == null)
         {
             Crops = new List <ImageCrop>();
         }
         Crops.ForEach(x => x.SetUnderlyingDataset(_underlying));
         var crops = GetCropsFromProperties();
         foreach (var crop in crops)
         {
             crop.Key.SetValue(this, Crops.FirstOrDefault(x => x.Alias == crop.Value.Alias));
         }
     }
 }
Пример #5
0
 public void InitSelectedItems()
 {
     Crop           = Crops.FirstOrDefault(c => c.CropId == Recipe.CropId);
     ProcessingType = ProcessingTypes.FirstOrDefault(pt => pt.ProcessingTypeId == Recipe.ProcessingTypeId);
     Carrier        = Carriers.FirstOrDefault(c => c.ComponentId == Recipe.CarrierId);
 }