Ejemplo n.º 1
0
        /// <summary>
        /// 递归函数,根据规则依次调整每个Mind位置
        /// </summary>
        /// <param name="xmle">当前节点</param>
        /// <param name="point">当前节点位置</param>
        /// <returns>调整后当前节点大小和位置</returns>
        private Point Recursion_AdjustMindModel(XmlElement xmle, Point point)
        {
            // 本级区域
            Rectangle rect = new Rectangle(point, new Size(20 * xmle.GetAttribute("key").Length, 20));
            // 下一个子集定位点
            Point nextChildPoint = new Point(rect.Right, rect.Top);
            // 下一个本级定位点
            Point nextPoint = new Point(rect.Left, rect.Bottom);

            if (xmle.HasChildNodes)
            {
                foreach (XmlElement txmle in xmle.ChildNodes)
                {
                    nextChildPoint = Recursion_AdjustMindModel(txmle, nextChildPoint);
                    nextPoint.Y    = nextChildPoint.Y;
                }
                Rectangle firstChildRect = MindConvert.StringToRectangle(((XmlElement)xmle.FirstChild).GetAttribute("region"));
                Rectangle lastChildRect  = MindConvert.StringToRectangle(((XmlElement)xmle.LastChild).GetAttribute("region"));
                rect.Offset(0, (lastChildRect.Top + firstChildRect.Top) / 2 - rect.Top);
            }

            xmle.SetAttribute("region", MindConvert.RectangleToString(rect));

            return(nextPoint);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 递归函数,用于移动Mind位置
        /// </summary>
        /// <param name="xmle">需要调整的节点</param>
        /// <param name="dpoint">移动的方向和长度</param>
        private void Recursion_MoveMindModel(XmlElement xmle, Point dpoint)
        {
            Rectangle rectangle = MindConvert.StringToRectangle(xmle.GetAttribute("region"));

            rectangle.Offset(dpoint);
            xmle.SetAttribute("region", MindConvert.RectangleToString(rectangle));
            if (xmle.HasChildNodes)
            {
                foreach (XmlElement txmle in xmle.ChildNodes)
                {
                    Recursion_MoveMindModel(txmle, dpoint);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 递归函数,用于水平翻转Mind
        /// </summary>
        /// <param name="xmle"></param>
        /// <param name="x"></param>
        private void Recursion_ReverseMindModel(XmlElement xmle, int x)
        {
            Rectangle rectangle = MindConvert.StringToRectangle(xmle.GetAttribute("region"));
            Point     dpoint    = new Point(2 * x - rectangle.Left - rectangle.Right);

            rectangle.Offset(dpoint);
            xmle.SetAttribute("region", MindConvert.RectangleToString(rectangle));
            if (xmle.HasChildNodes)
            {
                foreach (XmlElement txmle in xmle.ChildNodes)
                {
                    Recursion_ReverseMindModel(txmle, x);
                }
            }
        }