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;
            }
        }
Example #2
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;
            }
        }