private void InitEdit()
 {
     TextBoxMake.Text      = carOld.GetMake();
     TextBoxModel.Text     = carOld.GetModel();
     TextBoxYear.Text      = carOld.GetYear().ToString();
     TextBoxEngine.Text    = carOld.GetEngine();
     TextBoxVehicleID.Text = carOld.GetVehicleID();
     TextBoxPlate.Text     = carOld.GetPlate();
 }
        /// <summary>
        /// Removes the Sensor
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private IEnumerable <char> RemoveSensor(params string[] args)
        {
            if (args.Length < 3 && args.Length != 2)
            {
                throw new CommandInputException("Invalid command usage, should be : sensor remove <model> [side] [sensor] [sensor]");
            }
            ;

            CarModel     model;
            Direction    side;
            CreateSensor sensorFactory;

            try
            {
                model = CarModel.GetModel(args[1]);
            }
            catch (Exception e)
            {
                throw new CommandInputException("Invalid command: Model doesn't exist.");
            }
            listPotentialRemoved = model.Sensors;
            var countSensorsModel = model.Sensors.Count;

            if (args.Length == 2)
            {
                printListPotentialRemoved();
                App.Console.SendCommand += removeSensors;
                return(null);
            }
            else
            {
                try
                {
                    side = StringConverters.StringToDirection(args[2]);
                }
                catch (Exception e)
                {
                    throw new CommandInputException("Invalid command: Side is wrong used.");
                }
                try
                {
                    sensorFactory = StringConverters.GetSensor(args[3]);
                }
                catch (Exception e)
                {
                    throw new CommandInputException("Invalid command: Could not create sensor.");
                }
                var count = model.Sensors
                            .FindAll(sensor => sensor.Create.Equals(sensorFactory) && side == sensor.Direction)
                            .Count;

                model.Sensors.RemoveAll(sensor => sensor.Create.Equals(sensorFactory) && side == sensor.Direction);
                return($"Removed {count} {args[3]} sensors.");
            }
        }
Exemple #3
0
        private void ListViewJob_DoubleClick(object sender, EventArgs e)
        {
            ListView.SelectedIndexCollection indices = ListViewJob.SelectedIndices;
            JobModel job = jobs[indices[0]];

            string title = car.GetMake() + " " + car.GetModel() + " ";

            JobOverview jobOverview = new JobOverview(job, title);

            jobOverview.ShowDialog();
        }
Exemple #4
0
        public Jobs(CarModel car, string carID)
        {
            InitializeComponent();

            this.car       = car;
            this.carID     = Int32.Parse(carID.Replace("Index:", ""));
            page           = 1;
            shownItems     = 20;
            jobsController = new JobsController();
            Text           = car.GetMake() + " " + car.GetModel() + " Jobs - CI Garage Manager";
        }
