Exemple #1
0
        public void UpdateClassFilterList()
        {
            if (Simulator.Instance.Drivers == null)
            {
                return;
            }

            // When the session info update we might have to add or remove possible classes from the class filter dropdown
            var dict = _classFilterItems.ToDictionary(f => f.CarClassRelSpeed);

            foreach (var driver in Simulator.Instance.Drivers.OrderByDescending(d => d.Driver.CarClassRelSpeed))
            {
                if (driver.Driver.IsSpectator || driver.Driver.IsPacecar)
                {
                    continue;
                }

                var speed = driver.Driver.CarClassRelSpeed;
                if (!dict.ContainsKey(speed))
                {
                    var item = new ClassFilterItem()
                    {
                        CarClassRelSpeed = speed,
                        Brush            = new SolidColorBrush(driver.Driver.CarClassColor)
                    };
                    _classFilterItems.Add(item);
                    dict.Add(speed, item);
                }
            }
        }
Exemple #2
0
        public DriverListModel(MainViewModel mainModel)
        {
            _mainModel = mainModel;

            // Initialize views and filters
            _driversView      = (ListCollectionView)CollectionViewSource.GetDefaultView(Simulator.Instance.Drivers);
            _classFilterItems = new ObservableCollection <ClassFilterItem>();
            _classFilterItems.Add(ClassFilterItem.All());

            _driverFilter = new DriverFilter();
            _driverFilter.Attach(_driversView);
            _selectedDrivers = new ObservableCollection <DriverContainer>();
        }