private void ChooseStartDotForStartPart(List <RailEle> paraList, Int16 i)
        {
            StraightEle strTemp = new StraightEle();
            CurvedEle   curTemp = new CurvedEle();
            CrossEle    croTemp = new CrossEle();

            switch (paraList[i].graphType)
            {
            case 1:
                strTemp = (StraightEle)paraList[i];
                paraList[i].startPoint = strTemp.pointList[0];
                paraList[i].endPoint   = strTemp.pointList[1];
                break;

            case 2:
                curTemp = (CurvedEle)paraList[i];
                paraList[i].startPoint = curTemp.firstDot;
                paraList[i].endPoint   = curTemp.secDot;
                break;

            case 3:
                croTemp = (CrossEle)paraList[i];
                paraList[i].startPoint = croTemp.pointList[0];
                paraList[i].endPoint   = croTemp.pointList[5];
                break;

            default:
                break;
            }
            if (!SearchForNeighborDot(paraList, paraList[i].endPoint, Convert.ToInt16(i + 1)))
            {
                switch (paraList[i].graphType)
                {
                case 1:
                    strTemp = (StraightEle)paraList[i];
                    paraList[i].startPoint = strTemp.pointList[1];
                    paraList[i].endPoint   = strTemp.pointList[0];
                    break;

                case 2:
                    curTemp = (CurvedEle)paraList[i];
                    paraList[i].startPoint = curTemp.secDot;
                    paraList[i].endPoint   = curTemp.firstDot;
                    break;

                case 3:
                    croTemp = (CrossEle)paraList[i];
                    paraList[i].startPoint = croTemp.pointList[5];
                    paraList[i].endPoint   = croTemp.pointList[0];
                    break;

                default:
                    break;
                }
            }
        }
        public Point ComputeCoordinates(List <RailEle> tempList, ushort locationValue)
        {
            Point       returnPt   = Point.Empty;
            Int32       offsetTemp = 0;
            Int16       section    = 0;
            StraightEle strTemp    = new StraightEle();
            CurvedEle   curTemp    = new CurvedEle();
            CrossEle    croTemp    = new CrossEle();

            ComputeOffset(locationValue);
            section    = ComputeSegmentNumber(locationValue, tempList);
            offsetTemp = ComputeSegmentOffset(locationValue, tempList, section);
            switch (tempList[section].graphType)
            {
            case 1:
                strTemp    = (StraightEle)tempList[section];
                offsetTemp = offsetTemp * strTemp.lenght / strTemp.tagNumber;
                returnPt   = strTemp.startPoint;
                if (Math.Abs(strTemp.pointList[0].Y - strTemp.pointList[1].Y) < 3)
                {
                    if (strTemp.startPoint.X < strTemp.endPoint.X)
                    {
                        returnPt.X = strTemp.startPoint.X + offsetTemp;
                    }
                    else if (strTemp.startPoint.X > strTemp.endPoint.X)
                    {
                        returnPt.X = strTemp.startPoint.X - offsetTemp;
                    }
                }
                else
                {
                    if (strTemp.startPoint.Y < strTemp.endPoint.Y)
                    {
                        returnPt.Y = strTemp.startPoint.Y + offsetTemp;
                    }
                    else if (strTemp.startPoint.Y > strTemp.endPoint.Y)
                    {
                        returnPt.Y = strTemp.startPoint.Y - offsetTemp;
                    }
                }
                break;

            case 2:
                curTemp    = (CurvedEle)tempList[section];
                offsetTemp = offsetTemp * 90 / curTemp.tagNumber;
                double angleTemp = 0;
                if (curTemp.firstDot == curTemp.startPoint)
                {
                    angleTemp = (curTemp.startAngle + offsetTemp) * 3.14 / 180;
                }
                else if (curTemp.secDot == curTemp.startPoint)
                {
                    angleTemp = (curTemp.startAngle + curTemp.sweepAngle - offsetTemp) * 3.14 / 180;
                }
                returnPt.X = (int)(curTemp.center.X + curTemp.radiu * Math.Cos(angleTemp));
                returnPt.Y = (int)(curTemp.center.Y + curTemp.radiu * Math.Sin(angleTemp));
                break;

            case 3:
                croTemp    = (CrossEle)tempList[section];
                offsetTemp = offsetTemp * (croTemp.firstPart + croTemp.secPart + croTemp.thPart +
                                           (int)Math.Sqrt(croTemp.fourPart.X * croTemp.fourPart.X + croTemp.fourPart.Y * croTemp.fourPart.Y)) / croTemp.tagNumber;
                returnPt = croTemp.startPoint;
                if (croTemp.startAngle == 0 || croTemp.startAngle == 180)
                {
                    if (croTemp.startPoint.X < croTemp.endPoint.X)
                    {
                        if (croTemp.pointList[0].X < croTemp.pointList[5].X)
                        {
                            if (offsetTemp <= croTemp.firstPart)
                            {
                                returnPt.X = croTemp.startPoint.X + offsetTemp;
                            }
                            else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.startPoint.X + offsetTemp;
                                returnPt.Y = croTemp.pointList[2].Y;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                            {
                                returnPt.X = croTemp.startPoint.X + offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                                else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                            }
                        }
                        else if (croTemp.pointList[0].X > croTemp.pointList[5].X)
                        {
                            if (offsetTemp <= croTemp.thPart)
                            {
                                returnPt.X = croTemp.startPoint.X + offsetTemp;
                            }
                            else if (offsetTemp > croTemp.thPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.startPoint.X + offsetTemp;
                                returnPt.Y = croTemp.pointList[2].Y;
                            }
                            else if (offsetTemp > (croTemp.thPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.thPart + croTemp.secPart + croTemp.firstPart))
                            {
                                returnPt.X = croTemp.startPoint.X + offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                                else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                            }
                        }
                    }
                    else if (croTemp.startPoint.X > croTemp.endPoint.X)
                    {
                        if (croTemp.pointList[0].X < croTemp.pointList[5].X)
                        {
                            if (offsetTemp <= croTemp.thPart)
                            {
                                returnPt.X = croTemp.startPoint.X - offsetTemp;
                            }
                            else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.startPoint.X - offsetTemp;
                                returnPt.Y = croTemp.pointList[2].Y;
                            }
                            else if (offsetTemp > (croTemp.thPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                            {
                                returnPt.X = croTemp.startPoint.X - offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                                else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                            }
                        }
                        else if (croTemp.pointList[0].X > croTemp.pointList[5].X)
                        {
                            if (offsetTemp <= croTemp.firstPart)
                            {
                                returnPt.X = croTemp.startPoint.X - offsetTemp;
                            }
                            else if (offsetTemp > croTemp.thPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.startPoint.X - offsetTemp;
                                returnPt.Y = croTemp.pointList[2].Y;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.thPart + croTemp.secPart + croTemp.firstPart))
                            {
                                returnPt.X = croTemp.startPoint.X - offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                                else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                            }
                        }
                    }
                }
                else if (croTemp.startAngle == 90 || croTemp.startAngle == 270 || croTemp.startAngle == -90)
                {
                    if (croTemp.startPoint.Y < croTemp.startPoint.Y)
                    {
                        if (croTemp.pointList[0].Y < croTemp.pointList[5].Y)
                        {
                            if (offsetTemp <= croTemp.firstPart)
                            {
                                returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                            }
                            else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.pointList[2].X;
                                returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                            {
                                returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                                else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                            }
                        }
                        else if (croTemp.pointList[0].Y > croTemp.pointList[5].Y)
                        {
                            if (offsetTemp <= croTemp.thPart)
                            {
                                returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                            }
                            else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.pointList[2].X;
                                returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.thPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                            {
                                returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                                else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                            }
                        }
                    }
                    else if (croTemp.startPoint.Y > croTemp.startPoint.Y)
                    {
                        if (croTemp.pointList[0].Y > croTemp.pointList[5].Y)
                        {
                            if (offsetTemp <= croTemp.firstPart)
                            {
                                returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                            }
                            else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.pointList[2].X;
                                returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                            {
                                returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                                else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y -= offsetTemp;
                                }
                            }
                        }
                        else if (croTemp.pointList[0].Y < croTemp.pointList[5].Y)
                        {
                            if (offsetTemp <= croTemp.thPart)
                            {
                                returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                            }
                            else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                            {
                                returnPt.X = croTemp.pointList[2].X;
                                returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.thPart + croTemp.secPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                            {
                                returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                            }
                            else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                                     offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                            {
                                offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                                returnPt    = croTemp.pointList[6];
                                if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                                {
                                    returnPt.X -= offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                                else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                                {
                                    returnPt.X += offsetTemp;
                                    returnPt.Y += offsetTemp;
                                }
                            }
                        }
                    }
                }
                break;

            default:
                break;
            }
            return(returnPt);
        }
 private bool SearchForNeighborDot(List<RailEle> tempList, Point pt, Int16 j)
 {
     StraightEle strTemp = new StraightEle();
     CurvedEle curTemp = new CurvedEle();
     CrossEle croTemp = new CrossEle();
     Point startPt = Point.Empty;
     Point endPt = pt;
     switch (tempList[j].graphType)
     {
         case 1:
             strTemp = (StraightEle)tempList[j];
             if ((Int16)Math.Sqrt((strTemp.pointList[0].X - pt.X) * (strTemp.pointList[0].X - pt.X) +
                 (strTemp.pointList[0].Y - pt.Y) * (strTemp.pointList[0].Y - pt.Y)) < 2)
             {
                 tempList[j].startPoint = strTemp.pointList[0];
                 tempList[j].endPoint = strTemp.pointList[1];
                 return true;
             }
             else if ((Int16)Math.Sqrt((strTemp.pointList[1].X - pt.X) * (strTemp.pointList[1].X - pt.X) +
                 (strTemp.pointList[1].Y - pt.Y) * (strTemp.pointList[1].Y - pt.Y)) < 2)
             {
                 tempList[j].startPoint = strTemp.pointList[1];
                 tempList[j].endPoint = strTemp.pointList[0];
                 return true;
             }
             break;
         case 2:
             curTemp = (CurvedEle)tempList[j];
             if ((Int16)Math.Sqrt((curTemp.firstDot.X - endPt.X) * (curTemp.firstDot.X - endPt.X) +
                 (curTemp.firstDot.Y - pt.Y) * (curTemp.firstDot.Y - pt.Y)) < 2)
             {
                 tempList[j].startPoint = curTemp.firstDot;
                 tempList[j].endPoint = curTemp.secDot;
                 return true;
             }
             else if ((Int16)Math.Sqrt((curTemp.secDot.X - endPt.X) * (curTemp.secDot.X - endPt.X) +
                 (curTemp.secDot.Y - pt.Y) * (curTemp.secDot.Y - pt.Y)) < 2)
             {
                 tempList[j].startPoint = curTemp.secDot;
                 tempList[j].endPoint = curTemp.firstDot;
                 return true;
             }
             break;
         case 3:
             croTemp = (CrossEle)tempList[j];
             if ((Int16)Math.Sqrt((croTemp.pointList[0].X - pt.X) * (croTemp.pointList[0].X - pt.X) +
                 (croTemp.pointList[0].Y - pt.Y) * (croTemp.pointList[0].Y - pt.Y)) < 2)
             {
                 tempList[j].startPoint = croTemp.pointList[0];
                 tempList[j].endPoint = croTemp.pointList[5];
                 return true;
             }
             else if ((Int16)Math.Sqrt((croTemp.pointList[5].X - pt.X) * (croTemp.pointList[5].X - pt.X) +
                 (croTemp.pointList[5].Y - pt.Y) * (croTemp.pointList[5].Y - pt.Y)) < 2)
             {
                 tempList[j].startPoint = croTemp.pointList[5];
                 tempList[j].endPoint = croTemp.pointList[0];
                 return true;
             }
             break;
         default:
             break;
     }
     return false;
 }
        private bool SearchForNeighborDot(List <RailEle> tempList, Point pt, Int16 j)
        {
            StraightEle strTemp = new StraightEle();
            CurvedEle   curTemp = new CurvedEle();
            CrossEle    croTemp = new CrossEle();
            Point       startPt = Point.Empty;
            Point       endPt   = pt;

            switch (tempList[j].graphType)
            {
            case 1:
                strTemp = (StraightEle)tempList[j];
                if ((Int16)Math.Sqrt((strTemp.pointList[0].X - pt.X) * (strTemp.pointList[0].X - pt.X) +
                                     (strTemp.pointList[0].Y - pt.Y) * (strTemp.pointList[0].Y - pt.Y)) < 2)
                {
                    tempList[j].startPoint = strTemp.pointList[0];
                    tempList[j].endPoint   = strTemp.pointList[1];
                    return(true);
                }
                else if ((Int16)Math.Sqrt((strTemp.pointList[1].X - pt.X) * (strTemp.pointList[1].X - pt.X) +
                                          (strTemp.pointList[1].Y - pt.Y) * (strTemp.pointList[1].Y - pt.Y)) < 2)
                {
                    tempList[j].startPoint = strTemp.pointList[1];
                    tempList[j].endPoint   = strTemp.pointList[0];
                    return(true);
                }
                break;

            case 2:
                curTemp = (CurvedEle)tempList[j];
                if ((Int16)Math.Sqrt((curTemp.firstDot.X - endPt.X) * (curTemp.firstDot.X - endPt.X) +
                                     (curTemp.firstDot.Y - pt.Y) * (curTemp.firstDot.Y - pt.Y)) < 2)
                {
                    tempList[j].startPoint = curTemp.firstDot;
                    tempList[j].endPoint   = curTemp.secDot;
                    return(true);
                }
                else if ((Int16)Math.Sqrt((curTemp.secDot.X - endPt.X) * (curTemp.secDot.X - endPt.X) +
                                          (curTemp.secDot.Y - pt.Y) * (curTemp.secDot.Y - pt.Y)) < 2)
                {
                    tempList[j].startPoint = curTemp.secDot;
                    tempList[j].endPoint   = curTemp.firstDot;
                    return(true);
                }
                break;

            case 3:
                croTemp = (CrossEle)tempList[j];
                if ((Int16)Math.Sqrt((croTemp.pointList[0].X - pt.X) * (croTemp.pointList[0].X - pt.X) +
                                     (croTemp.pointList[0].Y - pt.Y) * (croTemp.pointList[0].Y - pt.Y)) < 2)
                {
                    tempList[j].startPoint = croTemp.pointList[0];
                    tempList[j].endPoint   = croTemp.pointList[5];
                    return(true);
                }
                else if ((Int16)Math.Sqrt((croTemp.pointList[5].X - pt.X) * (croTemp.pointList[5].X - pt.X) +
                                          (croTemp.pointList[5].Y - pt.Y) * (croTemp.pointList[5].Y - pt.Y)) < 2)
                {
                    tempList[j].startPoint = croTemp.pointList[5];
                    tempList[j].endPoint   = croTemp.pointList[0];
                    return(true);
                }
                break;

            default:
                break;
            }
            return(false);
        }
 private void ChooseStartDotForStartPart(List<RailEle> paraList, Int16 i)
 {
     StraightEle strTemp = new StraightEle();
     CurvedEle curTemp = new CurvedEle();
     CrossEle croTemp = new CrossEle();
     switch (paraList[i].graphType)
     {
         case 1:
             strTemp = (StraightEle)paraList[i];
             paraList[i].startPoint = strTemp.pointList[0];
             paraList[i].endPoint = strTemp.pointList[1];
             break;
         case 2:
             curTemp = (CurvedEle)paraList[i];
             paraList[i].startPoint = curTemp.firstDot;
             paraList[i].endPoint = curTemp.secDot;
             break;
         case 3:
             croTemp = (CrossEle)paraList[i];
             paraList[i].startPoint = croTemp.pointList[0];
             paraList[i].endPoint = croTemp.pointList[5];
             break;
         default:
             break;
     }
     if (!SearchForNeighborDot(paraList, paraList[i].endPoint, Convert.ToInt16(i + 1)))
     {
         switch (paraList[i].graphType)
         {
             case 1:
                 strTemp = (StraightEle)paraList[i];
                 paraList[i].startPoint = strTemp.pointList[1];
                 paraList[i].endPoint = strTemp.pointList[0];
                 break;
             case 2:
                 curTemp = (CurvedEle)paraList[i];
                 paraList[i].startPoint = curTemp.secDot;
                 paraList[i].endPoint = curTemp.firstDot;
                 break;
             case 3:
                 croTemp = (CrossEle)paraList[i];
                 paraList[i].startPoint = croTemp.pointList[5];
                 paraList[i].endPoint = croTemp.pointList[0];
                 break;
             default:
                 break;
         }
     }
 }
 public Point ComputeCoordinates(List<RailEle> tempList, ushort locationValue)
 {
     Point returnPt = Point.Empty;
     Int32 offsetTemp = 0;
     Int16 section = 0;
     StraightEle strTemp = new StraightEle();
     CurvedEle curTemp = new CurvedEle();
     CrossEle croTemp = new CrossEle();
     ComputeOffset(locationValue);
     section = ComputeSegmentNumber(locationValue, tempList);
     offsetTemp = ComputeSegmentOffset(locationValue, tempList, section);
     switch (tempList[section].graphType)
     {
         case 1:
             strTemp = (StraightEle)tempList[section];
             offsetTemp =offsetTemp * strTemp.lenght / strTemp.tagNumber;
             returnPt = strTemp.startPoint;
             if (Math.Abs(strTemp.pointList[0].Y - strTemp.pointList[1].Y) < 3)
             {
                 if (strTemp.startPoint.X < strTemp.endPoint.X)
                     returnPt.X = strTemp.startPoint.X + offsetTemp;
                 else if (strTemp.startPoint.X > strTemp.endPoint.X)
                     returnPt.X = strTemp.startPoint.X - offsetTemp;
             }
             else
             {
                 if (strTemp.startPoint.Y < strTemp.endPoint.Y)
                     returnPt.Y = strTemp.startPoint.Y + offsetTemp;
                 else if (strTemp.startPoint.Y > strTemp.endPoint.Y)
                     returnPt.Y = strTemp.startPoint.Y - offsetTemp;
             }
             break;
         case 2:
             curTemp = (CurvedEle)tempList[section];
             offsetTemp = offsetTemp * 90 / curTemp.tagNumber;
             double angleTemp = 0;
             if (curTemp.firstDot == curTemp.startPoint)
                 angleTemp = (curTemp.startAngle + offsetTemp) * 3.14 / 180;
             else if (curTemp.secDot == curTemp.startPoint)
                 angleTemp = (curTemp.startAngle + curTemp.sweepAngle - offsetTemp) * 3.14 / 180;
             returnPt.X = (int)(curTemp.center.X + curTemp.radiu * Math.Cos(angleTemp));
             returnPt.Y = (int)(curTemp.center.Y + curTemp.radiu * Math.Sin(angleTemp));
             break;
         case 3:
             croTemp = (CrossEle)tempList[section];
             offsetTemp = offsetTemp * (croTemp.firstPart + croTemp.secPart + croTemp.thPart +
                 (int)Math.Sqrt(croTemp.fourPart.X * croTemp.fourPart.X + croTemp.fourPart.Y * croTemp.fourPart.Y)) / croTemp.tagNumber;
             returnPt = croTemp.startPoint;
             if (croTemp.startAngle == 0 || croTemp.startAngle == 180)
             {
                 if (croTemp.startPoint.X < croTemp.endPoint.X)
                 {
                     if (croTemp.pointList[0].X < croTemp.pointList[5].X)
                     {
                         if (offsetTemp <= croTemp.firstPart)
                             returnPt.X = croTemp.startPoint.X + offsetTemp;
                         else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.startPoint.X + offsetTemp;
                             returnPt.Y = croTemp.pointList[2].Y;
                         }
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                             returnPt.X = croTemp.startPoint.X + offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                             else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                         }
                     }
                     else if (croTemp.pointList[0].X > croTemp.pointList[5].X)
                     {
                         if (offsetTemp <= croTemp.thPart)
                             returnPt.X = croTemp.startPoint.X + offsetTemp;
                         else if (offsetTemp > croTemp.thPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.startPoint.X + offsetTemp;
                             returnPt.Y = croTemp.pointList[2].Y;
                         }
                         else if (offsetTemp > (croTemp.thPart + croTemp.secPart)
                             && offsetTemp <= (croTemp.thPart + croTemp.secPart + croTemp.firstPart))
                             returnPt.X = croTemp.startPoint.X + offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                             else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                         }
                     }
                 }
                 else if (croTemp.startPoint.X > croTemp.endPoint.X)
                 {
                     if (croTemp.pointList[0].X < croTemp.pointList[5].X)
                     {
                         if (offsetTemp <= croTemp.thPart)
                             returnPt.X = croTemp.startPoint.X - offsetTemp;
                         else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.startPoint.X - offsetTemp;
                             returnPt.Y = croTemp.pointList[2].Y;
                         }
                         else if (offsetTemp > (croTemp.thPart + croTemp.secPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                             returnPt.X = croTemp.startPoint.X - offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                             else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                         }
                     }
                     else if (croTemp.pointList[0].X > croTemp.pointList[5].X)
                     {
                         if (offsetTemp <= croTemp.firstPart)
                             returnPt.X = croTemp.startPoint.X - offsetTemp;
                         else if (offsetTemp > croTemp.thPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.startPoint.X - offsetTemp;
                             returnPt.Y = croTemp.pointList[2].Y;
                         }
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart)
                             && offsetTemp <= (croTemp.thPart + croTemp.secPart + croTemp.firstPart))
                             returnPt.X = croTemp.startPoint.X - offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.X))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].Y > croTemp.pointList[7].Y)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                             else if (croTemp.pointList[6].Y < croTemp.pointList[7].Y)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                         }
                     }
                 }
             }
             else if (croTemp.startAngle == 90 || croTemp.startAngle == 270 || croTemp.startAngle == -90)
             {
                 if (croTemp.startPoint.Y < croTemp.startPoint.Y)
                 {
                     if (croTemp.pointList[0].Y < croTemp.pointList[5].Y)
                     {
                         if (offsetTemp <= croTemp.firstPart)
                             returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                         else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.pointList[2].X;
                             returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                         }
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                             returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                             else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                         }
                     }
                     else if (croTemp.pointList[0].Y > croTemp.pointList[5].Y)
                     {
                         if (offsetTemp <= croTemp.thPart)
                             returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                         else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.pointList[2].X;
                             returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                         }
                         else if (offsetTemp > (croTemp.thPart + croTemp.secPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                             returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                             else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                         }
                     }
                 }
                 else if (croTemp.startPoint.Y > croTemp.startPoint.Y)
                 {
                     if (croTemp.pointList[0].Y > croTemp.pointList[5].Y)
                     {
                         if (offsetTemp <= croTemp.firstPart)
                             returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                         else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.firstPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.pointList[2].X;
                             returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                         }
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                             returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                             else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y -= offsetTemp;
                             }
                         }
                     }
                     else if (croTemp.pointList[0].Y < croTemp.pointList[5].Y)
                     {
                         if (offsetTemp <= croTemp.thPart)
                             returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                         else if (offsetTemp > croTemp.firstPart && offsetTemp <= (croTemp.thPart + croTemp.secPart))
                         {
                             returnPt.X = croTemp.pointList[2].X;
                             returnPt.Y = croTemp.startPoint.Y - offsetTemp;
                         }
                         else if (offsetTemp > (croTemp.thPart + croTemp.secPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart))
                             returnPt.Y = croTemp.startPoint.Y + offsetTemp;
                         else if (offsetTemp > (croTemp.firstPart + croTemp.secPart + croTemp.thPart) &&
                             offsetTemp <= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y))
                         {
                             offsetTemp -= (croTemp.firstPart + croTemp.secPart + croTemp.thPart + croTemp.fourPart.Y);
                             returnPt = croTemp.pointList[6];
                             if (croTemp.pointList[6].X > croTemp.pointList[7].X)
                             {
                                 returnPt.X -= offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                             else if (croTemp.pointList[6].X < croTemp.pointList[7].X)
                             {
                                 returnPt.X += offsetTemp;
                                 returnPt.Y += offsetTemp;
                             }
                         }
                     }
                 }
             }
             break;
         default:
             break;
     }
     return returnPt;
 }
