private void Second_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args) { secondStop = args.SelectedItem as DirectionStopSQL; sender.Text = secondStop.name; sender.IsEnabled = false; sender.IsEnabled = true; }
private void Button_Click(object sender, RoutedEventArgs e) { DirectionStopSQL model = (((sender as Button).Parent as Border).Parent as Grid).DataContext as DirectionStopSQL; Stops.Where(d => d.n_id == model.n_id).First().Favorite = (model.favorite == Constant.FavoriteStar) ? Constant.UnFavoriteStar : Constant.FavoriteStar; Database.AddOrRemoveFromFavorite(model.n_id, model.r_id, model.d_id); }
private async void Swap_Click(object sender, RoutedEventArgs e) { if (firstStop != null && secondStop != null) { DirectionStopSQL tempObj = new DirectionStopSQL(); tempObj = secondStop; secondStop = firstStop; firstStop = tempObj; FirstAutoSug.Text = firstStop.name; SecondAutoSug.Text = secondStop.name; } }
private void Button_Click(object sender, RoutedEventArgs e) { DirectionStopSQL model = (((((sender as Button).Parent as Border).Parent as StackPanel).Parent as Grid).Parent as StackPanel).DataContext as DirectionStopSQL; if (model.type == 0) { Buses.Where(d => d.d_id == model.d_id).First().Favorite = (model.favorite == Constant.FavoriteStar) ? Constant.UnFavoriteStar : Constant.FavoriteStar; } else if (model.type == 1) { Trolls.Where(d => d.d_id == model.d_id).First().Favorite = (model.favorite == Constant.FavoriteStar) ? Constant.UnFavoriteStar : Constant.FavoriteStar; } else if (model.type == 2) { Tramms.Where(d => d.d_id == model.d_id).First().Favorite = (model.favorite == Constant.FavoriteStar) ? Constant.UnFavoriteStar : Constant.FavoriteStar; } Database.AddOrRemoveFromFavorite(model.n_id, model.r_id, model.d_id); }
private void Button_Click(object sender, RoutedEventArgs e) { DirectionStopSQL model = (((((sender as Button).Parent as Border).Parent as StackPanel).Parent as Grid).Parent as StackPanel).DataContext as DirectionStopSQL; Database.AddOrRemoveFromFavorite(model.n_id, model.r_id, model.d_id); if (model.type == 0) { Buses.Remove(model); } else if (model.type == 1) { Trolls.Remove(model); } else if (model.type == 2) { Tramms.Remove(model); } }
private void ListView_ItemClick(object sender, ItemClickEventArgs e) { DirectionStopSQL paramItem = e.ClickedItem as DirectionStopSQL; ScheduleSQL mainSchedule = new ScheduleSQL() { favorite = (paramItem.favorite == Constant.FavoriteStar) ? true : false, type = param.type, width = param.width, days = paramItem.days, schedule = paramItem.schedule, number = param.number, d_name = param.name, s_name = paramItem.name, d_id = paramItem.d_id, r_id = paramItem.r_id, next_bus = paramItem.next_bus, n_id = paramItem.n_id }; if (!Frame.Navigate(typeof(Views.MainSchedule), JsonConvert.SerializeObject(mainSchedule))) { throw new Exception(this.resourceLoader.GetString("NavigationFailedExceptionMessage")); } }
private async void GetRoutes() { if (secondStop != null && firstStop != null) { SQLiteConnection connection = new SQLiteConnection(dbPath); Buses = new ObservableCollection <DirectionStopSQL>(); Trolls = new ObservableCollection <DirectionStopSQL>(); Tramms = new ObservableCollection <DirectionStopSQL>(); List <DirectionStopSQL> firstRoutes = connection.Query <DirectionStopSQL>( "SELECT s.r_id as r_id, s.n_id as n_id, s.d_id as d_id,d.name as name, r.number as number, s.schedule as schedule, s.days as days, r.type as type " + "FROM stop AS s " + "LEFT JOIN direction as d ON d_id = d.id " + "LEFT JOIN route as r ON r_id = r.id " + "WHERE n_id=" + firstStop.n_id); List <DirectionStopSQL> secondRoutes = connection.Query <DirectionStopSQL>( "SELECT s.r_id as r_id, s.n_id as n_id, s.d_id as d_id,d.name as name, r.number as number, s.schedule as schedule, s.days as days, r.type as type " + "FROM stop AS s " + "LEFT JOIN direction as d ON d_id = d.id " + "LEFT JOIN route as r ON r_id = r.id " + "WHERE n_id=" + secondStop.n_id); List <DirectionStopSQL> SecondBus = new List <DirectionStopSQL>(); List <DirectionStopSQL> SecondTroll = new List <DirectionStopSQL>(); List <DirectionStopSQL> SecondTramm = new List <DirectionStopSQL>(); foreach (var item in secondRoutes) { if (item.type == 0) { SecondBus.Add(new DirectionStopSQL() { width = width, name = item.name, r_id = item.r_id, number = item.number, type = item.type, d_id = item.d_id, n_id = item.n_id, days = item.days, schedule = item.schedule, next_bus = time.getNextBusTime(item.schedule, item.days), }); } else if (item.type == 1) { SecondTroll.Add(new DirectionStopSQL() { width = width, name = item.name, r_id = item.r_id, number = item.number, d_id = item.d_id, type = item.type, n_id = item.n_id, days = item.days, schedule = item.schedule, next_bus = time.getNextBusTime(item.schedule, item.days), }); } else if (item.type == 2) { SecondTramm.Add(new DirectionStopSQL() { width = width, name = item.name, r_id = item.r_id, number = item.number, d_id = item.d_id, type = item.type, n_id = item.n_id, days = item.days, schedule = item.schedule, next_bus = time.getNextBusTime(item.schedule, item.days), }); } } foreach (var bus in SecondBus) { List <DirectionStopSQL> firstItem = connection.Query <DirectionStopSQL>( "SELECT s.r_id as r_id, s.n_id as n_id, s.d_id as d_id, REPLACE(sn.name,'ул. ','') as name, s.schedule as schedule, r.number as number, s.days as days " + "FROM stop AS s " + "LEFT JOIN route as r ON r_id = r.id " + "LEFT JOIN stopname as sn ON s.n_id = sn.id " + "WHERE s.d_id=" + bus.d_id + " AND s.r_id=" + bus.r_id + " " + "GROUP BY name " + "ORDER BY CAST(s.id AS INT)"); DirectionStopSQL search_first = firstItem.Where(item => item.name.ToUpper() == firstStop.name.ToUpper()).FirstOrDefault(); DirectionStopSQL search_second = firstItem.Where(item => item.name.ToUpper() == secondStop.name.ToUpper()).FirstOrDefault(); if (search_first != null && search_second != null) { int first_index = firstItem.IndexOf(search_first); int second_index = firstItem.IndexOf(search_second); if (second_index > first_index) { DirectionStopSQL stop = firstRoutes.Where(item => item.d_id == bus.d_id && item.r_id == bus.r_id && item.type == 0).FirstOrDefault(); stop.stop_count = this.resourceLoader.GetString("String_StopCount") + ": " + (second_index - first_index).ToString(); stop.next_bus = time.getNextBusTime(stop.schedule, stop.days); stop.width = width; Buses.Add(stop); } } } foreach (var troll in SecondTroll) { List <DirectionStopSQL> firstItem = connection.Query <DirectionStopSQL>( "SELECT s.r_id as r_id, s.n_id as n_id, s.d_id as d_id, REPLACE(sn.name,'ул. ','') as name, s.schedule as schedule, r.number as number, s.days as days " + "FROM stop AS s " + "LEFT JOIN route as r ON r_id = r.id " + "LEFT JOIN stopname as sn ON s.n_id = sn.id " + "WHERE s.d_id=" + troll.d_id + " AND s.r_id=" + troll.r_id + " " + "GROUP BY name " + "ORDER BY CAST(s.id AS INT)"); DirectionStopSQL search_first = firstItem.Where(item => item.name.ToUpper() == firstStop.name.ToUpper()).FirstOrDefault(); DirectionStopSQL search_second = firstItem.Where(item => item.name.ToUpper() == secondStop.name.ToUpper()).FirstOrDefault(); if (search_first != null && search_second != null) { int first_index = firstItem.IndexOf(search_first); int second_index = firstItem.IndexOf(search_second); if (second_index > first_index) { DirectionStopSQL stop = firstRoutes.Where(item => item.d_id == troll.d_id && item.r_id == troll.r_id && item.type == 1).FirstOrDefault(); stop.stop_count = this.resourceLoader.GetString("String_StopCount") + ": " + (second_index - first_index).ToString(); stop.next_bus = time.getNextBusTime(stop.schedule, stop.days); stop.width = width; Trolls.Add(stop); } } } foreach (var tramm in SecondTramm) { List <DirectionStopSQL> firstItem = connection.Query <DirectionStopSQL>( "SELECT s.r_id as r_id, s.n_id as n_id, s.d_id as d_id, REPLACE(sn.name,'ул. ','') as name, s.schedule as schedule, r.number as number, s.days as days " + "FROM stop AS s " + "LEFT JOIN route as r ON r_id = r.id " + "LEFT JOIN stopname as sn ON s.n_id = sn.id " + "WHERE s.d_id=" + tramm.d_id + " AND s.r_id=" + tramm.r_id + " " + "GROUP BY name " + "ORDER BY CAST(s.id AS INT)"); DirectionStopSQL search_first = firstItem.Where(item => item.name.ToUpper() == firstStop.name.ToUpper()).FirstOrDefault(); DirectionStopSQL search_second = firstItem.Where(item => item.name.ToUpper() == secondStop.name.ToUpper()).FirstOrDefault(); if (search_first != null && search_second != null) { int first_index = firstItem.IndexOf(search_first); int second_index = firstItem.IndexOf(search_second); if (second_index > first_index) { DirectionStopSQL stop = firstRoutes.Where(item => item.d_id == tramm.d_id && item.r_id == tramm.r_id && item.type == 2).FirstOrDefault(); stop.stop_count = this.resourceLoader.GetString("String_StopCount") + ": " + (second_index - first_index).ToString(); stop.next_bus = time.getNextBusTime(stop.schedule, stop.days); stop.width = width; Tramms.Add(stop); } } } this.DefaultViewModel["Buses"] = Buses.OrderBy(item => item.r_id); this.DefaultViewModel["Trolls"] = Trolls.OrderBy(item => item.r_id); this.DefaultViewModel["Tramms"] = Tramms.OrderBy(item => item.r_id); } }