From 0a3c2da685a4c9c43f0c32b24bcf17620a75f7bd Mon Sep 17 00:00:00 2001 From: Hug0lvt Date: Tue, 18 Oct 2022 22:21:32 +0200 Subject: [PATCH] =?UTF-8?q?R=C3=A9solution=20des=20evenements=20sur=20main?= =?UTF-8?q?Window?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Code/IHM/MainWindow.xaml.cs | 72 +++++++++++++++++++++++++++++-------- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/Code/IHM/MainWindow.xaml.cs b/Code/IHM/MainWindow.xaml.cs index a169a81..a5401fc 100644 --- a/Code/IHM/MainWindow.xaml.cs +++ b/Code/IHM/MainWindow.xaml.cs @@ -28,18 +28,36 @@ namespace IHM DataContext = this; } + public void ChangerStyleBtn(Button btn) + { + + StackPanel sp = (StackPanel)btn.Parent; + if (sp == null) return; + UIElementCollection UIEC = sp.Children; + if (UIEC == null) return; + foreach (UIElement obj in UIEC) + { + + if (obj as Button != null) + { + (obj as Button).IsDefault = false; + } + + } + btn.IsDefault = true; + } + private void Button_Click_TableauDeBord(object sender, RoutedEventArgs e) { - Debug.WriteLine(e); + Button btn = (Button)sender; if (btn == null) return; if (btn.IsDefault == false) { - btn.IsDefault = true; Nav.NavigateTo(Navigator.PART_TABLEAU_DE_BORD); - //scan les autres btns - - + ChangerStyleBtn(btn); + + } else return; @@ -52,31 +70,57 @@ namespace IHM if (btn == null) return; if (btn.IsDefault == false) { - btn.IsDefault = true; + Nav.NavigateTo(Navigator.PART_COMPTE); -/* - StackPanel parent = btn.Parent as StackPanel; - foreach(Button bt in parent) - */ + ChangerStyleBtn(btn); } else return; - //Nav.NavigateTo(Navigator.PART_COMPTE); + } private void Button_Click_Operation(object sender, RoutedEventArgs e) { - Nav.NavigateTo(Navigator.PART_OPERATION); + Button btn = (Button)sender; + if (btn == null) return; + if (btn.IsDefault == false) + { + + Nav.NavigateTo(Navigator.PART_OPERATION); + ChangerStyleBtn(btn); + + } + else return; + } private void Button_Click_Echeancier(object sender, RoutedEventArgs e) { - Nav.NavigateTo(Navigator.PART_ECHEANCIER); + Button btn = (Button)sender; + if (btn == null) return; + if (btn.IsDefault == false) + { + + Nav.NavigateTo(Navigator.PART_ECHEANCIER); + ChangerStyleBtn(btn); + + } + else return; + } private void Button_Click_Plannification(object sender, RoutedEventArgs e) { - Nav.NavigateTo(Navigator.PART_PLANIFICATION); + Button btn = (Button)sender; + if (btn == null) return; + if (btn.IsDefault == false) + { + + Nav.NavigateTo(Navigator.PART_PLANIFICATION); + ChangerStyleBtn(btn); + + } + else return; }