Exemplo n.º 1
0
 public TransportCompany(List <Storyboard> storyboard)
 {
     Title      = "Tram and others Company";
     Transports = new List <Transport>();
     Transports.Add(new Transport(4, "Tram", 100, 500, storyboard[0]));
     Transports.Add(new Transport(5, "TrolleyBus", 100, 300, storyboard[1]));
     CountOfTransport = Transports.Count;
     GreenBufferArrayOfStations.AddRange(GreenPointInForward);
     GreenBufferArrayOfStations.AddRange(GreenPointInBackward);
     RedBufferArrayOfStations.AddRange(RedPointInForward);
     RedBufferArrayOfStations.AddRange(RedPointInBackward);
     passengers = new List <Passenger>();
     passengers.Add(new Passenger());
     passengers.Add(new PassengerWithSingleTicket());
     passengers.Add(new PreferentialPassenger());
     width  = ((MainWindow)System.Windows.Application.Current.MainWindow).MainCanvas.Width;
     height = ((MainWindow)System.Windows.Application.Current.MainWindow).MainCanvas.Height;
     foreach (var VARIABLE in Transports)
     {
         VARIABLE.Draw();
         VARIABLE.StartTrip();
     }
     foreach (var VARIABLE in passengers)
     {
         VARIABLE.Draw();
     }
     //      StationTimer.Tick += new EventHandler(StationTimer_Tick);
     //    StationTimer.Tick += new EventHandler(OnStation_Tick);
     Added                += StationTimer_Tick;
     Added                += OnStation_Tick;
     StationTimer.Tick    += new EventHandler(Added);
     StationTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);
     StationTimer.Start();
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            Shape[] myShapes = { new Hexagon(),      new Circle(), new Hexagon("Mick"),
                                 new Circle("Beth"), new Hexagon("Linda") };
            foreach (var VARIABLE in myShapes)
            {
                VARIABLE.Draw();
            }

            ThreeDCircle o = new ThreeDCircle();

            o.Draw();
            //调用了父类的Draw()方法
            ((Circle)o).Draw();

            Console.ReadKey();
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.Black);

            //TODO: Add your drawing code here
            spriteBatch.Begin();

            foreach (var VARIABLE in _tileses)
            {
                if (VARIABLE != null)
                {
                    VARIABLE.Draw(spriteBatch);
                }
            }
            if (runAlive)
            {
                runSprite.Draw(gameTime, spriteBatch);
            }
            if (jumpAlive)
            {
                jumpSprite.Draw(gameTime, spriteBatch);
            }

            if (bulletAlive)
            {
                bulletSprite.Draw(gameTime, spriteBatch);
            }

            foreach (var VARIABLE in enemySprite)
            {
                VARIABLE.Draw(gameTime, spriteBatch);
            }

            spriteBatch.End();
            base.Draw(gameTime);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 渲染当前添加的所有元素,在OnGUI进行调用,默认自动进行调用
        /// </summary>
        public void OnGUI()
        {
            Event evt = Event.current;


            if (evt.type == EventType.KeyDown && evt.control && evt.keyCode == KeyCode.R)
            {
                AssetDatabase.Refresh();
                evt.Use();
            }

            //先进行渲染
            if (evt.type == EventType.Repaint)
            {
                foreach (var VARIABLE in _rootElements)
                {
                    VARIABLE.Draw();
                }
            }

            //实现局部事件
            {
                Vector2 mousePos = evt.mousePosition;

                //Drag
                if (_pointerDragIndex != -1 && mousePos != _lastDragMousePosition)
                {
                    IPointerDragHandler drag = _uiElements[_pointerDragIndex] as IPointerDragHandler;
                    if (drag != null)
                    {
                        drag.OnDrag(mousePos - _lastDragMousePosition, mousePos);
                        _lastDragMousePosition = mousePos;
                        _refreshWindow         = true;
                    }
                }


                //PointerExit
                if (_pointerEnterIndex != -1)
                {
                    if (_uiElements.Count <= _pointerEnterIndex)
                    {
                        _pointerEnterIndex = -1;
                    }
                    else
                    {
                        IOverlapPoint ip = _uiElements[_pointerEnterIndex] as IOverlapPoint;
                        if (ip != null && !ip.OverlapPoint(mousePos, evt))
                        {
                            IPointerExitHandler ie = ip as IPointerExitHandler;
                            ie?.OnPointerExit();
                            _pointerEnterIndex = -1;
                        }
                    }
                }

                //PointerClickExit
                if (_pointerClickEnterIndex != -1)
                {
                    if (_uiElements.Count <= _pointerClickEnterIndex)
                    {
                        _pointerClickEnterIndex = -1;
                    }
                    else
                    {
                        IOverlapPoint ip = _uiElements[_pointerClickEnterIndex] as IOverlapPoint;
                        if (ip != null && !ip.OverlapPoint(mousePos, evt))
                        {
                            _pointerClickEnterIndex = -1;
                        }
                    }
                }

                //PointerEnter
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerEnterHandler id = _uiElements[i] as IPointerEnterHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt))
                    {
                        if (_pointerEnterIndex == -1 || _pointerEnterIndex < i)
                        {
                            if (_pointerEnterIndex != -1)
                            {
                                IPointerExitHandler ie = _uiElements[_pointerEnterIndex] as IPointerExitHandler;
                                ie?.OnPointerExit();
                            }

                            _pointerEnterIndex = i;
                            id.OnPointerEnter();
                            break;
                        }
                    }
                }

                //PointerClickEnter
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerClickHandler id = _uiElements[i] as IPointerClickHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt))
                    {
                        if (_pointerClickEnterIndex == -1 || _pointerClickEnterIndex < i)
                        {
                            _pointerClickEnterIndex = i;
                            break;
                        }
                    }
                }
            }

            //处理鼠标按下
            if (evt.type == EventType.MouseDown)
            {
                Vector2 mousePos = evt.mousePosition;

                bool hasFocus = false;
                //PointerDown
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    UIElement     ui = _uiElements[i];
                    IOverlapPoint ip = ui as IOverlapPoint;

                    if (ip.OverlapPoint(mousePos, evt))
                    {
                        hasFocus = true;
                        IFocus focus = ui as IFocus;

                        IPointerDownHandler down = ui as IPointerDownHandler;

                        IPointerDragHandler drag = ui as IPointerDragHandler;

                        //Focus
                        if (focus != null)
                        {
                            //向上查找所有父亲
                            UIElement parent = ui;
                            while (parent != null)
                            {
                                focus = parent as IFocus;
                                if (focus != null)
                                {
                                    _focusElementsCur.Add(focus);
                                }

                                parent = parent.Parent;
                            }

                            //取消之前的
                            for (int i2 = _focusElements.Count - 1; i2 >= 0; i2--)
                            {
                                if (!_focusElementsCur.Contains(_focusElements[i2]))
                                {
                                    _focusElements[i2].Focus = false;
                                }
                            }


                            //聚焦现在的,从父亲到孩子
                            for (int i2 = _focusElementsCur.Count - 1; i2 >= 0; i2--)
                            {
                                _focusElementsCur[i2].Focus = true;
                            }

                            //交换之前与现在的列表,并清除现在
                            List <IFocus> temp = _focusElements;
                            _focusElements    = _focusElementsCur;
                            _focusElementsCur = temp;
                            _focusElementsCur.Clear();

                            if (down == null && drag == null)
                            {
                                break;
                            }
                        }

                        if (drag != null && _pointerDragIndex == -1 && evt.button == 0)
                        {
                            _pointerDragIndex = i;
                            drag.OnStartDrag(mousePos);

                            _lastDragMousePosition = mousePos;

                            if (down == null)
                            {
                                break;
                            }
                        }

                        if (down != null)
                        {
                            //PointerDown
                            down.OnPointerDown(mousePos, evt.shift, evt.control, evt.alt);
                            break;
                        }
                    }
                }


                //PointerClickDown
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerClickHandler id = _uiElements[i] as IPointerClickHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt) && _pointerClickPressIndex == -1)
                    {
                        _pointerClickPressButton = evt.button;
                        _pointerClickPressIndex  = i;
                        break;
                    }
                }

                //处理空白区域点击取消Focus
                if (!hasFocus)
                {
                    //取消焦点
                    for (int i2 = _focusElements.Count - 1; i2 >= 0; i2--)
                    {
                        _focusElements[i2].Focus = false;
                    }

                    _focusElements.Clear();
                }

                _refreshWindow = true;
            }

            //处理鼠标抬起
            if (evt.type == EventType.MouseUp || evt.type == EventType.MouseLeaveWindow)
            {
                Vector2 mousePos = evt.mousePosition;

                if (evt.button == 0)
                {
                    if (_pointerDragIndex != -1)
                    {
                        if (_uiElements[_pointerDragIndex] is IPointerDragHandler drag)
                        {
                            drag.OnDragEnd(mousePos);
                        }

                        _pointerDragIndex = -1;
                    }
                }

                //PointerUp
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IPointerUpHandler id = _uiElements[i] as IPointerUpHandler;
                    if (id != null && id.OverlapPoint(mousePos, evt))
                    {
                        id.OnPointerUp(mousePos);
                        break;
                    }
                }

                //PointerClickUp
                if (_pointerClickPressIndex != -1)
                {
                    if (_pointerClickEnterIndex != -1)
                    {
                        IPointerClickHandler ic = _uiElements[_pointerClickPressIndex] as IPointerClickHandler;
                        if (_pointerClickPressButton == evt.button)
                        {
                            if (_pointerClickPressIndex == _pointerClickEnterIndex)
                            {
                                ic?.OnClick(mousePos);
                            }
                            else
                            {
                                ic?.OnCancelClick(mousePos);
                            }
                        }
                        else
                        {
                            ic?.OnCancelClick(mousePos);
                        }

                        _pointerClickEnterIndex = -1;
                        _pointerClickPressIndex = -1;
                    }
                    else
                    {
                        IPointerClickHandler ic = _uiElements[_pointerClickPressIndex] as IPointerClickHandler;
                        ic?.OnCancelClick(mousePos);
                        _pointerClickEnterIndex = -1;
                        _pointerClickPressIndex = -1;
                    }
                }

                _refreshWindow = true;
            }

            //处理鼠标滚轮滑动
            if (evt.type == EventType.ScrollWheel)
            {
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IScrollHandler ic = _uiElements[i] as IScrollHandler;
                    ic?.OnScroll(evt.delta.y);
                }
            }

            //处理键盘按下
            if (evt.type == EventType.KeyDown)
            {
                if (evt.character != 0)
                {
                    for (int i = _uiElements.Count - 1; i >= 0; i--)
                    {
                        ICharacterInputHandler ic = _uiElements[i] as ICharacterInputHandler;
                        ic?.OnCharacterInput(evt.character);
                    }
                }

                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IKeyDownHandler ui = _uiElements[i] as IKeyDownHandler;
                    ui?.OnKeyDown(evt.keyCode, evt.shift, evt.control, evt.alt);
                }

                evt.Use();

                _refreshWindow = true;
            }

            if (evt.type == EventType.KeyUp)
            {
                for (int i = _uiElements.Count - 1; i >= 0; i--)
                {
                    IKeyUpHandler ui = _uiElements[i] as IKeyUpHandler;
                    ui?.OnKeyUp(evt.keyCode);
                }

                evt.Use();

                _refreshWindow = true;
            }


            //RefreshAllElement
            if (_hasChangedElement)
            {
                RefreshAllElementInline();
                _hasChangedElement = false;
                _refreshWindow     = true;
            }

            //鼠标移动重绘
            if (_lastMoveMousePosition != evt.mousePosition)
            {
                _refreshWindow         = true;
                _lastDragMousePosition = evt.mousePosition;
            }

            //自动重绘界面
            if (_refreshWindow)
            {
                _refreshWindow = false;
                CurEditorWindow.Repaint();
            }
        }