Exemple #5
0
        /*[TestCase(35, 85, DirectionCar.North, 90, 60, 2, 3, 0, 90, 75)]
         * [TestCase(45, 5, DirectionCar.West, 45, 90, 5, 0, 3, 35, 70)]
         * [TestCase(35, 85, DirectionCar.North, 90, 60, 2, 2, 0, 102.5, 60)]*/
        public void GetDirectionTest(double cX, double cY, DirectionCar direction, double dX, double dY, int road,
                                     int destRoad, int intersection, double eX, double eY)
        {
            var roads = new[]
            {
                new Road(new Vector(35, 80), new Vector(35, 100), 10, 0),
                new Road(new Vector(0, 75), new Vector(30, 75), 10, 0),
                new Road(new Vector(40, 75), new Vector(90, 75), 10, 0),
                new Road(new Vector(95, 70), new Vector(95, 10), 10, 0),
                new Road(new Vector(40, 5), new Vector(90, 5), 10, 0),
                new Road(new Vector(35, 10), new Vector(35, 70), 10, 0)
            };

            var intersections = new[]
            {
                new Intersection(new Vector(35, 75), 10),
                new Intersection(new Vector(95, 75), 10),
                new Intersection(new Vector(95, 5), 10),
                new Intersection(new Vector(35, 5), 10)
            };

            var city = new CityBuilder()
                       .Road(roads[0])
                       .Road(roads[1])
                       .Road(roads[2])
                       .Road(roads[3])
                       .Road(roads[4])
                       .Road(roads[5])
                       .Intersection(intersections[0])
                       .Intersection(intersections[1])
                       .Intersection(intersections[2])
                       .Intersection(intersections[3])
                       .Build();

            var car = new Car(1, CarModel.GetModel("TestModel"), new Vector(cX, cY), new List <Sensor>(), null, direction, 5, 5);

            city.Cars.Add(car);

            car.Destination = new Destination {
                Location = new Vector(dX, dY), Road = roads[destRoad]
            };

            var carDestination = GPSSystem.GetDirection(car, intersections[intersection]);

            Assert.AreEqual(roads[road], carDestination.Road);
            Assert.AreEqual(eX, carDestination.Location.X, 0.01);
            Assert.AreEqual(eY, carDestination.Location.Y, 0.01);
        }
 /// <summary>
 /// If any car property changed this method will save the new values.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnCarSave_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (Car.MaxSpeed.ToString() != CarMaxSpeedProperties.TBCurrentValue.Text)
     {
         var newValue = double.Parse(CarMaxSpeedProperties.TBCurrentValue.Text);
         Car.MaxSpeed = newValue;
         var newValue2 = CarModelProperties.TBCurrentValue.Text;
         try
         {
             Car.Model = CarModel.GetModel(newValue2);
         }
         catch (Exception)
         {
             MessageBox.Show("The changes have not been saved, the given model does not exist.", "Changes not saved.", MessageBoxButton.OK);
             return;
         }
     }
 }
        private void BtnGarageSave_Click(object sender, RoutedEventArgs e)
        {
            //If value changed
            if (Building.AvailableCars.ToString() != AvailableCarsProperty.TBCurrentValue.Text)
            {
                var newValue = (int)Math.Round(double.Parse(AvailableCarsProperty.TBCurrentValue.Text));
                Building.AvailableCars = newValue;
            }

            if (Building.Model.ToString() != CarModelProperties.TBCurrentValue.Text)
            {
                var newValue = CarModelProperties.TBCurrentValue.Text;
                try
                {
                    Building.Model = CarModel.GetModel(newValue);
                }
                catch (Exception)
                {
                    MessageBox.Show("The changes have not been saved, the given model does not exist.", "Changes not saved.", MessageBoxButton.OK);
                }
            }
        }
        /// <summary>
        /// Add's a sensor
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private IEnumerable <char> AddSensor(params string[] args)
        {
            if (args.Length < 4)
            {
                throw new CommandInputException("Invalid command usage, should be : sensor add <model> <side> <sensor> [range]");
            }
            ;

            if (args[0] != "add")
            {
                throw new CommandInputException("Invalid command useage, should be : sensor add <model> <side> <sensor> [range]");
            }
            ;

            CarModel     model;
            Direction    side;
            CreateSensor sensorFactory;

            try
            {
                model = CarModel.GetModel(args[1]);
            }
            catch (Exception)
            {
                throw new CommandInputException("Invalid command: Model doesn't exist.");
            }
            try
            {
                side = StringConverters.StringToDirection(args[2]);
            }
            catch (Exception)
            {
                throw new CommandInputException("Invalid command: Side is wrong used.");
            }
            try
            {
                sensorFactory = StringConverters.GetSensor(args[3]);
            }
            catch (Exception)
            {
                throw new CommandInputException("Invalid command: Could not create sensor.");
            }
            var range = 0;

            if (args.Length == 5)
            {
                try
                {
                    range = int.Parse(args[4]);
                }
                catch (Exception)
                {
                    throw new CommandInputException("Invalid command: Could not parse range.");
                }
            }

            var sensor = new SensorPrototype
            {
                Direction = side,
                Range     = range,
                Create    = sensorFactory
            };

            model.Sensors.Add(sensor);

            CitySystem.City.Instance.Cars
            .FindAll(car => car.Model == model)
            .ForEach(car => car.Sensors.Add(sensor.Create(car, sensor.Direction, sensor.Range)));



            return($"Added sensor {args[3]} to {model.Name}");
        }