private void FillStationSource()
 {
     if (CurRoute.Name == AllRoutes.First().Name)
     {
         ComboBoxStations.ItemsSource = AllStations.Concat(Db.Stations.Items);
     }
     else
     {
         ComboBoxStations.ItemsSource = AllStations.Concat(Db.Stations.Items.Where(
                                                               s => CurRoute.Stations.FirstOrDefault(st => st.StationId == s.Id) != null));
     }
 }
        private void ButtonFavorites_Click(object sender, RoutedEventArgs e)
        {
            FavoritesWindow window = new FavoritesWindow(this)
            {
                Owner = this
            };

            if (window.ShowDialog() == true)
            {
                CurStation = Db.Stations.Items.FirstOrDefault(s => s.Id == window.CurStation.Id);
                CurRoute   = AllRoutes.First();
                ComboBoxRoutes.SelectedItem   = AllRoutes.First();
                ComboBoxStations.SelectedItem = CurStation;
                StationSelect();
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            SetSelectItems();
            if (MessageBox.Show("Do you want to load from database?", "Loading priority",
                                MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                Db = Factory.Instance.GetDatabaseStorage();
            }
            else
            {
                Db = Factory.Instance.GetFileStorage(false);
            }

            CurRoute   = AllRoutes.First();
            CurStation = AllStations.First();
            FillStationSource();
            FillRouteSource();
        }