public async void Save() //Sauvegarde les données entrées dans un fichier { if (store.Folder == null) //pas de dossier sélectionné { await new MessageDialog("Veuillez sélectionner un emplacement.").ShowAsync(); return; } Matchimpro match = new Matchimpro(nomeq1.Text.Trim(), nomeq2.Text.Trim(), numberofround.SelectedIndex + 1); match.Save(store.Folder); MainPage mainFrame = (MainPage)((Frame)Window.Current.Content).Content; if (mainFrame.navigationView.MenuItems.Count == 5) { mainFrame.navigationView.MenuItems[0] = new NavigationViewItem { Name = "CURRENT", IsSelected = true, Content = "Match en cours", Icon = new SymbolIcon((Symbol)0xE945), Tag = "currentNav" }; } MainPage.MainPageFrame?.Navigate(typeof(CurrentMatchPage), match); //renvoie à la page de match }
private async void Read_storage()//lit le contenu du dossier de stockage { var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); StorageFolder storageFolder = store.Folder; List <Matchimpro> matchlist = await Matchimpro.ReadFolder(storageFolder); if (matchlist.Count > 0) { recent_matches.Visibility = Visibility.Visible; nb_matches.Text = $"{matchlist.Count} {(matchlist.Count > 1 ? resourceLoader.GetString("RecentMatchMultiple") : resourceLoader.GetString("RecentMatchSingle"))}"; mostRecentMatch = matchlist[0]; most_recent_match.Text = mostRecentMatch.Name; } else { recent_matches.Visibility = Visibility.Collapsed; } if (!File.Exists(storageFolder.Path + Path.DirectorySeparatorChar + "Categories.catei"))//si le fichier de catégorie n'existe pas, on masque la listview { StorageFile file = await store.Folder.CreateFileAsync("Categories.catei", CreationCollisionOption.FailIfExists); await FileIO.WriteTextAsync(file, string.Join("\n", "Libre")); } }
protected async override void OnFileActivated(FileActivatedEventArgs args) { base.OnFileActivated(args); StorageFile file = (StorageFile)args.Files[0]; //TODO Prendre en charge l'import de fichier Catei également try { if (file.Name.Contains(".matchi")) { Matchimpro match = await Matchimpro.ReadFile(file); var rootFrame = new Frame(); Window.Current.Content = rootFrame; Window.Current.Activate(); rootFrame.Navigate(typeof(MainPage), match); } else if (file.Name.Contains(".catei")) { var rootFrame = new Frame(); Window.Current.Content = rootFrame; Window.Current.Activate(); rootFrame.Navigate(typeof(MainPage), "catei"); } } catch (Exception) { MessageDialog error = new MessageDialog("Le fichier sélectionné n'a pas pu être lu."); await error.ShowAsync(); this.Exit(); } }
private async void Delete_click(object sender, RoutedEventArgs e) { var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); ContentDialog deleteFileDialog = new ContentDialog { Title = resourceLoader.GetString("WarningMessage"), Content = resourceLoader.GetString("MatchDeleteMessage"), PrimaryButtonText = resourceLoader.GetString("DeleteButton"), CloseButtonText = resourceLoader.GetString("CancelButton") }; ContentDialogResult result = await deleteFileDialog.ShowAsync(); if (result == ContentDialogResult.Primary) { Matchimpro match = (Matchimpro)list_of_matches.SelectedItem; match.DeleteFile(); matchlist.Remove(match); } }
private async void Read_storage()//lit le contenu du dossier de stockage { var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); matchlist = new ObservableCollection <Matchimpro>(await Matchimpro.ReadFolder(store.Folder)); list_of_matches.ItemsSource = matchlist; if (matchlist.Count > 0) { error_message.Visibility = Visibility.Collapsed; info_messages.Visibility = Visibility.Visible; list_of_matches.Visibility = Visibility.Visible; header_title.Text = resourceLoader.GetString("RecentMatchesTitle"); } else { info_messages.Visibility = Visibility.Collapsed;//messages par défaut si pas de fichiers ou mauvais format error_message.Visibility = Visibility.Visible; list_of_matches.Visibility = Visibility.Collapsed; header_title.Text = resourceLoader.GetString("RecentMatchesDefault");; } }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter is Matchimpro) { var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); Matchimpro match = (Matchimpro)e.Parameter; match.Save(store.Folder); contentFrame.Navigate(typeof(CurrentMatchPage), match); ToastNotifier ToastNotifier = ToastNotificationManager.CreateToastNotifier(); XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); XmlNodeList toastNodeList = toastXml.GetElementsByTagName("text"); toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(resourceLoader.GetString("ImportTitle"))); toastNodeList.Item(1).AppendChild(toastXml.CreateTextNode(resourceLoader.GetString("ImportMessage"))); ToastNotification toast = new ToastNotification(toastXml); toast.ExpirationTime = DateTime.Now.AddSeconds(1); ToastNotifier.Show(toast); } else if (e.Parameter is "catei") { contentFrame.Navigate(typeof(ImportCatei)); } }