Exemplo n.º 5
0
        public void Load(StreamReader sr)
        {
            foreach (var VARIABLE in passengers.ToArray())
            {
                VARIABLE.Remove();
                passengers.Remove(VARIABLE);
            }
            string s = sr.ReadLine();

            s = sr.ReadLine();
            s = sr.ReadLine();
            int k = Convert.ToInt32(s);

            for (int i = 0; i < k; i++)
            {
                s = sr.ReadLine();
                if (s == "Passenger")
                {
                    passengers.Add(new Passenger());
                    passengers[passengers.Count - 1].Load(sr);
                }
                if (s == "PassengerWithSingleTicket")
                {
                    passengers.Add(new PassengerWithSingleTicket());
                    passengers[passengers.Count - 1].Load(sr);
                }
                if (s == "PreferentialPassenger")
                {
                    passengers.Add(new PreferentialPassenger());
                    passengers[passengers.Count - 1].Load(sr);
                }
            }
            foreach (var VARIABLE in Transports)
            {
                foreach (var ARIABLE in VARIABLE.pass.ToArray())
                {
                    ARIABLE.Remove();
                    VARIABLE.pass.Remove(ARIABLE);
                }
            }
            k = Convert.ToInt32(sr.ReadLine());
            for (int i = 0; i < k; i++)
            {
                s = sr.ReadLine();
                if (s == "Passenger")
                {
                    Transports[0].pass.Add(new Passenger());
                    Transports[0].pass[Transports[0].pass.Count - 1].Load(sr);
                }
                if (s == "PassengerWithSingleTicket")
                {
                    Transports[0].pass.Add(new PassengerWithSingleTicket());
                    Transports[0].pass[Transports[0].pass.Count - 1].Load(sr);
                }
                if (s == "PreferentialPassenger")
                {
                    Transports[0].pass.Add(new PreferentialPassenger());
                    Transports[0].pass[Transports[0].pass.Count - 1].Load(sr);
                }
            }
            k = Convert.ToInt32(sr.ReadLine());
            for (int i = 0; i < k; i++)
            {
                s = sr.ReadLine();
                if (s == "Passenger")
                {
                    Transports[1].pass.Add(new Passenger());
                    Transports[1].pass[Transports[1].pass.Count - 1].Load(sr);
                }
                if (s == "PassengerWithSingleTicket")
                {
                    Transports[1].pass.Add(new PassengerWithSingleTicket());
                    Transports[1].pass[Transports[1].pass.Count - 1].Load(sr);
                }
                if (s == "PreferentialPassenger")
                {
                    Transports[1].pass.Add(new PreferentialPassenger());
                    Transports[1].pass[Transports[1].pass.Count - 1].Load(sr);
                }
            }
            foreach (var VARIABLE in passengers)
            {
                VARIABLE.Draw();
            }
        }
