Example #1
0
 public LineChart(float default_day, ref Predictor p)
 {
     this.scrollPos_curr = this.scrollPos_prev = default_day;
     setting.graphEnable = p.allPredType.ToDictionary(k => k.Key, k => false);
     setting.SetDefault();
     SetDefaultStyle();
 }
Example #2
0
        public void UpdateData(ref Predictor predictor)
        {
            //marks add dots on top of a graph, the text label is the text in the popup box
            this.SetMarks(Predictor.daysUntilNextHarvestSeason, "Days until the Next Harvest Season", Color.green);
            this.SetMarks(Predictor.daysUntilGrowingPeriodOver, "Days until Growing Period is Over", Color.red);
            this.SetMarks(Predictor.daysUntilWinter, "Days until the Winter", Color.white);
            this.SetMarks(Predictor.daysUntilEndofWinter, "Days until the End of Winter", Color.yellow);

            foreach (String s in this.setting.graphEnable.Where(x => x.Value == true).Select(x => x.Key))
            {
                Color c1, c2;
                GenerateRandomColorPair(this.setting.graphEnable.Keys.ToList().FindIndex(x => x == s), out c1, out c2);
                if (predictor.allPredType[s].def.plant.harvestedThingDef.label == "wood")
                {
                    this.SetCurve(s + " Wood Yield(Max)", c1, predictor.allPredType[s].projectedPred.Select(x => (float)x.yield.max).ToList());
                    this.SetCurve(s + " Wood Yield(Min)", c2, predictor.allPredType[s].projectedPred.Select(x => (float)x.yield.min).ToList());
                }
                else if (predictor.allPredType[s].def.plant.harvestedThingDef.defName == "Hay")
                {
                    this.SetCurve("Hay Yield(Max)",
                                  c1, predictor.allPredType[s].projectedPred.Select(x => (float)x.yield.max).ToList());
                    this.SetCurve("Hay Yield(Min)",
                                  c2, predictor.allPredType[s].projectedPred.Select(x => (float)x.yield.min).ToList());
                    this.SetCurve("Hay Stock(Max)", Color.white, predictor.allPredType[s].projectedPred.Select(x => (float)x.stock.max).ToList());
                    this.SetCurve("Hay Stock(Min)", Color.black, predictor.allPredType[s].projectedPred.Select(x => (float)x.stock.min).ToList());
                }
                else
                {
                    this.SetCurve(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(predictor.allPredType[s].def.plant.harvestedThingDef.label) + " Yield(Max)",
                                  c1, predictor.allPredType[s].projectedPred.Select(x => (float)x.yield.max).ToList());
                    this.SetCurve(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(predictor.allPredType[s].def.plant.harvestedThingDef.label) + " Yield(Min)",
                                  c2, predictor.allPredType[s].projectedPred.Select(x => (float)x.yield.min).ToList());
                }
            }

            foreach (String s in this.setting.graphEnable.Where(x => x.Value == false).Select(x => x.Key))
            {
                if (predictor.allPredType[s].def.plant.harvestedThingDef.label == "wood")
                {
                    this.RemoveCurve(s + " Wood Yield(Max)");
                    this.RemoveCurve(s + " Wood Yield(Min)");
                }
                else if (predictor.allPredType[s].def.plant.harvestedThingDef.defName == "Hay")
                {
                    this.RemoveCurve("Hay Yield(Max)");
                    this.RemoveCurve("Hay Yield(Min)");
                    this.RemoveCurve("Hay Stock(Max)");
                    this.RemoveCurve("Hay Stock(Min)");
                }
                else
                {
                    this.RemoveCurve(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(predictor.allPredType[s].def.plant.harvestedThingDef.label) + " Yield(Max)");
                    this.RemoveCurve(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(predictor.allPredType[s].def.plant.harvestedThingDef.label) + " Yield(Min)");
                }
            }
        }