Пример #1
0
 public void ControlCallBack(OrgCharNode node)
 {
     if (this.OnNodeClick != null)
     {
         this.OnNodeClick(this);
     }
 }
Пример #2
0
 private void DrawParenChildLine(OrgCharNode node)
 {
     if (node.Childs.Count > 0)
     {
         foreach (OrgCharNode n in node.Childs)
         {
             Draw3Dline(
                 node.X + node.Width / 2,
                 node.Botton,
                 node.X + node.Width / 2,
                 node.Botton + NODE_V_DIS / 2);
             Draw3DEndPoint(node.X + node.Width / 2, node.Botton, 0);
             Draw3Dline(
                 node.X + node.Width / 2,
                 node.Botton + NODE_V_DIS / 2,
                 n.X + n.Width / 2,
                 n.Y - NODE_V_DIS / 2);
             Draw3Dline(
                 n.X + n.Width / 2,
                 n.Y - NODE_V_DIS / 2,
                 n.X + n.Width / 2,
                 n.Y);
             Draw3DEndPoint(n.X + n.Width / 2, n.Y, 1);
             DrawParenChildLine(n);
         }
     }
 }
Пример #3
0
        public void CalNodeRec(OrgCharNode node)
        {
            AddNodeToLevels(node);
            foreach (OrgCharNode n in node.Childs)
            {
                CalNodeRec(n);
            }
            //System.Diagnostics.Debug.WriteLine((node.Tag);

            node.Width  = NODE_WIDTH;
            node.Heigth = NODE_HEIGHT;
            int[] sortArr = new int[] {
                GetXByParentPreviousNode(node),
                GetXByChilds(node),
                GetXByLevel(node),
                NODEMAIGINS_RIGHT
            };
            Array.Sort(sortArr);
            int N_X = sortArr[sortArr.Length - 1]; //取出最大X座標 就是node 的座標

            node.X = N_X;
            node.Y = (NODE_V_DIS + NODE_HEIGHT) * node.Level + ROOTMAIGINS_TOP;
            if (Max_X < node.X)
            {
                Max_X = node.X;
            }
            if (Max_Y < node.Y)
            {
                Max_Y = node.Y;
            }
        }
Пример #4
0
        /// <summary>
        /// 通過父親的前一個節點的子節點來獲取X座標
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public int GetXByParentPreviousNode(OrgCharNode node)
        {
            if (node.ParentNode == null)
            {
                return(-1);
            }
            OrgCharNode pprvnode = node.ParentNode.PreviousNode;

            if (pprvnode != null)
            {
                if (pprvnode.Childs.Count > 0)
                {
                    return(pprvnode.LastChildNode.Right + NODE_H_DIS);
                }
                else
                {
                    return(pprvnode.X);
                }
            }
            else
            {
                if (node.ParentNode != null)
                {
                    return(GetXByParentPreviousNode(node.ParentNode));
                }
            }
            return(-1);
        }
Пример #5
0
        /// <summary>
        /// 通過同level的前一個子節點的Right來獲取X座標
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public int GetXByLevel(OrgCharNode node)
        {
            OrgCharNode prvnode = this.Levels[node.Level].GetPrviousNode(node);

            if (prvnode != null)
            {
                return(prvnode.Right + NODE_H_DIS);
            }
            return(-1);
        }
Пример #6
0
 /// <summary>
 /// 通過childs來獲取node X座標
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public int GetXByChilds(OrgCharNode node)
 {
     if (node.Childs.Count > 0)
     {
         int tmp = 0;
         tmp = node.FirstChildNode.X + ((node.LastChildNode.Right - node.FirstChildNode.X) / 2) - NODE_WIDTH / 2;
         return(tmp);
     }
     return(-1);
 }
Пример #7
0
 private int GetNodeIndex(OrgCharNode node)
 {
     for (int i = 0; i < this.Items.Count; i++)
     {
         if (node.Equals(this.Items[i]))
         {
             return(i);
         }
     }
     return(-1);
 }
