示例#1
0
        /// <summary>
        /// Removes the child tree.
        /// </summary>
        /// <param name="node">The node.</param>
        public void RemoveChildTree(DecisionNode node)
        {
            if (node == null)
            {
                return;
            }
            if (node.layer == 0)
            {
                return;
            }
            if (node.lChild == null)
            {
                return;
            }

            Canvas.instance.panelCanvas.Controls.Remove(node.lChild.button);
            Canvas.instance.panelCanvas.Controls.Remove(node.rChild.button);

            RemoveChildTree(node.lChild);
            RemoveChildTree(node.rChild);

            DecisionTreeLayer layer = GetLayer(node.layer + 1);

            layer.nodeList[node.lChild.index] = null;
            layer.nodeList[node.rChild.index] = null;
            if (IsLayerEmpty(layer))
            {
                layerList.Remove(layer);
            }
            node.lChild    = null;
            node.rChild    = null;
            node.nodeColor = RandomColor.GetRandomColor();
            node.button.Appearance.ForeColor = Color.White;
        }
示例#2
0
        /// <summary>
        /// 新建节点显示控件.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns>SimpleButton.</returns>
        public static SimpleButton NewNodeButton(DecisionNode node)
        {
            SimpleButton btn = new SimpleButton();

            btn.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.HotFlat;
            btn.Name        = node.NodeName;
            btn.Size        = new System.Drawing.Size(60, 24);
            btn.Text        = node.NodeName;
            btn.Tag         = node;
            btn.Appearance.Options.UseBackColor = true;
            //if (node.layer > 0)
            {
                btn.MouseDown   += new MouseEventHandler(simpleButton_MouseDown);
                btn.DoubleClick += new EventHandler(simpleButton_DoubleClick);
            }
            if (node.layer > 0)
            {
                Random random = new Random();
                btn.Appearance.BackColor = RandomColor.GetRandomColor();
                btn.Appearance.ForeColor = Color.White;
            }
            return(btn);
        }