Ejemplo n.º 1
0
        /// <summary>
        /// jesli lewy przycisk jest przycisniety umozliwenie dragdropu pojazdu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void VehicleControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.MouseDevice.LeftButton == MouseButtonState.Pressed)
            {
                List <HorizontalRoadSign> listOfDirections = new List <HorizontalRoadSign>();

                //pobranie kierunkow w ktore moze poruszac sie pojazd na danym pasie
                if (vehicleVM.Lane == Lane.Lane1)
                {
                    listOfDirections = DI.laneDirectionPickerVM.CurrentDirectionLane1.DirectionsOnLane();
                }
                else if (vehicleVM.Lane == Lane.Lane2)
                {
                    listOfDirections = DI.laneDirectionPickerVM.CurrentDirectionLane2.DirectionsOnLane();
                }
                else if (vehicleVM.Lane == Lane.Lane3)
                {
                    listOfDirections = DI.laneDirectionPickerVM.CurrentDirectionLane3.DirectionsOnLane();
                }
                else if (vehicleVM.Lane == Lane.Lane4)
                {
                    listOfDirections = DI.laneDirectionPickerVM.CurrentDirectionLane4.DirectionsOnLane();
                }

                //tworzenie odpowiednich stref w zaleznosci od kierunkow w ktore moze poruszac sie pojazd
                foreach (HorizontalRoadSign roadSign in listOfDirections)
                {
                    if (roadSign == HorizontalRoadSign.Lewo)
                    {
                        DI.dataPickerVM.DepartureArea = DepartureArea.CreateLeft;
                    }
                    if (roadSign == HorizontalRoadSign.Prosto)
                    {
                        DI.dataPickerVM.DepartureArea = DepartureArea.CreateTop;
                    }
                    if (roadSign == HorizontalRoadSign.Prawo)
                    {
                        DI.dataPickerVM.DepartureArea = DepartureArea.CreateRight;
                    }
                }
                VehicleControl vehicle = sender as VehicleControl;

                //DragDrop pojazdu
                DragDrop.DoDragDrop(vehicle, vehicleVM, DragDropEffects.Move);

                //po zakonczeniu operacji usuwamy strefy DROP
                DI.dataPickerVM.DepartureArea = DepartureArea.Remove;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tworzenie nowego pojazdu przy zmianie wartosci
        /// </summary>
        /// <param name="d"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public static void CreateVehiclePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            VehicleType vehicleType = (VehicleType)e.NewValue;

            if (vehicleType == VehicleType.NONE)
            {
                return;
            }

            Grid inlet = (Grid)d;

            switch (vehicleType)
            {
            case VehicleType.SOD:
            {
                VehicleControl vehicleControl = new VehicleControl(DI.dataPickerVM.ActiveLane, VehicleType.SOD, "#9acd32");
                inlet.Children.Add(vehicleControl);
                break;
            }

            case VehicleType.A:
            {
                VehicleControl vehicleControl = new VehicleControl(DI.dataPickerVM.ActiveLane, VehicleType.A, "#ffff00");
                inlet.Children.Add(vehicleControl);
                break;
            }

            case VehicleType.AP:
            {
                VehicleControl vehicleControl = new VehicleControl(DI.dataPickerVM.ActiveLane, VehicleType.AP, "#ffd700");
                inlet.Children.Add(vehicleControl);
                break;
            }

            case VehicleType.SC:
            {
                VehicleControl vehicleControl = new VehicleControl(DI.dataPickerVM.ActiveLane, VehicleType.SC, "#daa520");
                inlet.Children.Add(vehicleControl);
                break;
            }

            case VehicleType.SCP:
            {
                VehicleControl vehicleControl = new VehicleControl(DI.dataPickerVM.ActiveLane, VehicleType.SCP, "#ffa500");
                inlet.Children.Add(vehicleControl);
                break;
            }

            case VehicleType.MR:
            {
                VehicleControl vehicleControl = new VehicleControl(DI.dataPickerVM.ActiveLane, VehicleType.MR, "#ff8c00");
                inlet.Children.Add(vehicleControl);
                break;
            }

            case VehicleType.INNE:
            {
                VehicleControl vehicleControl = new VehicleControl(DI.dataPickerVM.ActiveLane, VehicleType.INNE, "#ff0000");
                inlet.Children.Add(vehicleControl);
                break;
            }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Zmiana wartosci <see cref="ModeProperty"/>
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        public static object ModePropertyChanged(DependencyObject o, object e)
        {
            VehicleMode mode = (VehicleMode)e;

            if (mode == VehicleMode.None)
            {
                return(e);
            }

            VehicleControl vehicleControl = (VehicleControl)o;

            switch (mode)
            {
            case VehicleMode.Arrival:
            {
                vehicleControl.MoveVehicle.MoveOnArrival();
                break;
            }

            case VehicleMode.Departure:
            {
                VehicleViewModel vehicleVM = (VehicleViewModel)vehicleControl.DataContext;

                vehicleControl.MoveVehicle.MoveOnDeparture(vehicleVM.Lane, DI.laneDirectionPickerVM.NumberOfLanes + 1, vehicleVM.DirectionPicked);

                VehicleStorage.RemoveVehicle(vehicleVM.Lane);

                //jesli jeszcze jest jakis pojazd na wlocie to pierwszemu jest wlaczany
                //aby umozliwic operacje DragDrop
                if (VehicleStorage.GetLane(vehicleVM.Lane).Count > 0)
                {
                    VehicleStorage.GetFirstOnLane(vehicleVM.Lane).Enabled = true;
                }

                //ustawienie trybu kazdego pojazdu na VehicleMode.Lane, aby poruszyl sie na pasie
                //gdy ten pojazd odjedzie
                foreach (VehicleViewModel VM in VehicleStorage.GetLane(vehicleVM.Lane))
                {
                    VM.QueuePosition -= 1;

                    VM.Mode = VehicleMode.None;
                    VM.Mode = VehicleMode.Lane;
                }

                break;
            }

            case VehicleMode.Lane:
            {
                vehicleControl.MoveVehicle.MoveOnLane();
                break;
            }

            case VehicleMode.Remove:
            {
                (vehicleControl.Parent as Grid).Children.Remove(vehicleControl);
                break;
            }

            default: break;
            }

            return(e);
        }
Ejemplo n.º 4
0
 public MoveVehicleAnimation(VehicleControl vehicle, Lane lane)
 {
     this.vehicleControl = vehicle;
     this.lane           = lane;
 }