Esempio n. 1
0
        public virtual Point GetTrainPoint(ArrayList alTrains, TrainBase t)
        {
            int index = -1;

            if (alTrains.Count > 1)
            {
                index = alTrains.IndexOf(t);
            }
            Point       trainPoint = this.GetTrainPoint();
            PathElement element    = this;
            Point       point2     = new Point();

            if (t.HeadElementArrivedSource != -1)
            {
                int[] sources = element.GetSources();
                Debug.Assert(sources.Length == 2);
                Point connectionSourcePoint = element.GetConnectionSourcePoint(sources[0]);
                Point point4 = element.GetConnectionSourcePoint(sources[1]);
                if (sources.Length != 2)
                {
                    return(trainPoint);
                }
                double introduced15 = Math.Pow(connectionSourcePoint.get_X() - point4.get_X(), 2.0);
                double num2         = Math.Sqrt(introduced15 + Math.Pow(connectionSourcePoint.get_Y() - point4.get_Y(), 2.0));
                double num3         = (num2 * t.HeadOffset) / ((element.Length == 0) ? ((double)1) : ((double)element.Length));
                double num4         = 1.0;
                double num5         = 0.0;
                if (!(connectionSourcePoint.get_Y() == point4.get_Y()))
                {
                    num4 = Math.Abs((double)(point4.get_X() - connectionSourcePoint.get_X())) / num2;
                    num5 = Math.Abs((double)(point4.get_Y() - connectionSourcePoint.get_Y())) / num2;
                }
                double num6 = num3 * num4;
                double num7 = num3 * num5;
                if (t.HeadElementArrivedSource == sources[0])
                {
                    if (connectionSourcePoint.get_X() <= point4.get_X())
                    {
                        connectionSourcePoint.set_X(connectionSourcePoint.get_X() + num6);
                    }
                    else
                    {
                        connectionSourcePoint.set_X(connectionSourcePoint.get_X() - num6);
                    }
                    if (connectionSourcePoint.get_Y() <= point4.get_Y())
                    {
                        connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + num7);
                    }
                    else
                    {
                        connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - num7);
                    }
                    point2 = connectionSourcePoint;
                }
                else
                {
                    if (point4.get_X() <= connectionSourcePoint.get_X())
                    {
                        point4.set_X(point4.get_X() + num6);
                    }
                    else
                    {
                        point4.set_X(point4.get_X() - num6);
                    }
                    if (point4.get_Y() <= connectionSourcePoint.get_Y())
                    {
                        point4.set_Y(point4.get_Y() + num7);
                    }
                    else
                    {
                        point4.set_Y(point4.get_Y() - num7);
                    }
                    point2 = point4;
                }
                trainPoint = point2;
                if (index != -1)
                {
                    if (connectionSourcePoint.get_Y() == point4.get_Y())
                    {
                        trainPoint.set_Y(trainPoint.get_Y() - 6.0);
                        trainPoint.set_Y(trainPoint.get_Y() + (13 * index));
                    }
                    else
                    {
                        trainPoint.set_X(trainPoint.get_X() - 6.0);
                        trainPoint.set_X(trainPoint.get_X() + (13 * index));
                    }
                }
            }
            return(trainPoint);
        }
