示例#1
0
        public override List <string> GetTodoList(DateRange range)
        {
            List <string> result = new List <string>();

            string PlantingName = Name;

            if (range.IsDateInRange(created))
            {
                foreach (KeyValuePair <VarietyKeySeq, PlantingInfo> pair in Varieties)
                {
                    VarietyKeySeq varietyKeySeq = pair.Key;
                    PlantingInfo  plantingInfo  = pair.Value;
                    Plant         plant         = GardenData.LoadedData.GetPlant(varietyKeySeq);
                    string        sown          = plant.MustBeSownOutside ? "sow" : "plant";
                    string        strike        = plantingInfo.AlreadyPlanted ? "#" : ""; //added as prefix to indicate that this entry should be marked as done
                    result.Add($"{strike}{DateRange.ApproxDayMonthDateTimeToString(plantingInfo.PlannedPlantingDate)}: {sown} {GardenData.LoadedData.GetVariety(varietyKeySeq).Name}");
                }
                //if (Varieties.Count > 0)
                //    result.Add(DateRange.ApproxDayMonthDateTimeToString(created)+": plant "+ Varieties.Keys.ToList().ConvertAll((VarietyKeySeq input) => GardenData.LoadedData.GetVariety(input).Name).Aggregate((string elem1, string elem2) => elem1 + ", " + elem2)+ " in "+PlantingName);
            }

            foreach (VarietyKeySeq varietyKeySeq in Varieties.Keys)
            {
                PlantVariety    variety      = GardenData.LoadedData.GetVariety(varietyKeySeq);
                PlantingInfo    plantingInfo = Varieties[varietyKeySeq];
                System.DateTime plantTime    = plantingInfo.PlannedPlantingDate.AddDays(-variety.DaysUntilPlantOutside);
                if (variety.MustBeSownInside && range.IsDateInRange(plantTime))
                {
                    string strike = plantingInfo.AlreadyPlanted ? "#" : ""; //added as prefix to indicate that this entry should be marked as done
                    result.Add(strike + DateRange.ApproxDayMonthDateTimeToString(plantTime) + ": sow " + variety.Name + " inside");
                }
            }

            return(result);
        }
示例#2
0
        /// <summary>
        /// Removes all references to a variety
        /// </summary>
        public void RemovePlantVariety(PlantVariety variety)
        {
            GetFamily(variety.FamilyID).Plants[variety.PlantID].RemoveVariety(variety.ID);

            foreach (Garden garden in Gardens.Values)
            {
                foreach (Planting planting in garden.Plantings.Values)
                {
                    planting.RemovePlantVariety(variety);
                }
            }
        }
示例#3
0
 public void AddVariety(string varietyID, PlantVariety variety)
 {
     AddToDictionary(varietyID, variety, Varieties);
     if (FamilyID.Length == 0)
     {
         throw new System.Exception($"{typeof(Plant).Name} must be added to {typeof(PlantFamily).Name} before adding {typeof(PlantVariety).Name}");
     }
     variety.FamilyID = FamilyID;
     if (ID.Length == 0)
     {
         throw new System.Exception($"{typeof(Plant).Name} must be added to {typeof(GardenData).Name} before adding {typeof(PlantVariety).Name}");
     }
     variety.PlantID = ID;
 }
示例#4
0
        public void CalcColor()
        {
            double r = 0, g = 0, b = 0;
            int    sum = 0;

            foreach (KeyValuePair <VarietyKeySeq, PlantingInfo> pair in Varieties)
            {
                VarietyKeySeq seq     = pair.Key;
                int           count   = pair.Value.Count;
                PlantVariety  variety = GardenData.LoadedData.GetVariety(seq);
                Color         color   = variety.GetColor();
                r   += count * color.R;
                g   += count * color.G;
                b   += count * color.B;
                sum += count;
            }
            r    /= sum;
            g    /= sum;
            b    /= sum;
            Color = new Color(r, g, b);
        }
示例#5
0
 public bool TryGetVariety(string varietyID, out PlantVariety variety) =>
 Varieties.TryGetValue(varietyID, out variety);
示例#6
0
 public void AddVariety(PlantVariety variety, PlantingInfo plantingInfo) =>
 AddVarietyKeys(variety.FamilyID, variety.PlantID, variety.ID, plantingInfo);
