コード例 #1
0
        public bool Add(string value, string parentValue)
        {
            if (!_faultTree.Push(value, parentValue))
            {
                TreeError.DisplayError(_faultTree.PrevErrorMsg);
                return(false);
            }

            if (_faultTree.NumOfNodes == 1)
            {
                _listOfDrawLocations.Add(new DrawLocation(new PointF(425.0f, 15.0f), _faultTree.MostRecentAddedNode));
            }
            else
            {
                int currentNodeDepth = _faultTree.MostRecentAddedNode.Depth;

                if (currentNodeDepth > _maxNodeDepth)
                {
                    _maxNodeDepth = currentNodeDepth;
                }

                // Find the added node in the list of draw locations, find its parent, add its child to this list

                for (int i = 0; i < _faultTree.NumOfNodes - 1; ++i)
                {
                    FaultTreeNode temp = _listOfDrawLocations[i].Node.Child;
                    while (temp != null)
                    {
                        if (temp == _faultTree.MostRecentAddedNode)
                        {
                            PointF nodePos = _listOfDrawLocations[i].DrawPosition;
                            _listOfDrawLocations.Add(new DrawLocation(nodePos, _faultTree.MostRecentAddedNode));
                            break;
                        }
                        temp = temp.Sibling;
                    }
                }
            }

            int charLengthOfNodeData = _faultTree.MostRecentAddedNode.Data.ToString().Length;

            if (charLengthOfNodeData > _maxCharLengthOfData)
            {
                _maxCharLengthOfData = charLengthOfNodeData;
                _nodeDrawSize.Width  = (int)(_font.Size * _maxCharLengthOfData * 1.2f);

                if (_nodeDrawSize.Width < _nodeDrawSize.Height)
                {
                    _nodeDrawSize.Width = _nodeDrawSize.Height;
                }
            }

            SetNodePositions(_faultTree.RootNode);

            EstablishNodeLines();

            return(true);
        }
コード例 #2
0
        public void AdjustMaxSizeOfTree(int newMaxSize)
        {
            _faultTree.MaxSize = newMaxSize;

            if (newMaxSize < _faultTree.NumOfNodes)
            {
                TreeError.DisplayError(_faultTree.PrevErrorMsg);
            }
        }