Exemplo n.º 6
0
        private void OnStation_Tick(object sender, EventArgs e)
        {
            foreach (var VARIABLE in GreenStation)
            {
                foreach (var VAE in passengers)
                {
                    Rect rectangle1 = new Rect(VAE.x, VAE.y, (int)Passenger.imagewx, (int)Passenger.imagewy);
                    Rect rectangle2 = new Rect(Canvas.GetLeft(VARIABLE), Canvas.GetTop(VARIABLE), 25, 25);
                    if (rectangle1.IntersectsWith(rectangle2) && VAE.InTravel == false)
                    {
                        VAE.MotionStyle = 0;
                        WasPaused       = true;
                        foreach (var V in Transports)
                        {
                            V.Pause();
                        }
                        ChooseStation newPassenger = new ChooseStation();
                        newPassenger.ShowDialog();
                        if (newPassenger.DialogResult == true)
                        {
                            if (Convert.ToInt32(newPassenger.MyStation) < 0 ||
                                Convert.ToInt32(newPassenger.MyStation) > 12)
                            {
                            }
                            else
                            {
                                VAE.OnStation(GreenStation.IndexOf(VARIABLE), Convert.ToInt32(newPassenger.MyStation),
                                              Colors.Green);
                            }
                        }
                        foreach (var V in Transports)
                        {
                            V.Resume();
                        }
                        WasPaused = false;

                        foreach (var pass in passengers)
                        {
                            pass.Draw();
                        }
                    }
                }
            }
            foreach (var VARIABLE in RedStation)
            {
                foreach (var VAE in passengers)
                {
                    Rect rectangle1 = new Rect(VAE.x, VAE.y, Passenger.imagewx, Passenger.imagewy);
                    Rect rectangle2 = new Rect(Canvas.GetLeft(VARIABLE), Canvas.GetTop(VARIABLE), 25, 25);
                    if (rectangle1.IntersectsWith(rectangle2) && VAE.InTravel == false)
                    {
                        WasPaused       = true;
                        VAE.MotionStyle = 0;
                        foreach (var V in Transports)
                        {
                            V.Pause();
                        }
                        ChooseStation newPassenger = new ChooseStation();
                        newPassenger.ShowDialog();
                        if (newPassenger.DialogResult == true)
                        {
                            if (Convert.ToInt32(newPassenger.MyStation) < 0 ||
                                Convert.ToInt32(newPassenger.MyStation) > 6)
                            {
                            }
                            else
                            {
                                VAE.OnStation(RedStation.IndexOf(VARIABLE), Convert.ToInt32(newPassenger.MyStation),
                                              Colors.Red);
                            }
                        }
                        foreach (var V in Transports)
                        {
                            V.Resume();
                        }
                        WasPaused = false;

                        foreach (var pass in passengers)
                        {
                            pass.Draw();
                        }
                    }
                }
            }
            if (Transports[0].pass.Count != 0)
            {
                foreach (var passenger in Transports[0].pass)
                {
                    passenger.x =
                        (int)Canvas.GetLeft(((MainWindow)System.Windows.Application.Current.MainWindow).rect);
                    passenger.y = (int)Canvas.GetTop(((MainWindow)System.Windows.Application.Current.MainWindow).rect);
                }
                foreach (var VARIABLE in Transports[0].pass)
                {
                    VARIABLE.Draw();
                }
            }
            if (Transports[1].pass.Count != 0)
            {
                foreach (var passenger in Transports[1].pass)
                {
                    passenger.x =
                        (int)Canvas.GetLeft(((MainWindow)System.Windows.Application.Current.MainWindow).rect121);
                    passenger.y = (int)Canvas.GetTop(((MainWindow)System.Windows.Application.Current.MainWindow).rect121);
                }
                foreach (var VARIABLE in Transports[1].pass)
                {
                    VARIABLE.Draw();
                }
            }
        }