示例#7
0
 public PlantingInfo GetPlantingInfo(PlantVariety variety) =>
 GetPlantingInfo(variety.FamilyID, variety.PlantID, variety.ID);
示例#8
0
        public override void Draw(Context context, int xoffset = 0, int yoffset = 0, double zoom = 1, int year = 0, int month = 0)
        {
            if (!CheckDate(year, month))
            {
                return;
            }

            Shape.Draw(context, xoffset, yoffset, LINE_COLOR, Color, LINE_WIDTH, zoom);
            if (GardenPlannerSettings.GetSettings().ShowAreaImages&& Varieties.Count > 0)
            {
                int i = 0;
                foreach (KeyValuePair <VarietyKeySeq, PlantingInfo> keyValuePair in Varieties)
                {
                    VarietyKeySeq varietyKeySeq = keyValuePair.Key;
                    int           count         = keyValuePair.Value.Count;
                    Plant         plant         = GardenData.LoadedData.GetPlant(varietyKeySeq.FamilyKey, varietyKeySeq.PlantKey);
                    PlantVariety  variety       = GardenData.LoadedData.GetVariety(varietyKeySeq);

                    PointD plantingShapePoint = Shape.GetTopLeftPoint().ToCairoPointD(xoffset, yoffset, zoom);

                    //Draw image or substitute
                    if (plant.HasImageSurface())
                    {
                        ImageSurface surf  = plant.GetImageSurface();
                        int          surfw = surf.Width;
                        int          surfh = surf.Height;
                        context.Save();

                        double scaleH = (IMAGE_SIZE / surfw) * zoom;
                        double scaleV = (IMAGE_SIZE / surfh) * zoom;
                        context.Translate(plantingShapePoint.X + 1 + scaleH * surfw * i, plantingShapePoint.Y + 1);

                        context.Scale(scaleH, scaleV);

                        context.SetSourceSurface(surf, 0, 0);

                        context.Paint();
                        context.Restore();
                    }
                    else
                    {
                        double imageZoom = IMAGE_SIZE * zoom;
                        double x         = plantingShapePoint.X + 1 + imageZoom * i;
                        double y         = plantingShapePoint.Y + 1;
                        context.SetSourceColor(plant.GetColor());
                        context.MoveTo(x, y);
                        context.LineTo(x + imageZoom, y);
                        context.LineTo(x + imageZoom, y + imageZoom);
                        context.LineTo(x, y + imageZoom);
                        context.LineTo(x, y);

                        context.Fill();
                    }

                    //Draw amount
                    context.SetSourceColor(new Color(0, 0, 0));
                    context.MoveTo(plantingShapePoint.X + 1 + IMAGE_SIZE * zoom * i, plantingShapePoint.Y + (IMAGE_SIZE / 2) * zoom);
                    context.SetFontSize(20 * zoom);
                    context.ShowText(count + "x");

                    //Draw Name
                    if (GardenPlannerSettings.GetSettings().ShowPlantNames || GardenPlannerSettings.GetSettings().ShowVarietyNames)
                    {
                        context.SetSourceColor(new Color(0, 0, 0));
                        context.MoveTo(plantingShapePoint.X + 1 + IMAGE_SIZE * zoom * i, plantingShapePoint.Y + (1.25 * IMAGE_SIZE) * zoom);
                        context.SetFontSize(18 * zoom);
                        context.Rotate(0.45);
                        string text = "";
                        if (GardenPlannerSettings.GetSettings().ShowPlantNames&& GardenPlannerSettings.GetSettings().ShowVarietyNames)
                        {
                            text = variety.Name + " (" + plant.Name + ")";
                        }
                        else
                        {
                            text = GardenPlannerSettings.GetSettings().ShowPlantNames ? plant.Name : variety.Name;
                        }
                        context.ShowText(text);
                        context.Rotate(-0.45);
                    }

                    i++;
                }
            }
        }
示例#9
0
 /// <summary>
 /// Removes all references to the variety
 /// </summary>
 public void RemovePlantVariety(PlantVariety variety) =>
 RemoveById((arg) => arg.VarietyKey.Equals(variety.ID));