Ejemplo n.º 1
0
        // *************************************************************************************
        #region Calendar methods
        private void FillCalendar()
        {
            CalendrierCtrl.ClearCalendar();

            foreach (Creneau creneau in CalendarManager.Instance.ListCreneauChoosed)
            {
                if (DataManager.Instance.ActiviteChoosed != null &&
                    (creneau.Activite.Equal(DataManager.Instance.ActiviteChoosed) ||
                     creneau.Activite.Id.Equals(DataManager.Instance.ActiviteChoosed.Id_LinkedActivity)))
                {
                    CalendarCtrlClasse classe = CreateCalendarClasseCtrlByCreneau(creneau);

                    CalendrierCtrl.AddCtrlClass(classe);
                }

                if (DataManager.Instance.ClasseChoosed != null && creneau.Classe != null &&
                    creneau.Classe.Equal(DataManager.Instance.ClasseChoosed))
                {
                    CalendarCtrlClasse classe = CreateCalendarClasseCtrlByCreneau(creneau);

                    CalendrierCtrl.AddCtrlClass(classe);
                }

                if (DataManager.Instance.ClasseChoosed != null && creneau.ListClass_Custom != null &&
                    creneau.ListClass_Custom.Where(x => x.Id == DataManager.Instance.ClasseChoosed.Id).Count() > 0)
                {
                    CalendarCtrlClasse classe = CreateCalendarClasseCtrlByCreneau(creneau);

                    CalendrierCtrl.AddCtrlClass(classe);
                }
            }
        }
Ejemplo n.º 2
0
        private void ClasseCtrl_CreneauChoosed(object sender, Creneau e)
        {
            CalendarCtrlClasse classe = CreateCalendarClasseCtrlByCreneau(e);

            bool IsAdded = CalendarManager.Instance.AddCreneau(e, out int countConflictCreneau, out List <Creneau> conflitCreneaux);

            if (IsAdded)
            {
                CalendrierCtrl.AddCtrlClass(classe);
            }
            else if (!IsAdded && countConflictCreneau < MAXIMUM_CONFLIT_STACK)
            {
                string message = "Ce créneau est déjà pris !";
                foreach (Creneau c in conflitCreneaux)
                {
                    message += " \n\n" +
                               (c.Classe != null ? c.Classe.Libelle : "") + " | " + c.Activite.Libelle + "\n" +
                               c.StartHour.ToString("hh\\:mm") + " à " + c.EndHour.ToString("hh\\:mm");
                }
                message += "\n\n Voulez-vous le partagez ?";

                if (MessageBox.Show(message, "Attention", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                {
                    //No
                }
                else //Yes
                {
                    //On ajoute le creneau
                    CalendarManager.Instance.ListCreneauChoosed.Add(e);

                    //On sépare les creneaux
                    int nbConflit = 0;
                    for (int index = 0; index < conflitCreneaux.Count; index++)
                    {
                        conflitCreneaux[index].Column           = (Enums.ColumnSpanType)index;
                        conflitCreneaux[index].ConflitCreneauId = e.ID;
                        nbConflit++;
                    }

                    e.ConflitCreneauId = conflitCreneaux.First().ID;
                    e.Column           = (Enums.ColumnSpanType)nbConflit;

                    FillCalendar();
                }
            }
            else
            {
                string message2 = "Ce créneau est déjà pris !";
                foreach (Creneau c in conflitCreneaux)
                {
                    message2 += " \n\n" +
                                (c.Classe != null ? c.Classe.Libelle : "") + " | " + c.Activite.Libelle + "\n" +
                                c.StartHour.ToString("hh\\:mm") + " à " + c.EndHour.ToString("hh\\:mm");
                }
                MessageBox.Show(message2);
            }
        }