예제 #1
0
 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);
 }
예제 #2
0
 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;
 }
예제 #3
0
        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);
        }
예제 #4
0
 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);
 }
예제 #5
0
        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);
        }
예제 #6
0
 void _controller_OnNewNomAvailable(object sender, Nom newNom)
 {
     AddANom(newNom);
 }
예제 #7
0
 public NomProperties(Nom nom)
 {
     _nom = nom;
     InitializeComponent();
 }
예제 #8
0
 private void _nomsSelected_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
 {
     Debug.WriteLine(((BindingList<Nom>)_nomsSelected.DataSource).Count);
     _deletedNom = e.Row.DataBoundItem as Nom;
 }
예제 #9
0
 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;
 }
예제 #10
0
 public void UpdateANom(Nom nom)
 {
     if (Equals(null, nom) ||
         Equals(null, _model)) return;
     _model.SaveObject<Nom>(nom);
 }
예제 #11
0
 public void RemoveNomFromDiet(Nom nom)
 {
     _dietInProgress.Remove(nom);
     //if (!Equals(null, OnCatDietChanged))
     //    OnCatDietChanged(this, _dietInProgress);
 }
예제 #12
0
 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);
 }