Exemplo n.º 7
0
        private void StationTimer_Tick(object sender, EventArgs e)
        {
            foreach (var VARIABLE in passengers)
            {
                if (VARIABLE.InTravel == true)
                {
                    VARIABLE.Draw();
                }
            }
            foreach (var VARIABLE in Transports)
            {
                VARIABLE.Draw();
            }
            CheckIfONGreenStation();
            CheckIfONRedStation();

            {
                int            index;
                List <Ellipse> bufferPoints = new List <Ellipse>();
                bufferPoints.AddRange(GreenStation);
                bufferPoints.AddRange(RedStation);
                foreach (var VARIABLE in passengers)
                {
                    int dx = 0, dy = 0;
                    if (VARIABLE.MotionStyle == 2)
                    {
                        int MinRad =
                            (int)
                            Math.Sqrt(Math.Pow(Canvas.GetLeft(bufferPoints[0]) - VARIABLE.x, 2) +
                                      Math.Pow(Canvas.GetTop(bufferPoints[0]) - VARIABLE.y, 2));
                        index = 0;
                        foreach (var VE in bufferPoints)
                        {
                            if (MinRad >
                                (int)
                                Math.Sqrt(Math.Pow(Canvas.GetLeft(VE) - VARIABLE.x, 2) +
                                          Math.Pow(Canvas.GetTop(VE) - VARIABLE.y, 2)))
                            {
                                MinRad =
                                    (int)
                                    Math.Sqrt(Math.Pow(Canvas.GetLeft(VE) - VARIABLE.x, 2) +
                                              Math.Pow(Canvas.GetTop(VE) - VARIABLE.y, 2));
                                index = bufferPoints.IndexOf(VE);
                            }
                        }
                        int dxx, dyx;
                        dxx = (int)Canvas.GetLeft(bufferPoints[bufferPoints.IndexOf(bufferPoints[index])]) - VARIABLE.x;
                        dyx = (int)Canvas.GetTop(bufferPoints[index]) - VARIABLE.y;
                        dxx = RandomizeStep(dxx);
                        dyx = RandomizeStep(dyx);

                        VARIABLE.Move(dxx / 20, dyx / 20);
                    }

                    if (VARIABLE.MotionStyle == 3)
                    {
                        int indexix = 0;
                        int MinRad;
                        if (passengers.Count > passengers.IndexOf(VARIABLE) + 1)
                        {
                            MinRad =
                                (int)
                                Math.Sqrt(
                                    Math.Pow(passengers[passengers.IndexOf(VARIABLE) + 1].x - VARIABLE.x, 2) +
                                    Math.Pow(passengers[passengers.IndexOf(VARIABLE) + 1].y - VARIABLE.y, 2));
                            indexix = passengers.IndexOf(VARIABLE) + 1;
                        }
                        else
                        {
                            MinRad = (int)
                                     Math.Sqrt(
                                Math.Pow(passengers[passengers.IndexOf(VARIABLE) - 1].x - VARIABLE.x, 2) +
                                Math.Pow(passengers[passengers.IndexOf(VARIABLE) - 1].y - VARIABLE.y, 2));
                            indexix = passengers.IndexOf(VARIABLE) - 1;
                        }
                        foreach (var VARIABL in passengers)
                        {
                            if (MinRad > (int)
                                Math.Sqrt(
                                    Math.Pow(VARIABL.x - VARIABLE.x, 2) +
                                    Math.Pow(VARIABL.y - VARIABLE.y, 2)) && VARIABL != VARIABLE)
                            {
                                MinRad = (int)
                                         Math.Sqrt(
                                    Math.Pow(VARIABL.x - VARIABLE.x, 2) +
                                    Math.Pow(VARIABL.y - VARIABLE.y, 2));
                                indexix = passengers.IndexOf(VARIABL);
                            }
                            // Rect rectangle1 = new Rect(VARIABL.x, VARIABL.y, Passenger.imagewx, Passenger.imagewy);
                            // Rect rectangle2 = new Rect(VARIABLE.x, VARIABLE.y, Passenger.imagewx, Passenger.imagewy);
                            //  if (rectangle1.IntersectsWith(rectangle2) && VARIABL.InTravel == false && VARIABLE.InTravel == false )
                            if (VARIABL / VARIABLE)
                            {
                                if (VARIABL.active == false)
                                {
                                    VARIABLE.active = false;
                                }
                                else
                                {
                                    VARIABL.Move(-100, -100);
                                    VARIABLE.Move(100, 100);
                                }
                            }

                            // MessageBox.Show("kek");
                        }
                        int dxx, dyx;
                        dxx = passengers[indexix].x - VARIABLE.x;
                        dyx = passengers[indexix].y - VARIABLE.y;
                        dxx = RandomizeStep(dxx);
                        dyx = RandomizeStep(dyx);
                        VARIABLE.Move(dxx / 20, dyx / 20);
                    }
                    if (VARIABLE.MotionStyle == 1)
                    {
                        VARIABLE.Move(out dx, out dy);

                        VARIABLE.Move(dx, dy);
                    }
                }
                foreach (var VARIBALE in passengers)
                {
                    VARIBALE.Draw();
                }
            }
        }
