Ejemplo n.º 1
0
        private void ApplyForAll()
        {
            isApplying = true;
            foreach (Crossing crossing in manager.Grid.AllCrossings)
            {
                if (crossing == null)
                {
                    continue;
                }
                if (manager.CurrentActiveComponent is Lane)
                {
                    if (cbApplyCrossing.Checked && manager.CurrentActiveLane.Owner.Owner != crossing)
                    {
                        continue;
                    }
                    ActionStack.AddAction(new UpdateMultipleFlowAction((int)propertiesEditNUD.Value, crossing));
                }
                if (manager.CurrentActiveComponent is Trafficlight)
                {
                    if (cbApplyCrossing.Checked && manager.CurrentActiveTrafficLight.Owner != crossing)
                    {
                        continue;
                    }

                    ActionStack.AddAction(new UpdateMultipleIntervalAction((int)propertiesEditNUD.Value, crossing));
                }
                slotIDToPBoxLookup[crossing.Column + crossing.Row * 3].Invalidate();
            }
            isApplying = false;
        }
Ejemplo n.º 2
0
        private void PlaceCrossing(PictureBox currentBox)
        {
            if (state != SystemState.Place)
            {
                return;
            }

            int id = pBoxToSlotIDLookup[currentBox];

            ActionStack.AddAction(new PlaceCrossingAction(id / 3, id % 3, Activator.CreateInstance(crossingToBePlaced.GetType(), manager) as Crossing));
        }
Ejemplo n.º 3
0
        private void RemoveCrossing(PictureBox currentBox)
        {
            if (state != SystemState.Delete)
            {
                return;
            }
            if (currentBox.Image == null)
            {
                return;
            }

            int id = pBoxToSlotIDLookup[currentBox];

            ActionStack.AddAction(new RemoveCrossingAction(id / 3, id % 3, manager.Grid.Crossings[id / 3][id % 3]));
        }
Ejemplo n.º 4
0
 private void updateFlowBtn_Click(object sender, EventArgs e)
 {
     if (manager.CurrentActiveLane != null)
     {
         // TODO-IF Current Lane is allowed to have pedestrians enable button, otherwise disable
         // when pedestrians activated the cars which are about to get into the lane have to wait for the pedestrians to pass (or other type of functionality)
         if (manager.CurrentActiveLane.Flow == (int)propertiesEditNUD.Value)
         {
             return;
         }
         if (cbApply.Checked || cbApplyCrossing.Checked)
         {
             ApplyForAll();
         }
         else
         {
             ActionStack.AddAction(new UpdateFlowAction((int)propertiesEditNUD.Value, manager.CurrentActiveLane));
             slotIDToPBoxLookup[manager.CurrentActiveLane.Owner.Owner.Column + manager.CurrentActiveLane.Owner.Owner.Row * 3].Invalidate();
         }
     }
     else if (manager.CurrentActiveTrafficLight != null)
     {
         if (manager.CurrentActiveTrafficLight.GreenSeconds == (float)propertiesEditNUD.Value)
         {
             return;
         }
         if (cbApply.Checked || cbApplyCrossing.Checked)
         {
             ApplyForAll();
         }
         else
         {
             ActionStack.AddAction(new UpdateLightIntervalAction((int)propertiesEditNUD.Value, manager.CurrentActiveTrafficLight));
             slotIDToPBoxLookup[manager.CurrentActiveTrafficLight.Owner.Column + manager.CurrentActiveTrafficLight.Owner.Row * 3].Invalidate();
         }
     }
     UpdateInterface();
 }