private void InitData() { try { TreeNode1 topNode = new TreeNode1(null, $"Top", null); topNode.NumDescendantEquations = 0; SelectedTreeLevels.Clear(); CurrentlySelectedTreeLevel = new SelectedTreeLevel1(null, topNode, ""); SelectedTreeLevels.Add(CurrentlySelectedTreeLevel); // Recursively build the tree information from the libraries foreach (var eqbLib in _vmEquations.EquationLibraries) { TreeNode1 libTn = new TreeNode1(topNode, eqbLib.Name, null); libTn.NumDescendantEquations = 0; foreach (var sn in eqbLib.TopSectionNodes) { TreeNode1 tn = new TreeNode1(libTn, sn.Name, sn); AddChildNodes(sn, tn); libTn.NumDescendantEquations += tn.NumDescendantEquations; } topNode.NumDescendantEquations += libTn.NumDescendantEquations; } } catch (Exception ex) { Logging.LogException(ex); throw; } }
private void lstTreeLevels_ItemTap(object sender, ItemTappedEventArgs e) { try { SelectedTreeLevel1 selectedTreeLevel = e.Item as SelectedTreeLevel1; ChangeSelectTreeLevel(selectedTreeLevel); } catch (Exception ex) { Logging.LogException(ex); throw; } }
private void Level_Clicked(object sender, EventArgs e) { try { Button btn = sender as Button; SelectedTreeLevel1 selectedTreeLevel = btn.BindingContext as SelectedTreeLevel1; ChangeSelectTreeLevel(selectedTreeLevel); } catch (Exception ex) { Logging.LogException(ex); throw; } }
public void SelectTreeLevel(SelectedTreeLevel1 selectedTreeLevel) { try { CurrentlySelectedTreeLevel = selectedTreeLevel; CurrentEquationCalc = null; OnPropertyChanged("CurrentEquationCalc"); if (CurrentlySelectedTreeLevel == null) { throw new UnspecifiedException("CurrentlySelectedTreeLevel should not be null"); } _selectedLevelChildren.Clear(); _selectedLevelSelectedChild = null; IList <string> itemsToShow = new List <string>(); IDictionary <string, string> itemsToReturn = new Dictionary <string, string>(); foreach (var node in CurrentlySelectedTreeLevel?.TreeNode?.ChildTreeNodes) { string itemToShow = node.Name + $" ({node.NumDescendantEquations} equations)"; itemsToShow.Add(itemToShow); itemsToReturn.Add(itemToShow, node.Name); _selectedLevelChildren.Add(node.Name, node); } if (itemsToShow.Count != 0) { _vmEquations.EquationsUiService.SelectStringFromList(itemsToShow, (s) => { SelectedLevelSelectedChildName = itemsToReturn[s]; return(true); }); } } catch (Exception ex) { Logging.LogException(ex); throw; } }
private void RefreshSelectedTreeLevels(TreeNode1 lastTnToKeep) { try { int lastGoodItem = 0; for (int i = 0; i < SelectedTreeLevels.Count; i++) { if (SelectedTreeLevels[i]?.SelectedChildNode == lastTnToKeep) { lastGoodItem = i; break; } } int j = SelectedTreeLevels.Count - 1; while (j > lastGoodItem) { SelectedTreeLevels.RemoveAt(j); j--; } // Add the selection point at the end SelectedTreeLevel1 lastSelectedTreeLevel = SelectedTreeLevels[SelectedTreeLevels.Count - 1]; if (lastSelectedTreeLevel?.SelectedChildNode?.ChildTreeNodes?.Count > 0) { SelectedTreeLevel1 newSelectedTreeLevel = new SelectedTreeLevel1(lastSelectedTreeLevel, lastSelectedTreeLevel.SelectedChildNode, lastSelectedTreeLevel.Indent + " "); SelectedTreeLevels.Add(newSelectedTreeLevel); } else { SelectEquation.Execute(null); } } catch (Exception ex) { Logging.LogException(ex); throw; } }
private void ChangeSelectTreeLevel(SelectedTreeLevel1 selectedTreeLevel) { _vmBrowseEquation.SelectTreeLevel(selectedTreeLevel); }
public SelectedTreeLevel1(SelectedTreeLevel1 parent, TreeNode1 treeNode, string indent) { Parent = parent; TreeNode = treeNode; Indent = indent; }