private async void Favourite_ContextMenu_Add_Stop(object sender, RoutedEventArgs e) { string str = ((MenuItem)sender).Tag.ToString(); await Favourite.WriteToFile(str, "Stop"); await Favourite_Init(false); }
public async Task Favourite_Init(bool scroll) { // Вставляю картинку в зависимости от цвета темы BitmapImage _bi = new BitmapImage(); if (Util.GetThemeColor() == "dark") { _bi.UriSource = new Uri("/Images/favs.png", UriKind.Relative); } else { _bi.UriSource = new Uri("/Images/favs.dark.png", UriKind.Relative); } Favourite_Image.Source = _bi; // Инициализация, собственно Favourite.Model data = await Favourite.ReadFile(); if (data == null) { Util.Hide(Favourite_Items); Util.Show(Favourite_NoItems); return; } Favourive_Routes.ItemsSource = data.Routes; Favourive_Stops.ItemsSource = data.Stops; Util.Hide(Favourite_NoItems); Util.Show(Favourite_Items); // Скролл к избранному, если выбранно и установка нужного значения в настройках if (Data.Settings.GetOrDefault("ScrollToFavouriteOnStart", "true") == "true") { if (scroll) { Pivot_Main.SelectedIndex = GetPivotItemIntByName("Favourite"); } // менять ничего в настройках не надо, всё выставлено по умолчанию на «да» } else { Favourite_Scroll_ToggleSwicth.Content = "Нет"; Favourite_Scroll_ToggleSwicth.IsChecked = false; } }