private void treeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { //if (!IsParent) return; try { WorkFlowScriptIDDataStore temp = (WorkFlowScriptIDDataStore)treeView.SelectedItem; if (temp.Place != 2) { return; } Textcategory_id.IsOpen = false; CatNameIDPair tempcat = new CatNameIDPair(temp.Name, temp.Id); bool flag = true; foreach (CatNameIDPair g in catlist) { if (g.Have(tempcat)) { flag = false; break; } } if (flag) { catlist.Add(tempcat); ListBoxCategory_id.ItemsSource = null; ListBoxCategory_id.ItemsSource = catlist; } } catch (Exception) { return; } }
/* * Creates categories Childs * */ public List <WorkFlowScriptIDDataStore> FindChilds(string id) { List <WorkFlowScriptIDDataStore> childList = new List <WorkFlowScriptIDDataStore>(); while (CategoriesRaw.Count == 0) { System.Threading.Thread.Sleep(10); } foreach (categories t in CategoriesRaw.ToList()) { if (t.parent_id == id) { WorkFlowScriptIDDataStore child = new WorkFlowScriptIDDataStore() { Id = t.id, Name = t.name, ParentId = t.parent_id, Subcategories = new List <WorkFlowScriptIDDataStore>() }; child.Subcategories.AddRange(FindChilds(child.Id)); if (child.Subcategories.Count == 0) { child.Place = 2; } else { child.Place = 1; } childList.Add(child); } } return(childList); }
//definitions private void treeView_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { //if (!IsParent) return; if (e.Key == Key.Return) { WorkFlowScriptIDDataStore temp = (WorkFlowScriptIDDataStore)treeView.SelectedItem; if (temp.Place != 2) { return; } Textcategory_id.IsOpen = false; CatNameIDPair tempcat = new CatNameIDPair(temp.Name, temp.Id); bool flag = true; foreach (CatNameIDPair g in catlist) { if (g.Have(tempcat)) { flag = false; break; } } if (flag) { catlist.Add(tempcat); ListBoxCategory_id.ItemsSource = null; ListBoxCategory_id.ItemsSource = catlist; } } }
/* * Takes Categories into CategoriesRaw * Takes Vehicles into VehiclesRaw * Creates categories Parents * */ private void CreateCategories_Parents(object sender, DoWorkEventArgs e) { foreach (categories p in CategoriesRaw.ToList()) { //if (t.parent_id == "" && t.id=="30") //If its a car-parts if (p.parent_id == "77") { WorkFlowScriptIDDataStore parent = new WorkFlowScriptIDDataStore() { Id = p.id, Name = p.name, ParentId = p.parent_id, Subcategories = new List <WorkFlowScriptIDDataStore>() }; parent.Subcategories.AddRange(FindChilds(parent.Id)); if (parent.Subcategories.Count == 0) { parent.Place = 2; } else { parent.Place = 0; } TreeView_List.Add(parent); } } }
private void treeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { WorkFlowScriptIDDataStore temp = (WorkFlowScriptIDDataStore)treeView.SelectedItem; if (temp.Place != 2) { return; } Textcategory_id.IsOpen = false; Textcategory_id.Content = temp.Name; buffer.Text = temp.Id; cat.Text = temp.Id; }
private void treeView_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Return) { WorkFlowScriptIDDataStore temp = (WorkFlowScriptIDDataStore)treeView.SelectedItem; if (temp.Place != 2) { return; } Textcategory_id.IsOpen = false; Textcategory_id.Content = temp.Name; buffer.Text = temp.Id; cat.Text = temp.Id; } }
private void treeView_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { //if ENTER is pressed. if (e.Key == Key.Return) { WorkFlowScriptIDDataStore temp = (WorkFlowScriptIDDataStore)treeView.SelectedItem; if (temp.Place != 2) { return; } Textcategory_id.IsOpen = false; Textcategory_id.Content = temp.Name; CheckData_Filters(); } }
private void treeView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { try { WorkFlowScriptIDDataStore temp = (WorkFlowScriptIDDataStore)treeView.SelectedItem; if (temp.Place != 2) { return; } Textcategory_id.IsOpen = false; Textcategory_id.Content = temp.Name; CheckData_Filters(); } catch (Exception) { return; } }
public List <WorkFlowScriptIDDataStore> FindChilds(string id) { List <WorkFlowScriptIDDataStore> childList = new List <WorkFlowScriptIDDataStore>(); while (data.Count == 0) { System.Threading.Thread.Sleep(10); } //int tempint = data.Count; //int count = 0; //categories tempcat; foreach (categories t in data.ToList()) { //count++; if (t is null) { continue; } if (t.parent_id == id) { WorkFlowScriptIDDataStore child = new WorkFlowScriptIDDataStore() { Id = t.id, Name = t.name, ParentId = t.parent_id, Subcategories = new List <WorkFlowScriptIDDataStore>() }; child.Subcategories.AddRange(FindChilds(child.Id)); if (child.Subcategories.Count == 0) { child.Place = 2; } else { child.Place = 1; } childList.Add(child); } //tempcat = t; } return(childList); }
//Tree private void InisializeData(object sender, DoWorkEventArgs e) { while (caching.VehiclesCached.Count == 0 || caching.CategoriesCached.Count == 0) { System.Threading.Thread.Sleep(50); } while (caching.NumberOfCarProducts == 0 && caching.NumberOfCarProducts != 0) { System.Threading.Thread.Sleep(50); } data.Clear(); data.AddRange(caching.CategoriesCached); vehicles.Clear(); vehicles.AddRange(caching.VehiclesCached .GroupBy(item => item.make_id) .ToDictionary(grp => grp.Key, grp => grp.ToList()) .Select(kvp => kvp.Value[0]) .ToList()); foreach (categories p in data.ToList()) { //if (t.parent_id == "" && t.id=="30") if (p.parent_id == "77") { WorkFlowScriptIDDataStore parent = new WorkFlowScriptIDDataStore() { Id = p.id, Name = p.name, ParentId = p.parent_id, Place = 0, Subcategories = new List <WorkFlowScriptIDDataStore>() }; parent.Subcategories.AddRange(FindChilds(parent.Id)); lst.Add(parent); } } }