Example #1
0
        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 RefreshSelectedTreeLevels()
        {
            try
            {
                int      lastGoodItem      = 0;
                TreeNode selectedChildNode = SelectedTreeLevels[0].SelectedChildNode;
                for (int i = 1; i < SelectedTreeLevels.Count; i++)
                {
                    if ((selectedChildNode == null) || (SelectedTreeLevels[i].TreeNode != selectedChildNode))
                    {
                        break;      // This selection, and all those below is no longer consistent with the selections above
                    }
                    lastGoodItem      = i;
                    selectedChildNode = SelectedTreeLevels[i].SelectedChildNode;
                }

                int j = SelectedTreeLevels.Count - 1;
                while (j > lastGoodItem)
                {
                    SelectedTreeLevels.RemoveAt(j);
                    j--;
                }

                // Add the selection point at the end
                SelectedTreeLevel lastSelectedTreeLevel = SelectedTreeLevels[SelectedTreeLevels.Count - 1];
                SelectedTreeLevels.Add(new SelectedTreeLevel(lastSelectedTreeLevel, lastSelectedTreeLevel.SelectedChildNode));
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }
        }
        private void InitData()
        {
            try
            {
                TreeNode topNode = new TreeNode()
                {
                    Name   = $"Top",
                    Parent = null,
                };

                IList <TreeNode> topNodes = InitTree(topNode, "", 1, 5);

                SelectedTreeLevels.Clear();

                SelectedTreeLevels.Add(new SelectedTreeLevel(null, topNode));
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }
        }
Example #4
0
        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;
            }
        }