public List <ValLvlListItem> getFinalList(List <string> vlst)//use values from listbox and create final list. Fix indexes basically. { List <ValLvlListItem> finalList = new List <ValLvlListItem>(); ValLvlListItem itm = null; int i = 0; foreach (string lv in vlst) { foreach (ValLabelMarixRow lvl in vldMatrix) { if (lvl.ChangeDeleteLevel.Trim().Equals(lv.Trim()) || lvl.NewLevel.Trim().Equals(lv.Trim()))//if level matches { lvl.ListboxIndex = i; ///// creating List/// itm = new ValLvlListItem(); if (lvl.ChangeDeleteLevel.Trim().Length > 0) { itm.NewLevel = lvl.ChangeDeleteLevel.Trim(); itm.OriginalLevel = lvl.OriginalLevel; } else if (lvl.NewLevel.Trim().Length > 0) { itm.NewLevel = lvl.NewLevel.Trim(); itm.OriginalLevel = "";// keep it empty, for R. c("Chngd Level", "Exstng Lvl", "") #last one is new lvl } finalList.Add(itm); break; } } i++; } //creating a final list in order they exists. //foreach (ValLabelMarixRow lvl in vldMatrix) //{ // if ((lvl.ChangeDeleteLevel.Trim().Length > 0) || (lvl.NewLevel.Trim().Length > 0)) // { // itm = new ValLvlListItem(); // if(lvl.ChangeDeleteLevel.Trim().Length>0) // { // itm.NewLevel = lvl.ChangeDeleteLevel.Trim(); // itm.OriginalLevel = lvl.OriginalLevel; // } // else if(lvl.NewLevel.Trim().Length >0) // { // itm.NewLevel = lvl.NewLevel.Trim(); // itm.OriginalLevel = "";// keep it empty, for R. c("Chngd Level", "Exstng Lvl", "") #last one is new lvl // } // //finalList.Insert(lvl.ListboxIndex, itm); // finalList.Add(itm); // } //} return(finalList); }
public List<ValLvlListItem> getFinalList(List<string> vlst)//use values from listbox and create final list. Fix indexes basically. { List<ValLvlListItem> finalList = new List<ValLvlListItem>(); ValLvlListItem itm = null; int i = 0; foreach (string lv in vlst) { foreach (ValLabelMarixRow lvl in vldMatrix) { if (lvl.ChangeDeleteLevel.Trim().Equals(lv.Trim()) || lvl.NewLevel.Trim().Equals(lv.Trim()))//if level matches { lvl.ListboxIndex = i; ///// creating List/// itm = new ValLvlListItem(); if (lvl.ChangeDeleteLevel.Trim().Length > 0) { itm.NewLevel = lvl.ChangeDeleteLevel.Trim(); itm.OriginalLevel = lvl.OriginalLevel; } else if (lvl.NewLevel.Trim().Length > 0) { itm.NewLevel = lvl.NewLevel.Trim(); itm.OriginalLevel = "";// keep it empty, for R. c("Chngd Level", "Exstng Lvl", "") #last one is new lvl } finalList.Add(itm); break; } } i++; } //creating a final list in order they exists. //foreach (ValLabelMarixRow lvl in vldMatrix) //{ // if ((lvl.ChangeDeleteLevel.Trim().Length > 0) || (lvl.NewLevel.Trim().Length > 0)) // { // itm = new ValLvlListItem(); // if(lvl.ChangeDeleteLevel.Trim().Length>0) // { // itm.NewLevel = lvl.ChangeDeleteLevel.Trim(); // itm.OriginalLevel = lvl.OriginalLevel; // } // else if(lvl.NewLevel.Trim().Length >0) // { // itm.NewLevel = lvl.NewLevel.Trim(); // itm.OriginalLevel = "";// keep it empty, for R. c("Chngd Level", "Exstng Lvl", "") #last one is new lvl // } // //finalList.Insert(lvl.ListboxIndex, itm); // finalList.Add(itm); // } //} return finalList; }
private void ChangeLabels(int rowindex) { if (rowindex < 0) { //Wrong row index return; } //int rowindex = variableGrid.SelectedIndex; string colname = (this.Variables[rowindex] as DataSourceVariable).RName; DataColumnMeasureEnum measure = (this.Variables[rowindex] as DataSourceVariable).Measure; if (measure == DataColumnMeasureEnum.Scale)//dont let user run "change levels" on scale col. { MessageBox.Show("This operation is not valid for variable of type Measure = Scale(Numeric)", "Change Level Warning:", MessageBoxButton.OK, MessageBoxImage.Warning); return; } IAnalyticsService analyticServ = LifetimeService.Instance.Container.Resolve<IAnalyticsService>(); List<FactorMap> fctmaplst = new List<FactorMap>(); foreach (var v in ds.Variables[rowindex].Values) { FactorMap cpyfm = new FactorMap(); cpyfm.labels = v; cpyfm.textbox = v; fctmaplst.Add(cpyfm); } ValueLabelsSubDialog vlsd = new ValueLabelsSubDialog(fctmaplst, "Existing Label", "New Label"); vlsd.WindowStartupLocation = WindowStartupLocation.CenterScreen; vlsd.ShowDialog(); if (!vlsd.OKclicked) { return; } List<ValLvlListItem> finalList = new List<ValLvlListItem>(); ValLvlListItem vlit; foreach (FactorMap fm in fctmaplst) { if (fm.labels != "<NA>" || fm.textbox != "<NA>") { vlit = new ValLvlListItem(); vlit.OriginalLevel = fm.labels; vlit.NewLevel = fm.textbox; finalList.Add(vlit); } } analyticServ.ChangeColumnLevels(colname, finalList, ds.Name); refreshDataGrid(); }