示例#7
0
        public List <RailEle> OpenFile()
        {
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load("..//config//rails.xml");
            }
            catch
            {
                MessageBox.Show("文件不存在,请打开组态软件进行配置");
                return(railInfoEleList);
            }
            XmlNode     root         = xmlDoc.SelectSingleNode("DrawDoc");
            XmlNodeList rootNodeList = xmlDoc.SelectSingleNode("DrawDoc").ChildNodes;

            foreach (XmlNode rxn in rootNodeList)
            {
                XmlElement rxe = (XmlElement)rxn;
                if (rxe.Name == "DrawObjectList")
                {
                    XmlNodeList childNodeList = rxe.ChildNodes;
                    foreach (XmlNode cxn in childNodeList)
                    {
                        XmlElement  cxe          = (XmlElement)cxn;
                        XmlNodeList cTwoNodeList = null;
                        XmlNodeList cThNodeList  = null;
                        XmlNodeList cFNodeList   = null;
                        Point       pt           = Point.Empty;
                        switch (cxe.GetAttribute("xsi:type"))
                        {
                        case "StraightRailEle":
                            StraightEle strTemp = new StraightEle();
                            cTwoNodeList = cxe.ChildNodes;
                            foreach (XmlNode ctwoxn in cTwoNodeList)
                            {
                                XmlElement ctwoxe = (XmlElement)ctwoxn;
                                if (ctwoxe.Name == "GraphType")
                                {
                                    strTemp.graphType = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "Speed")
                                {
                                    strTemp.speed = float.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "SegmentNumber")
                                {
                                    strTemp.segmentNumber = Int16.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "TagNumber")
                                {
                                    strTemp.tagNumber = Convert.ToInt16(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "Lenght")
                                {
                                    strTemp.lenght = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "StartAngle")
                                {
                                    strTemp.startAngle = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "PointList")
                                {
                                    cThNodeList = ctwoxe.ChildNodes;
                                    foreach (XmlNode cthxn in cThNodeList)
                                    {
                                        XmlElement cthxe = (XmlElement)cthxn;
                                        if (cthxe.Name == "Point")
                                        {
                                            cFNodeList = cthxe.ChildNodes;
                                            foreach (XmlNode cfxn in cFNodeList)
                                            {
                                                XmlElement cfxe = (XmlElement)cfxn;
                                                if (cfxe.Name == "X")
                                                {
                                                    pt.X = int.Parse(cfxe.InnerText);
                                                }
                                                else if (cfxe.Name == "Y")
                                                {
                                                    pt.Y = int.Parse(cfxe.InnerText);
                                                }
                                            }
                                            strTemp.pointList.Add(pt);
                                        }
                                    }
                                }
                            }
                            railInfoEleList.Add(strTemp);
                            break;

                        case "CurvedRailEle":
                            CurvedEle curTemp = new CurvedEle();
                            cTwoNodeList = cxn.ChildNodes;
                            foreach (XmlNode ctwoxn in cTwoNodeList)
                            {
                                XmlElement ctwoxe = (XmlElement)ctwoxn;
                                if (ctwoxe.Name == "GraphType")
                                {
                                    curTemp.graphType = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "speed")
                                {
                                    curTemp.speed = float.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "SegmentNumber")
                                {
                                    curTemp.segmentNumber = Convert.ToInt16(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "TagNumber")
                                {
                                    curTemp.tagNumber = Int16.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "StartAngle")
                                {
                                    curTemp.startAngle = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "SweepAngle")
                                {
                                    curTemp.sweepAngle = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "Radiu")
                                {
                                    curTemp.radiu = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "Center")
                                {
                                    cThNodeList = ctwoxe.ChildNodes;
                                    foreach (XmlNode cthxn in cThNodeList)
                                    {
                                        XmlElement cthxe = (XmlElement)cthxn;
                                        if (cthxe.Name == "X")
                                        {
                                            curTemp.center.X = int.Parse(cthxe.InnerText);
                                        }
                                        else if (cthxe.Name == "Y")
                                        {
                                            curTemp.center.Y = int.Parse(cthxe.InnerText);
                                        }
                                    }
                                }
                                else if (ctwoxn.Name == "FirstDot")
                                {
                                    cThNodeList = ctwoxn.ChildNodes;
                                    foreach (XmlNode cthxn in cThNodeList)
                                    {
                                        XmlElement cthxe = (XmlElement)cthxn;
                                        if (cthxe.Name == "X")
                                        {
                                            curTemp.firstDot.X = int.Parse(cthxe.InnerText);
                                        }
                                        else if (cthxe.Name == "Y")
                                        {
                                            curTemp.firstDot.Y = int.Parse(cthxe.InnerText);
                                        }
                                    }
                                }
                                else if (ctwoxn.Name == "SecDot")
                                {
                                    cThNodeList = ctwoxn.ChildNodes;
                                    foreach (XmlNode cthxn in cThNodeList)
                                    {
                                        XmlElement cthxe = (XmlElement)cthxn;
                                        if (cthxe.Name == "X")
                                        {
                                            curTemp.secDot.X = int.Parse(cthxe.InnerText);
                                        }
                                        else if (cthxe.Name == "Y")
                                        {
                                            curTemp.secDot.Y = int.Parse(cthxe.InnerText);
                                        }
                                    }
                                }
                            }
                            railInfoEleList.Add(curTemp);
                            break;

                        case "CrossEle":
                            CrossEle croTemp = new CrossEle();
                            cTwoNodeList = cxn.ChildNodes;
                            foreach (XmlNode ctwoxn in cTwoNodeList)
                            {
                                XmlElement ctwoxe = (XmlElement)ctwoxn;
                                if (ctwoxe.Name == "GraphType")
                                {
                                    croTemp.graphType = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "Speed")
                                {
                                    croTemp.speed = float.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "SegmentNumber")
                                {
                                    croTemp.segmentNumber = Convert.ToInt16(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "TagNumber")
                                {
                                    croTemp.tagNumber = Int16.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "FirstPart")
                                {
                                    croTemp.firstPart = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "SecPart")
                                {
                                    croTemp.secPart = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "ThPart")
                                {
                                    croTemp.thPart = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "StartAngle")
                                {
                                    croTemp.startAngle = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "RotateAngle")
                                {
                                    croTemp.rotateAngle = int.Parse(ctwoxe.InnerText);
                                }
                                else if (ctwoxe.Name == "FourPart")
                                {
                                    cThNodeList = ctwoxe.ChildNodes;
                                    foreach (XmlNode cthxn in cThNodeList)
                                    {
                                        XmlElement cthxe = (XmlElement)cthxn;
                                        if (cthxe.Name == "X")
                                        {
                                            croTemp.fourPart.X = int.Parse(cthxe.InnerText);
                                        }
                                        else if (cthxe.Name == "Y")
                                        {
                                            croTemp.fourPart.Y = int.Parse(cthxe.InnerText);
                                        }
                                    }
                                }
                                else if (ctwoxe.Name == "PointList")
                                {
                                    cThNodeList = ctwoxe.ChildNodes;
                                    foreach (XmlNode cthxn in cThNodeList)
                                    {
                                        XmlElement cthxe = (XmlElement)cthxn;
                                        if (cthxe.Name == "Point")
                                        {
                                            cFNodeList = cthxe.ChildNodes;
                                            foreach (XmlNode cfxn in cFNodeList)
                                            {
                                                XmlElement cfxe = (XmlElement)cfxn;
                                                if (cfxe.Name == "X")
                                                {
                                                    pt.X = int.Parse(cfxe.InnerText);
                                                }
                                                else if (cfxe.Name == "Y")
                                                {
                                                    pt.Y = int.Parse(cfxe.InnerText);
                                                }
                                            }
                                            croTemp.pointList.Add(pt);
                                        }
                                    }
                                }
                            }
                            railInfoEleList.Add(croTemp);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            return(railInfoEleList);
        }
示例#8
0
        public void DrawRailInfo(Graphics canvas)
        {
            Pen pen = new Pen(Color.Black, 1);

            //Pen pen1 = new Pen(Color.Red, 1);
            //Pen pen2 = new Pen(Color.Green, 1);
            //Pen pen3 = new Pen(Color.Blue, 1);
            //Pen pen4 = new Pen(Color.Yellow, 1);
            //Pen pen5 = new Pen(Color.Pink, 1);
            //Pen pen6 = new Pen(Color.Orange, 1);
            //int j = railEleList.Count;

            //for (int k = 0; k < j; k++)
            //{
            //    if (k == 0 || k == 6 || k == 12)
            //        pen = pen1;
            //    else if (k == 1 || k == 7 || k == 13)
            //        pen = pen2;
            //    else if (k == 2 || k == 8 || k == 14)
            //        pen = pen3;
            //    else if (k == 3 || k == 9 || k == 15)
            //        pen = pen4;
            //    else if (k == 4 || k == 10 || k == 16)
            //        pen = pen5;
            //    else if (k == 5 || k == 11)
            //        pen = pen6;
            //    RailEle obj = railEleList[k];
            //    switch (obj.graphType)
            //    {
            //        case 1:
            //            StraightEle strTemp = (StraightEle)obj;
            //            canvas.DrawLine(pen, strTemp.pointList[0], strTemp.pointList[1]);
            //            break;
            //        case 2:
            //            CurvedEle curTemp = (CurvedEle)obj;
            //            Rectangle rc = new Rectangle();
            //            rc.Location = new Point(curTemp.center.X - curTemp.radiu, curTemp.center.Y - curTemp.radiu);
            //            rc.Size = new Size(curTemp.radiu * 2, curTemp.radiu * 2);
            //            GraphicsPath gp = new GraphicsPath();
            //            gp.AddArc(rc, curTemp.startAngle, curTemp.sweepAngle);
            //            canvas.DrawPath(pen, gp);
            //            gp.Dispose();
            //            break;
            //        case 3:
            //            CrossEle croTemp = (CrossEle)obj;
            //            int n = croTemp.pointList.Count;
            //            Point[] pts = new Point[2];
            //            for (int i = 0; i < n; i++, i++)
            //            {
            //                pts[0] = croTemp.pointList[i];
            //                pts[1] = croTemp.pointList[i + 1];
            //                canvas.DrawLines(pen, pts);
            //            }
            //            break;
            //        default:
            //            break;
            //    }
            //}

            foreach (RailEle obj in railEleList)
            {
                switch (obj.graphType)
                {
                case 1:
                    StraightEle strTemp = (StraightEle)obj;
                    canvas.DrawLine(pen, strTemp.pointList[0], strTemp.pointList[1]);
                    break;

                case 2:
                    CurvedEle curTemp = (CurvedEle)obj;
                    Rectangle rc      = new Rectangle();
                    rc.Location = new Point(curTemp.center.X - curTemp.radiu, curTemp.center.Y - curTemp.radiu);
                    rc.Size     = new Size(curTemp.radiu * 2, curTemp.radiu * 2);
                    GraphicsPath gp = new GraphicsPath();
                    gp.AddArc(rc, curTemp.startAngle, curTemp.sweepAngle);
                    canvas.DrawPath(pen, gp);
                    gp.Dispose();
                    break;

                case 3:
                    CrossEle croTemp = (CrossEle)obj;
                    int      n       = croTemp.pointList.Count;
                    Point[]  pts     = new Point[2];
                    for (int i = 0; i < n; i++, i++)
                    {
                        pts[0] = croTemp.pointList[i];
                        pts[1] = croTemp.pointList[i + 1];
                        canvas.DrawLines(pen, pts);
                    }
                    break;

                default:
                    break;
                }
            }
            pen.Dispose();
        }
示例#9
0
 public List<RailEle> OpenFile()
 {
     XmlDocument xmlDoc = new XmlDocument();
     try
     {
         xmlDoc.Load("..//config//rails.xml");
     }
     catch
     {
         MessageBox.Show("文件不存在,请打开组态软件进行配置");
         return railInfoEleList;
     }
     XmlNode root = xmlDoc.SelectSingleNode("DrawDoc");
     XmlNodeList rootNodeList = xmlDoc.SelectSingleNode("DrawDoc").ChildNodes;
     foreach (XmlNode rxn in rootNodeList)
     {
         XmlElement rxe = (XmlElement)rxn;
         if (rxe.Name == "DrawObjectList")
         {
             XmlNodeList childNodeList = rxe.ChildNodes;
             foreach (XmlNode cxn in childNodeList)
             {
                 XmlElement cxe = (XmlElement)cxn;
                 XmlNodeList cTwoNodeList=null;
                 XmlNodeList cThNodeList = null;
                 XmlNodeList cFNodeList = null;
                 Point pt = Point.Empty;
                 switch (cxe.GetAttribute("xsi:type"))
                 {
                     case "StraightRailEle":
                         StraightEle strTemp = new StraightEle();
                         cTwoNodeList = cxe.ChildNodes;
                         foreach (XmlNode ctwoxn in cTwoNodeList)
                         {
                             XmlElement ctwoxe=(XmlElement)ctwoxn;
                             if (ctwoxe.Name == "GraphType")
                                 strTemp.graphType = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "Speed")
                                 strTemp.speed = float.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "SegmentNumber")
                                 strTemp.segmentNumber = Int16.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "TagNumber")
                                 strTemp.tagNumber = Convert.ToInt16(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "Lenght")
                                 strTemp.lenght = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "StartAngle")
                                 strTemp.startAngle = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "PointList")
                             {
                                 cThNodeList = ctwoxe.ChildNodes;
                                 foreach (XmlNode cthxn in cThNodeList)
                                 {
                                     XmlElement cthxe = (XmlElement)cthxn;
                                     if (cthxe.Name == "Point")
                                     {
                                         cFNodeList = cthxe.ChildNodes;
                                         foreach (XmlNode cfxn in cFNodeList)
                                         {
                                             XmlElement cfxe = (XmlElement)cfxn;
                                             if (cfxe.Name == "X")
                                                 pt.X = int.Parse(cfxe.InnerText);
                                             else if (cfxe.Name == "Y")
                                                 pt.Y = int.Parse(cfxe.InnerText);
                                         }
                                         strTemp.pointList.Add(pt);
                                     }
                                 }
                             }
                         }
                         railInfoEleList.Add(strTemp);
                         break;
                     case "CurvedRailEle":
                         CurvedEle curTemp = new CurvedEle();
                         cTwoNodeList = cxn.ChildNodes;
                         foreach(XmlNode ctwoxn in cTwoNodeList)
                         {
                             XmlElement ctwoxe=(XmlElement)ctwoxn;
                             if (ctwoxe.Name == "GraphType")
                                 curTemp.graphType = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "speed")
                                 curTemp.speed = float.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "SegmentNumber")
                                 curTemp.segmentNumber = Convert.ToInt16(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "TagNumber")
                                 curTemp.tagNumber = Int16.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "StartAngle")
                                 curTemp.startAngle = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "SweepAngle")
                                 curTemp.sweepAngle = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "Radiu")
                                 curTemp.radiu = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "Center")
                             {
                                 cThNodeList = ctwoxe.ChildNodes;
                                 foreach (XmlNode cthxn in cThNodeList)
                                 {
                                     XmlElement cthxe = (XmlElement)cthxn;
                                     if (cthxe.Name == "X")
                                         curTemp.center.X = int.Parse(cthxe.InnerText);
                                     else if (cthxe.Name == "Y")
                                         curTemp.center.Y = int.Parse(cthxe.InnerText);
                                 }
                             }
                             else if (ctwoxn.Name == "FirstDot")
                             {
                                 cThNodeList = ctwoxn.ChildNodes;
                                 foreach (XmlNode cthxn in cThNodeList)
                                 {
                                     XmlElement cthxe = (XmlElement)cthxn;
                                     if (cthxe.Name == "X")
                                         curTemp.firstDot.X = int.Parse(cthxe.InnerText);
                                     else if (cthxe.Name == "Y")
                                         curTemp.firstDot.Y = int.Parse(cthxe.InnerText);
                                 }
                             }
                             else if (ctwoxn.Name == "SecDot")
                             {
                                 cThNodeList = ctwoxn.ChildNodes;
                                 foreach (XmlNode cthxn in cThNodeList)
                                 {
                                     XmlElement cthxe = (XmlElement)cthxn;
                                     if (cthxe.Name == "X")
                                         curTemp.secDot.X = int.Parse(cthxe.InnerText);
                                     else if (cthxe.Name == "Y")
                                         curTemp.secDot.Y = int.Parse(cthxe.InnerText);
                                 }
                             }
                         }
                         railInfoEleList.Add(curTemp);
                         break;
                     case "CrossEle":
                         CrossEle croTemp = new CrossEle();
                         cTwoNodeList = cxn.ChildNodes;
                         foreach (XmlNode ctwoxn in cTwoNodeList)
                         {
                             XmlElement ctwoxe = (XmlElement)ctwoxn;
                             if (ctwoxe.Name == "GraphType")
                                 croTemp.graphType = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "Speed")
                                 croTemp.speed = float.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "SegmentNumber")
                                 croTemp.segmentNumber = Convert.ToInt16(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "TagNumber")
                                 croTemp.tagNumber = Int16.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "FirstPart")
                                 croTemp.firstPart = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "SecPart")
                                 croTemp.secPart = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "ThPart")
                                 croTemp.thPart = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "StartAngle")
                                 croTemp.startAngle = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "RotateAngle")
                                 croTemp.rotateAngle = int.Parse(ctwoxe.InnerText);
                             else if (ctwoxe.Name == "FourPart")
                             {
                                 cThNodeList = ctwoxe.ChildNodes;
                                 foreach (XmlNode cthxn in cThNodeList)
                                 {
                                     XmlElement cthxe = (XmlElement)cthxn;
                                     if (cthxe.Name == "X")
                                         croTemp.fourPart.X = int.Parse(cthxe.InnerText);
                                     else if (cthxe.Name == "Y")
                                         croTemp.fourPart.Y = int.Parse(cthxe.InnerText);
                                 }
                             }
                             else if (ctwoxe.Name == "PointList")
                             {
                                 cThNodeList = ctwoxe.ChildNodes;
                                 foreach (XmlNode cthxn in cThNodeList)
                                 {
                                     XmlElement cthxe = (XmlElement)cthxn;
                                     if (cthxe.Name == "Point")
                                     {
                                         cFNodeList = cthxe.ChildNodes;
                                         foreach (XmlNode cfxn in cFNodeList)
                                         {
                                             XmlElement cfxe = (XmlElement)cfxn;
                                             if (cfxe.Name == "X")
                                                 pt.X = int.Parse(cfxe.InnerText);
                                             else if (cfxe.Name == "Y")
                                                 pt.Y = int.Parse(cfxe.InnerText);
                                         }
                                         croTemp.pointList.Add(pt);
                                     }
                                 }
                             }
                         }
                         railInfoEleList.Add(croTemp);
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     return railInfoEleList;
 }