private void ReloadCBs()
 {
     if (jourActive)
     {
         SemaineJourSelect.Items.Clear();
         int n = DateTime.DaysInMonth(Year, Month);
         for (int i = 1; i <= n; ++i)
         {
             ComboBoxItem cbi = new ComboBoxItem()
             {
                 Content = $"Jour {i}"
             };
             SemaineJourSelect.Items.Add(cbi);
         }
         this.SemaineJourSelect.SelectedIndex = selectedDay - 1;
         this.monthSelect.SelectedIndex       = Month - 1;
         this.yearSelect.SelectedIndex        = Year - MinYear;
     }
     else
     {
         SemaineJourSelect.Items.Clear();
         for (int i = 1; i <= AffichageParSemaineControl.DivideToWeeks(Month, Year).Values.Count; ++i)
         {
             ComboBoxItem cbi = new ComboBoxItem()
             {
                 Content = $"Semaine {i}"
             };
             SemaineJourSelect.Items.Add(cbi);
         }
         SemaineJourSelect.SelectedIndex = selectedWeek - 1;
         this.monthSelect.SelectedIndex  = Month - 1;
         this.yearSelect.SelectedIndex   = Year - MinYear;
     }
 }
 private void Last(object sender, MouseEventArgs e)
 {
     this.selectionChangedEnabled = false;
     if (this.jourActive)
     {
         if (selectedDay == 1)
         {
             if (this.Month == 1)
             {
                 if (this.yearSelect.SelectedIndex != 0)
                 {
                     this.Year       -= 1;
                     this.Month       = 1;
                     this.selectedDay = 1;
                 }
             }
             else
             {
                 this.Month      -= 1;
                 this.selectedDay = 1;
             }
         }
         else
         {
             selectedDay -= 1;
         }
     }
     else
     {
         if (selectedWeek == 1)
         {
             if (Month == 1)
             {
                 if (Year != MinYear)
                 {
                     Year        -= 1;
                     Month        = 1;
                     selectedWeek = 1;
                 }
             }
             else
             {
                 Month       -= 1;
                 selectedWeek = AffichageParSemaineControl.DivideToWeeks(Month, Year).Values.Count;
             }
         }
         else
         {
             selectedWeek -= 1;
         }
     }
     this.selectionChangedEnabled = true;
     this.ReloadCBs();
     MainWindow.TachesEventsField.Update();
 }
        public void ChangeToSemaines()
        {
            updatingVisuals = true;
            jourActive      = false;
            ComboBox cb = this.SemaineJourSelect;

            cb.Items.Clear();
            int weeksCount = AffichageParSemaineControl.DivideToWeeks(Month, Year).Values.Count;

            for (int i = 1; i <= weeksCount; ++i)
            {
                ComboBoxItem cbi = new ComboBoxItem()
                {
                    Content     = $"Semaine {i}",
                    DataContext = i
                };
                cbi.Selected += new RoutedEventHandler(SelectWeek);
                cb.Items.Add(cbi);
            }
            cb.SelectedIndex = selectedWeek - 1;
            updatingVisuals  = false;
        }