コード例 #1
0
        bool PushIn(string value, string parentValue)
        {
            bool          pushSuccessful = false;
            FaultTreeNode parent         = GetParent(parentValue, _rootNode);

            if (parent == null)
            {
                return(pushSuccessful);
            }
            if (parent.Child == null)
            {
                parent.Child           = new FaultTreeNode(value);
                parent.Child.Depth     = parent.Depth + 1;
                _mostRecentlyAddedNode = parent.Child;
                return(true);
            }
            FaultTreeNode temp = parent.Child;

            while (temp.Sibling != null)
            {
                temp = temp.Sibling;
            }
            temp.Sibling           = new FaultTreeNode(value);
            temp.Sibling.Depth     = parent.Depth + 1;
            _mostRecentlyAddedNode = temp.Sibling;
            pushSuccessful         = true;
            return(pushSuccessful);
        }
コード例 #2
0
        FaultTreeNode GetParent(string parentValue, FaultTreeNode parentNode)
        {
            if (parentNode.Data.Equals(parentValue))
            {
                return(parentNode);
            }
            FaultTreeNode child  = parentNode.Child;
            FaultTreeNode parent = null;

            while (child != null)
            {
                parent = GetParent(parentValue, child);
                if (parent != null)
                {
                    break;
                }
                child = child.Sibling;
            }
            return(parent);
        }
コード例 #3
0
        public bool Push(string value, string parentValue)
        {
            bool pushSucceeded;

            if (_numOfElements == _maxSize)
            {
                _lastError = "The tree has exceeded the maximum amount of nodes permitted in the tree" +
                             ", increase the maximum size of the tree first.";
                return(false);
            }
            if (_rootNode == null)
            {
                _rootNode = new FaultTreeNode(value);
                _mostRecentlyAddedNode = _rootNode;
                pushSucceeded          = true;
            }
            else
            {
                try
                {
                    pushSucceeded = PushIn(value, parentValue);

                    if (!pushSucceeded)
                    {
                        _lastError = "Duplicate value already exists inside the tree.";
                    }
                }
                catch (Exception e)
                {
                    _lastError = e.Message;
                    return(false);
                }
            }

            if (pushSucceeded)
            {
                _numOfElements++;
            }

            return(pushSucceeded);
        }
コード例 #4
0
        public VisualFaultTree(FaultTrees.FT.FaultTreeNode _rootFaultTree)
        {
            InitializeComponent();

            _pictureBoxGraphics = pbVisualTree.CreateGraphics();

            DrawAreaSize = pbVisualTree.Size;

            this.MouseWheel += new MouseEventHandler(Form1_MouseWheel);

            _graphicalTree = new TreeRendererFaultTree();
            ResetUI();
            if (tmrDraw.Enabled)
            {
                GC.Collect();
            }
            //   _treeDataType = _graphicalTree.GetType().GetGenericArguments()[0];
            //  CheckScrollBars();
            tmrDraw.Enabled = true;
            _graphicalTree.Add(_rootFaultTree);
            CheckScrollBars();
        }
コード例 #5
0
 /// <summary>
 /// Clears the tree by removing the reference to the root node
 /// </summary>
 public void Clear()
 {
     _rootNode      = null;
     _numOfElements = 0;
 }