private void AddANom(Nom nom) { List<Nom> sortedNoms = (_selectNom.DataSource as BindingList<Nom>).ToList<Nom>(); sortedNoms.Add(nom); sortedNoms.Sort((nomA, nomB) => nomA.CompareTo(nomB)); _selectNom.DataSource = new BindingList<Nom>(sortedNoms); }
public int CompareTo(Nom other) { int result = String.Compare(this.Name, other.Name, true); if (0 == result) result = this.CaloriesPerGram.CompareTo(other.CaloriesPerGram); if (0 == result) result = this.Gushy.CompareTo(other.Gushy); return result; }
public int CompareTo(Nom other) { int result = String.Compare(this.Name, other.Name, true); if (0 == result) { result = this.CaloriesPerGram.CompareTo(other.CaloriesPerGram); } if (0 == result) { result = this.Gushy.CompareTo(other.Gushy); } return(result); }
public void AddNom(Nom nom, double grams) { foreach (NomsThisMeal test in _noms) { if (test.NomType.Id == nom.Id) { test.Grams += grams; return; } } NomsThisMeal newNom = new NomsThisMeal { MyMeal = this, NomType = nom, Grams = grams }; _noms.Add(newNom); }
void _controller_OnNewNomAvailable(object sender, Nom newNom) { AddANom(newNom); }
public NomProperties(Nom nom) { _nom = nom; InitializeComponent(); }
private void _nomsSelected_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) { Debug.WriteLine(((BindingList<Nom>)_nomsSelected.DataSource).Count); _deletedNom = e.Row.DataBoundItem as Nom; }
public bool ValidateNomName(string nomName) { if (Equals(null, _model)) return false; Nom nom = _model.GetNom(nomName); if (!Equals(null, nom)) return true; nom = new Nom { Name = nomName }; NomProperties dlg = new NomProperties(nom); if (DialogResult.OK == dlg.ShowDialog()) { // Now store the new nom _model.SaveObject<Nom>(nom); if (!Equals(null, OnNewNomAvailable)) OnNewNomAvailable(this, nom); return true; } return false; }
public void UpdateANom(Nom nom) { if (Equals(null, nom) || Equals(null, _model)) return; _model.SaveObject<Nom>(nom); }
public void RemoveNomFromDiet(Nom nom) { _dietInProgress.Remove(nom); //if (!Equals(null, OnCatDietChanged)) // OnCatDietChanged(this, _dietInProgress); }
public void AddNomToMeal(Meal meal, Nom nom, double grams) { if (Equals(null, meal) || Equals(null, nom)) return; if (0 == meal.Id) _model.SaveObject<Meal>(meal); meal.AddNom(nom, grams); }