Пример #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
 public PlantingInfo GetPlantingInfo(VarietyKeySeq key)
 {
     if (Varieties.ContainsKey(key))
     {
         return(Varieties[key]);
     }
     else
     {
         return(null);
     }
 }
Пример #3
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);
        }
Пример #4
0
 public void RemoveVarietyKey(VarietyKeySeq varietyKeySeq) =>
 Varieties.Remove(varietyKeySeq);
Пример #5
0
        public void AddVarietyKeys(string family, string plant, string variety, PlantingInfo plantingInfo)
        {
            VarietyKeySeq varietyKeySeq = new VarietyKeySeq(family, plant, variety);

            Varieties.Add(new VarietyKeySeq(family, plant, variety), plantingInfo);
        }
Пример #6
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++;
                }
            }
        }
Пример #7
0
 public PlantVariety GetVariety(VarietyKeySeq varietyKeySeq) =>
 GetVariety(varietyKeySeq.FamilyKey, varietyKeySeq.PlantKey, varietyKeySeq.VarietyKey);
Пример #8
0
 public Plant GetPlant(VarietyKeySeq varietyKeySeq) =>
 GetPlant(varietyKeySeq.FamilyKey, varietyKeySeq.PlantKey);