Exemplo n.º 8
0
 public void CheckIfONRedStation()
 {
     {
         if ((int)Canvas.GetLeft(((MainWindow)System.Windows.Application.Current.MainWindow).rect121) >= (int)RedBufferArrayOfStations[0].X - 50 &&
             (int)Canvas.GetLeft(((MainWindow)System.Windows.Application.Current.MainWindow).rect121) <= (int)RedBufferArrayOfStations[0].X + 50 &&
             (int)Canvas.GetTop(((MainWindow)System.Windows.Application.Current.MainWindow).rect121) >= (int)RedBufferArrayOfStations[0].Y - 50 &&
             (int)Canvas.GetTop(((MainWindow)System.Windows.Application.Current.MainWindow).rect121) <= (int)RedBufferArrayOfStations[0].Y + 50)
         {
             foreach (var VARIABLE in passengers.ToArray())
             {
                 if (VARIABLE.InTravel == true && (bool)VARIABLE.InTransport == false && VARIABLE.StationColor == Colors.Red)
                 {
                     if (RedBufferArrayOfStations[0] == RedPointInForward[(int)VARIABLE.CurrentStation])
                     {
                         AddInTransport bo = Transports[1].AddingPassenger;
                         IAsyncResult   ar = bo.BeginInvoke(VARIABLE, null, null);
                         Transports[1]++;
                         passengers.Remove(VARIABLE);
                     }
                     List <Point> buffer = new List <Point>();
                     buffer.AddRange(RedPointInBackward);
                     buffer.Reverse();
                     //
                     //if ((int)VARIABLE.NeedStation != 6 && (int)VARIABLE.NeedStation != 0)
                     if (RedBufferArrayOfStations[0] == buffer[(int)VARIABLE.CurrentStation])
                     {
                         AddInTransport bo = Transports[1].AddingPassenger;
                         IAsyncResult   ar = bo.BeginInvoke(VARIABLE, null, null);
                         Transports[1]++;
                         passengers.Remove(VARIABLE);
                     }
                 }
             }
             if (Transports[1].pass.Count != 0)
             {
                 List <Point> buffer = new List <Point>();
                 buffer.AddRange(RedPointInBackward);
                 buffer.Reverse();
                 foreach (var VARIABLE in Transports[1].pass.ToArray())
                 {
                     if (RedBufferArrayOfStations[0] == RedPointInForward[(int)VARIABLE.NeedStation])
                     {
                         VARIABLE.OutFromTransport();
                         Transports[1].pass.Remove(VARIABLE);
                         Transports[1]--;
                         passengers.Add(VARIABLE);
                         VARIABLE.x -= 200;
                         VARIABLE.y += 200;
                         VARIABLE.Draw();
                     }
                     else
                     {
                         //
                         //   if((int)VARIABLE.NeedStation!=6 && (int)VARIABLE.NeedStation != 0)
                         if (RedBufferArrayOfStations[0] == buffer[(int)VARIABLE.NeedStation])
                         {
                             VARIABLE.OutFromTransport();
                             Transports[1].pass.Remove(VARIABLE);
                             Transports[1]--;
                             passengers.Add(VARIABLE);
                             VARIABLE.x -= 200;
                             VARIABLE.y += 200;
                             VARIABLE.Draw();
                         }
                     }
                 }
             }
             dispatcherTimer1RED.Tick    += new EventHandler(dispatcherTimer1RED_Tick);
             dispatcherTimer1RED.Interval = new TimeSpan(0, 0, 0, 0, 1);
             dispatcherTimer1RED.Start();
             RedBufferArrayOfStations.RemoveAt(0);
         }
         if (RedBufferArrayOfStations.Count == 0)
         {
             RedBufferArrayOfStations.AddRange(RedPointInForward);
             RedBufferArrayOfStations.AddRange(RedPointInBackward);
         }
     }
 }