Esempio n. 2
0
        public static bool GetOffsettedValue(PathElement peHead, double HeadOffset, int HeadElementArrivedSource, ref Point ptOut)
        {
            Point point = new Point();

            int[] sources = peHead.GetSources();
            Debug.Assert(sources.Length == 2);
            Point connectionSourcePoint = peHead.GetConnectionSourcePoint(sources[0]);
            Point point3 = peHead.GetConnectionSourcePoint(sources[1]);

            if (sources.Length != 2)
            {
                return(false);
            }
            double introduced12 = Math.Pow(connectionSourcePoint.get_X() - point3.get_X(), 2.0);
            double num          = Math.Sqrt(introduced12 + Math.Pow(connectionSourcePoint.get_Y() - point3.get_Y(), 2.0));
            double num2         = (num * HeadOffset) / ((peHead.Length == 0) ? ((double)1) : ((double)peHead.Length));
            double num3         = 1.0;
            double num4         = 0.0;

            if (!(connectionSourcePoint.get_Y() == point3.get_Y()))
            {
                num3 = Math.Abs((double)(point3.get_X() - connectionSourcePoint.get_X())) / num;
                num4 = Math.Abs((double)(point3.get_Y() - connectionSourcePoint.get_Y())) / num;
            }
            double num5 = num2 * num3;
            double num6 = num2 * num4;

            if (HeadElementArrivedSource == sources[0])
            {
                if (connectionSourcePoint.get_X() <= point3.get_X())
                {
                    connectionSourcePoint.set_X(connectionSourcePoint.get_X() + ((int)num5));
                }
                else
                {
                    connectionSourcePoint.set_X(connectionSourcePoint.get_X() - ((int)num5));
                }
                if (connectionSourcePoint.get_Y() <= point3.get_Y())
                {
                    connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + ((int)num6));
                }
                else
                {
                    connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - ((int)num6));
                }
                point = connectionSourcePoint;
            }
            else
            {
                if (point3.get_X() <= connectionSourcePoint.get_X())
                {
                    point3.set_X(point3.get_X() + ((int)num5));
                }
                else
                {
                    point3.set_X(point3.get_X() - ((int)num5));
                }
                if (point3.get_Y() <= connectionSourcePoint.get_Y())
                {
                    point3.set_Y(point3.get_Y() + ((int)num6));
                }
                else
                {
                    point3.set_Y(point3.get_Y() - ((int)num6));
                }
                point = point3;
            }
            ptOut = point;
            return(true);
        }
Esempio n. 3
0
 public static bool GetOffsettedValue(PathElement peHead, double HeadOffset, int HeadElementArrivedSource, ref Point ptOut)
 {
     Point point = new Point();
     int[] sources = peHead.GetSources();
     Debug.Assert(sources.Length == 2);
     Point connectionSourcePoint = peHead.GetConnectionSourcePoint(sources[0]);
     Point point3 = peHead.GetConnectionSourcePoint(sources[1]);
     if (sources.Length != 2)
     {
         return false;
     }
     double introduced12 = Math.Pow(connectionSourcePoint.get_X() - point3.get_X(), 2.0);
     double num = Math.Sqrt(introduced12 + Math.Pow(connectionSourcePoint.get_Y() - point3.get_Y(), 2.0));
     double num2 = (num * HeadOffset) / ((peHead.Length == 0) ? ((double) 1) : ((double) peHead.Length));
     double num3 = 1.0;
     double num4 = 0.0;
     if (!(connectionSourcePoint.get_Y() == point3.get_Y()))
     {
         num3 = Math.Abs((double) (point3.get_X() - connectionSourcePoint.get_X())) / num;
         num4 = Math.Abs((double) (point3.get_Y() - connectionSourcePoint.get_Y())) / num;
     }
     double num5 = num2 * num3;
     double num6 = num2 * num4;
     if (HeadElementArrivedSource == sources[0])
     {
         if (connectionSourcePoint.get_X() <= point3.get_X())
         {
             connectionSourcePoint.set_X(connectionSourcePoint.get_X() + ((int) num5));
         }
         else
         {
             connectionSourcePoint.set_X(connectionSourcePoint.get_X() - ((int) num5));
         }
         if (connectionSourcePoint.get_Y() <= point3.get_Y())
         {
             connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() + ((int) num6));
         }
         else
         {
             connectionSourcePoint.set_Y(connectionSourcePoint.get_Y() - ((int) num6));
         }
         point = connectionSourcePoint;
     }
     else
     {
         if (point3.get_X() <= connectionSourcePoint.get_X())
         {
             point3.set_X(point3.get_X() + ((int) num5));
         }
         else
         {
             point3.set_X(point3.get_X() - ((int) num5));
         }
         if (point3.get_Y() <= connectionSourcePoint.get_Y())
         {
             point3.set_Y(point3.get_Y() + ((int) num6));
         }
         else
         {
             point3.set_Y(point3.get_Y() - ((int) num6));
         }
         point = point3;
     }
     ptOut = point;
     return true;
 }