Exemplo n.º 1
0
        //public string SelectedLevelSelectedChildName
        //{
        //    get { return _selectedLevelSelectedChild?.Name; }
        //    set
        //    {
        //        try
        //        {
        //            if (string.IsNullOrEmpty(value))
        //            {
        //                _selectedLevelSelectedChild = null;
        //            }
        //            else if (CurrentlDisplayNode == null)
        //            {
        //                throw new UnspecifiedException("");
        //            }
        //            else if ((_selectedLevelSelectedChild == null) || (!_selectedLevelSelectedChild.Name.Equals(value)))
        //            {
        //                _selectedLevelSelectedChild = _selectedLevelChildren[(string)value];
        //                //CurrentlySelectedTreeLevel.SelectedChildNode = _selectedLevelSelectedChild;

        //                CurrentEquationCalc = null;
        //                OnPropertyChanged("CurrentEquationCalc");

        //                RefreshVisibles();

        //                RefreshSelectedTreeLevels(_selectedLevelSelectedChild);
        //            }
        //        }
        //        catch (Exception ex)
        //        {
        //            Logging.LogException(ex);
        //            throw;
        //        }
        //    }
        //}

        //private void RefreshSelectedTreeLevels(EquationLibraryContentNode lastTnToKeep)
        //{
        //    try
        //    {
        //        int lastGoodItem = 0;
        //        for (int i = 0; i < EquationLibraryDisplayTree.Count; i++)
        //        {
        //            if (EquationLibraryDisplayTree[i]?.SelectedChildNode == lastTnToKeep)
        //            {
        //                lastGoodItem = i;
        //                break;
        //            }
        //        }

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

        //        // Add the selection point at the end
        //        EquationLibraryDisplayNode lastSelectedTreeLevel = EquationLibraryDisplayTree[EquationLibraryDisplayTree.Count - 1];
        //        if (lastSelectedTreeLevel?.SelectedChildNode?.ChildTreeNodes?.Count > 0)
        //        {
        //            EquationLibraryDisplayNode newSelectedTreeLevel = new EquationLibraryDisplayNode(lastSelectedTreeLevel, lastSelectedTreeLevel.SelectedChildNode, lastSelectedTreeLevel.Indent + "  ");
        //            EquationLibraryDisplayTree.Add(newSelectedTreeLevel);
        //        }
        //        else
        //        {
        //            SelectEquation.Execute(null);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Logging.LogException(ex);
        //        throw;
        //    }
        //}


        /// <returns>Number of children</returns>
        public int ExpandTreeLevel(EquationLibraryDisplayNode displayNode)
        {
            try
            {
                if (CurrentDisplayNode != null)
                {
                    CurrentDisplayNode.IsSelected = false;
                }

                EquationLibraryContentNode selectedContentNode = displayNode.ContentNode;
                selectedContentNode.Expanded = !selectedContentNode.Expanded;

                RefreshEquationLibraryDisplayTree();

                CurrentDisplayNode  = FindDisplayNode(selectedContentNode);
                CurrentEquationCalc = null;
                OnPropertyChanged("CurrentEquationCalc");

                if (CurrentDisplayNode == null)
                {
                    throw new UnspecifiedException("CurrentDisplayNode should not be null");
                }
                CurrentDisplayNode.IsSelected = true;

                return(selectedContentNode.ChildTreeNodes.Count);
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }
        }
Exemplo n.º 2
0
        private void lstTreeLevels_ItemTap(object sender, ItemTappedEventArgs e)
        {
            try
            {
                EquationLibraryDisplayNode displayNode = e.Item as EquationLibraryDisplayNode;
                int NumChildren = _vmBrowseEquation2.ExpandTreeLevel(displayNode);

                if (NumChildren == 0)     // Show the list of equations for this node
                {
                    _vmBrowseEquation2.SelectEquation(() => this.Navigation.PopAsync());
                }
            }
            catch (Exception ex)
            {
                Logging.LogException(ex);
                throw;
            }
        }
Exemplo n.º 3
0
        private void AddEquationLibraryDisplayLevels(bool isTop, EquationLibraryDisplayNode parentNode, EquationLibraryContentNode contentNode)
        {
            EquationLibraryDisplayNode displayNode = null;

            if (!isTop)
            {
                displayNode = new EquationLibraryDisplayNode
                                  (parentNode, contentNode, ((parentNode == null) ? "" : parentNode.Indent + "  "));
                EquationLibraryDisplayTree.Add(displayNode);
            }

            if (contentNode.Expanded)
            {
                foreach (var childContentNode in contentNode.ChildTreeNodes)
                {
                    AddEquationLibraryDisplayLevels(false, displayNode, childContentNode);
                }
            }
        }
Exemplo n.º 4
0
 public EquationLibraryDisplayNode(EquationLibraryDisplayNode parent, EquationLibraryContentNode contentNode, string indent)
 {
     Parent      = parent;
     ContentNode = contentNode;
     Indent      = indent;
 }