From 5f3480bf989faa3c047656c08f9af70c551013f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20LAVERGNE?= Date: Sun, 2 Jun 2024 23:25:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Am=C3=A9lioration=20du=20binding?= =?UTF-8?q?,=20avec=20l'actualisation=20et=20l'interaction=20avec=20la=20g?= =?UTF-8?q?rille=20d'op=C3=A9ration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/Trek-12/Trek-12/Views/PageBoard.xaml | 95 +++++++++++-------- .../Trek-12/Trek-12/Views/PageBoard.xaml.cs | 19 ++++ 2 files changed, 76 insertions(+), 38 deletions(-) diff --git a/source/Trek-12/Trek-12/Views/PageBoard.xaml b/source/Trek-12/Trek-12/Views/PageBoard.xaml index 6527854..587ac7a 100644 --- a/source/Trek-12/Trek-12/Views/PageBoard.xaml +++ b/source/Trek-12/Trek-12/Views/PageBoard.xaml @@ -2,58 +2,77 @@ - - - + + + + + - - + + + + + Padding="0"> + + + + + + + + - - - - + + + + + + - + BackgroundColor="Transparent" + SelectionChanged="OnOperationCellSelected" + Margin="50"> + - - - + + + - - + \ No newline at end of file diff --git a/source/Trek-12/Trek-12/Views/PageBoard.xaml.cs b/source/Trek-12/Trek-12/Views/PageBoard.xaml.cs index 8260b4b..1f66020 100644 --- a/source/Trek-12/Trek-12/Views/PageBoard.xaml.cs +++ b/source/Trek-12/Trek-12/Views/PageBoard.xaml.cs @@ -1,4 +1,8 @@ +using System.Diagnostics; + namespace Trek_12.Views; + +using Models.Game; using Stub; public partial class PageBoard : ContentPage @@ -10,4 +14,19 @@ public partial class PageBoard : ContentPage InitializeComponent(); BindingContext = MyStub; } + + private void OnOperationCellSelected(object sender, SelectionChangedEventArgs e) + { + Debug.WriteLine("OnOperationCellSelected"); // Debug + if (e.CurrentSelection.Count > 0) // Si un élément est sélectionné + { + var selectedCell = (OperationCell)e.CurrentSelection[0]; + if (selectedCell != null && !selectedCell.IsChecked) + { + selectedCell.Check(); + Debug.WriteLine("OperationCell at ({0}, {1}) is checked", selectedCell.X, selectedCell.Y); // Debug + } + ((CollectionView)sender).SelectedItem = null; // Déselectionne l'élément pour la CollectionView + } + } } \ No newline at end of file