public static IPotDraw FromPotPeriod(int Pot, int Period) { // Null Pot PotObject pot = PotObject.Load(Pot); if (pot == null) return new NullPot(); Pot = pot.PotKey; PotPeriod potPeriod = PotPeriod.Load(Pot, Period); if(potPeriod == null) return new NullPot(); // Abstract Pot var apot = new AbstractPot(); apot.Name = pot.PName; if (!potPeriod.Availability) return apot; PotPeriodAvailable avail = PotPeriodAvailable.Load(Pot, Period); if (avail == null) return apot; // Empty Pot var epot = new EmptyPot(apot); var state = StatesObject.Load(avail.StateKey); if (state != null) epot.State = state.SName; if (avail.Empty || avail.MinutesSpent == 0) return epot; PotPeriodFiller fWater = PotPeriodFiller.Load(Pot, Period, (int)Form1.Fillers.Water); PotPeriodFiller fHg = PotPeriodFiller.Load(Pot, Period, (int)Form1.Fillers.Hg); if (fWater == null && fHg == null) return epot; // Watered Pot var wpot = new WateredPot(apot); wpot.MinutesSpent = (float)avail.MinutesSpent; if(state != null) wpot.State = state.SName; var method = MethodsObject.Load(avail.MethodKey); if(method != null) wpot.FillingMethod = method.MName; if (fWater != null) wpot.WaterCount = (float)fWater.Quantity; else wpot.WaterCount = 0; if (fHg == null) return wpot; // Hg Pot var hgpot = new HgPot(wpot); hgpot.HgCount = (float)fHg.Quantity; return hgpot; }
public EmptyPot(AbstractPot pot) { Name = pot.Name; }
public WateredPot(AbstractPot pot) { Name = pot.Name; }
private void UpdatePreviewIni() { if (Pot == null) return; float minSpent = (float)numericMinutesSpent.Value; float hg = (float)numericHgCount.Value; float water = (float)numericWaterCount.Value; if (checkBoxNewCreated.Checked) { var pot = new AbstractPot(); pot.Name = Pot.PName; Preview = pot; } else if (checkBoxEmpty.Checked || minSpent == 0) { var pot = new EmptyPot(); pot.Name = Pot.PName; Preview = pot; } else if (hg == 0) { var pot = new WateredPot(); pot.WaterCount = water; pot.MinutesSpent = minSpent; pot.Name = Pot.PName; pot.State = comboBoxState.SelectedValue as String; pot.FillingMethod = (comboBoxFillingMethod.SelectedItem as ComboItem).Value; Preview = pot; } else { var pot = new HgPot(); pot.WaterCount = water; pot.MinutesSpent = minSpent; pot.Name = Pot.PName; pot.State = comboBoxState.SelectedValue as String; pot.FillingMethod = (comboBoxFillingMethod.SelectedItem as ComboItem).Value; pot.HgCount = hg; Preview = pot; } Preview.Ini(); pictureBoxPotPreview.Invalidate(); pictureBoxPotPreview.Update(); }