Пример #8
0
            /// <summary>
            /// 獲取Level某個節點的前一個節點
            /// </summary>
            /// <param name="node"></param>
            /// <returns></returns>
            public OrgCharNode GetPrviousNode(OrgCharNode node)
            {
                int index = this.GetNodeIndex(node);

                if (index == -1 || index == 0)
                {
                    return(null);
                }
                else
                {
                    return(this.Items[index - 1]);
                }
            }
Пример #9
0
 /// <summary>
 /// 把各個leve層次的節點加入到對應的level中
 /// </summary>
 /// <param name="n"></param>
 private void AddNodeToLevels(OrgCharNode n)
 {
     if (n.Level > Levels.Count - 1)
     {
         Level l = new Level(n.Level);
         l.Items.Add(n);
         Levels.Add(l);
     }
     else
     {
         Levels[n.Level].Items.Add(n);
     }
     Levels.Sort(CompareSortLevel); //重新排序列表
 }
Пример #10
0
 /// <summary>
 /// 給定某個範圍,計算出每個node的位置Rectangle
 /// </summary>
 /// <param name="RootNode"></param>
 /// <param name="LeftNode_x">最左邊的節點x座標</param>
 /// <param name="LeftNode_y">最左邊的節點y座標</param>
 public void GeneratorControlChar(OrgCharNode RootNode)
 {
     this.Max_X = 0;
     this.Max_Y = 0;
     _RootNode  = RootNode;
     this.Levels.Clear();
     AddNodeToLevels(RootNode);
     CalNodeRec(RootNode);
     if (this.DataSource != null && this.DataSource.Container != null)
     {
         this.DataSource.Container.Width  = this.Max_X + NODE_WIDTH + NODEMAIGINS_RIGHT;
         this.DataSource.Container.Height = this.Max_Y + NODE_HEIGHT;
     }
 }
Пример #11
0
        public OrgCharNode BuildNodeTree()
        {
            DataRow[] drs = Table.Select(string.Format("{0}='{1}'", ParentKeyFileName, 0));
            if (ControlBuilder == null)
            {
                ControlBuilder = (IOrgCharControlBuilder)Activator.CreateInstance(this.BuilderType);
            }

            IOrgCharNodeControl obj = ControlBuilder.Build(drs[0]);

            this.Container.Controls.Add((Control)obj);
            obj.Node_X     = -100;
            obj.NodeHeight = OrgCharGenerator.NODE_HEIGHT;
            obj.NodeWidth  = OrgCharGenerator.NODE_WIDTH;
            OrgCharNode rootn = new OrgCharNode(obj);

            obj.Node = rootn;
            BuildNodeTree(drs[0], rootn);
            return(rootn);
        }
Пример #12
0
        private void BuildNodeTree(DataRow r, OrgCharNode pn)
        {
            DataRow[] drs = Table.Select(string.Format("{0}='{1}'", ParentKeyFileName, r[KeyFileName]));
            foreach (DataRow d in drs)
            {
                if (ControlBuilder == null)
                {
                    ControlBuilder = (IOrgCharControlBuilder)Activator.CreateInstance(this.BuilderType);
                }
                IOrgCharNodeControl obj = ControlBuilder.Build(d);
                this.Container.Controls.Add((Control)obj);

                obj.Node_X     = -100;
                obj.NodeHeight = OrgCharGenerator.NODE_HEIGHT;
                obj.NodeWidth  = OrgCharGenerator.NODE_WIDTH;
                OrgCharNode n = new OrgCharNode(obj);
                obj.Node = n;
                pn.AddChild(n);
                BuildNodeTree(d, n);
            }
        }
Пример #13
0
 public void AddChild(OrgCharNode node)
 {
     node.ParentNode = this;
     node.Level      = this.Level + 1;
     this.Childs.Add(node);
 }