private static void UpdateFuelDispenserInfo(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            _selectedFuelDispenser = modelingForm.SelectedFuelDispenser ?? mappedTopology.FuelDispensersList.First();
            var fuelDispenserView = _selectedFuelDispenser.Tag as FuelDispenserView;

            modelingForm.LabelSpeedOfFillingValue.Text = fuelDispenserView.SpeedOfFillingPerMinute.ToString();
        }
        private static void UpdateFuelTankInfo(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            _selectedFuelTank = modelingForm.SelectedFuelTank ?? mappedTopology.FuelTanksList.First();
            var fuelTankView = _selectedFuelTank.Tag as FuelTankView;

            modelingForm.LabelFuelValue.Text            = fuelTankView.Fuel.ToString();
            modelingForm.LabelVolumeValue.Text          = ((int)fuelTankView.Volume).ToString();
            modelingForm.LabelCurrentFullnessValue.Text = ((int)fuelTankView.CurrentFullness).ToString();
        }
        internal static void SetUpModelingProcessor(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            CashCounter        = mappedTopology.CashCounter;
            FuelDispensersList = mappedTopology.FuelDispensersList;
            FuelTanksList      = mappedTopology.FuelTanksList;
            _isCollectingMoney = false;
            _isRefilling       = false;

            CarMover.SetUpCarMover(modelingForm);
            CarRouter.SetUpCarRouter(modelingForm);

            RefuellerMover.SetUpRefuellerMover(modelingForm);
        }
        internal static MappedTopology MapTopology(ModelingForm modelingForm,
                                                   Topology.Topology topology, TrafficFlow trafficFlow)
        {
            _modelingForm = modelingForm;
            _topology     = topology;
            ModelSettings.SetUpModelSettings(trafficFlow);
            _mappedTopology = new MappedTopology();
            ElementPictureBoxProducer.SetUpElementPictureBoxProducer(modelingForm, _mappedTopology);

            SetupPlaygroundPanel();
            SetupServiceArea();

            DestinationPointsDefiner.DefineElementsPoints(_mappedTopology);

            return(_mappedTopology);
        }
        private static void UpdateUI(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            UpdateCashCounterInfo(modelingForm, mappedTopology);
            UpdateFuelDispenserInfo(modelingForm, mappedTopology);
            UpdateFuelTankInfo(modelingForm, mappedTopology);

            _selectedItem = modelingForm.SelectedItem;

            if (_selectedItem != null)
            {
                if (_selectedItem.Tag is CarView)
                {
                    CarPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem.Tag is FuelDispenserView)
                {
                    FuelDispenserPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem.Tag is FuelTankView)
                {
                    FuelTankPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem.Tag is CashCounterView)
                {
                    CashCounterPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem is CollectorPictureBox)
                {
                    CashCollectorPictureBox_Click(_selectedItem, null);
                }
            }
        }
 internal static void SetUpElementPictureBoxProducer(ModelingForm modelingForm, MappedTopology mappedTopology)
 {
     _modelingForm   = modelingForm;
     _mappedTopology = mappedTopology;
 }
        internal static void Tick(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            if (IsPaused)
            {
                return;
            }

            TimerTicksCount++;
            TicksAfterLastCarSpawning++;

            if (TimeAfterLastCarSpawningInSeconds >= TimeBetweenCars)
            {
                CarCreator.SpawnCar();
                TimeBetweenCars           = ModelSettings.TrafficFlow.TimeBetweenCars;
                TicksAfterLastCarSpawning = 0;
            }

            //if (!_paused)
            //{
            //    //return;
            //    //CarCreator.SpawnCar();
            //    CarCreator.SpawnCollector();

            //    _paused = true;
            //}


            //if (TimerTicksCount % 20 == 0)
            //{
            //    CarCreator.SpawnCar();
            //}

            #region LoopingControls

            var panelPlayground = modelingForm.PlaygroundPanel;

            foreach (Control control in panelPlayground.Controls)
            {
                if (!(control is MoveablePictureBox))
                {
                    continue;
                }

                var moveablePictureBox = control as MoveablePictureBox;

                // Car
                if (moveablePictureBox is CarPictureBox car)
                {
                    CarRouter.RouteCar(car);

                    CarMover.MoveCarToDestination(car);

                    continue;
                }

                // Collector
                if (moveablePictureBox is CollectorPictureBox collector)
                {
                    CarRouter.RouteCar(collector);

                    CarMover.MoveCarToDestination(collector);

                    continue;
                }

                // Refueller
                if (moveablePictureBox is RefuellerPictureBox refueller)
                {
                    RefuellerRouter.RouteRefueller(refueller);

                    RefuellerMover.MoveRefuellerToDestination(refueller);
                }
            }

            #endregion /LoopingControls

            #region UI

            UpdateUI(modelingForm, mappedTopology);

            #endregion UI
        }
 private static void UpdateCashCounterInfo(ModelingForm modelingForm, MappedTopology mappedTopology)
 {
     modelingForm.LabelCashCounterSumValue.Text =
         ((int)((CashCounterView)mappedTopology.CashCounter.Tag).CurrentCashVolume).ToString();
 }