private void Compare() { if (cmp.Items.Count <= 0) { return; } z_resLab.Content = string.Format("Comparing {0} foods", cmp.Items.Count); //Delegate for the progressbar dispatcher. u4progbar updateprog = new u4progbar(UpdateProBar); // the progress steps from the iterations number. double pv = (double)((double)100.0 / (double)cmp.Items.Count); ShowProg(); footag fr = null; TheResTab.Rows.Clear(); for (int i = 0; i < cmp.Items.Count; i++) { ListBoxItem lbi = (ListBoxItem)cmp.Items[i]; z_prog.Dispatcher.Invoke(DispatcherPriority.Render, updateprog, pv); fr = lbi.Tag as footag; AddFoodRow(fr); } HideProg(); ActionBtnsHide(true); }
private void TempresRem(footag fr) { zsrDataSet.NUT_DATARow dr = null; string sel = string.Format("NDB_NO = {0}", fr.NDB_No); DataRow[] sfdr = Tempres.Select(sel); foreach (DataRow ddr in sfdr) { dr = (zsrDataSet.NUT_DATARow)ddr; Tempres.Rows.Remove(dr); } }
private string ffoodes(string p) { footag drow = null; foreach (ListBoxItem lb in cmp.Items) { drow = (footag)lb.Tag; if (drow.NDB_No.Equals(p) == true) { return(drow.Desc); } } return(null); }
private void AddFoodRow(footag fr) { ddda.Nutrient4(foo.NUT_DATA, fr.NDB_No); DataRow dr = TheResTab.NewRow(); float v = 0F; dr[0] = fr.Desc; for (int i = 1; i < TheResTab.Columns.Count; i++) { v = Findval(TheResTab.Columns[i].Caption); dr[i] = v; } TheResTab.Rows.Add(dr); }
private void RemoveSelectedItem() { if (cmp.SelectedItem == null) { return; } //if (TheResTab.Rows.Count <= 0) // return; ListBoxItem lbi = cmp.SelectedItem as ListBoxItem; footag sr = (footag)lbi.Tag; cmp.Items.Remove(lbi); //Remove Item from Tempres TempresRem(sr); // delete from results table. for (int i = 0; i < TheResTab.Rows.Count; i++) { if (sr.Desc.Equals(TheResTab.Rows[i][0].ToString()) == true) { TheResTab.Rows[i].Delete(); } } CmpListHasItems(); }