From bec919bf9917797935ec4f029cba895380bdcdf5 Mon Sep 17 00:00:00 2001 From: Yoan Date: Sat, 6 May 2023 18:49:50 +0200 Subject: [PATCH] Barre de recherche effective pour les Fruits du demon --- Sources/Model/Manager.cs | 29 +++++++++++++++++++++++++++++ Sources/Ohara/PageFDD.xaml | 16 ++++++++++++++-- Sources/Ohara/PageFDD.xaml.cs | 22 +++++++++++++++++++++- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs index a7dfd30..cef6e1a 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Manager.cs @@ -55,5 +55,34 @@ namespace Model } return fdd; } + + public List RechercheFDD(string text,List listeFDD) + { + if (text == "") { + return listeFDD; + } + foreach(FruitDuDemon f in listeFDD.ToList()) + { + bool correspondance = false; + int textPos = 0; + for (int i = 0; i < (f.Nom.Length); i++) { + if (string.Equals(text[textPos].ToString(), f.Nom[i].ToString(), StringComparison.OrdinalIgnoreCase)) + { + textPos++; + } + if(textPos == text.Length) + { + correspondance = true; + break; + } + + } + if (!correspondance) + { + listeFDD.Remove(f); + } + } + return listeFDD; + } } } diff --git a/Sources/Ohara/PageFDD.xaml b/Sources/Ohara/PageFDD.xaml index dabb1ed..9835db0 100644 --- a/Sources/Ohara/PageFDD.xaml +++ b/Sources/Ohara/PageFDD.xaml @@ -4,8 +4,8 @@ x:Class="Ohara.PageFDD" Title="PageFDD" BackgroundColor="#e2edf1"> - + @@ -34,6 +34,7 @@