Ejemplo n.º 1
0
        private void AddTask(object sender, MouseButtonEventArgs e)
        {
            if (TextBoxTitle.Text == "")
            {
                TextBoxTitle.Focus();
            }
            else if (PickerDate.SelectedDate == null || PickerHeureDebut.SelectedTime == null || PickerHeureFin.SelectedTime == null)
            {
                MessageBox.Show("Veuillez choisir la date exacte");
            }
            else if ((ComboBoxPriorité.SelectedIndex != 0) && (ComboBoxPriorité.SelectedIndex != 1) && (ComboBoxPriorité.SelectedIndex != 2))
            {
                MessageBox.Show("Veuillez choisir la priorité");
            }
            else if (((string)((ComboBoxItem)ComboBoxActivities.SelectedItem).DataContext) == "Activité scolaire" && DataSupervisor.ds.user.JoursFeries.Keys.Contains(PickerDate.SelectedDate.Value))
            {
                MessageBox.Show("Le jour choisit est ferie");
            }
            else
            {
                Tache    t           = new Tache();
                DateTime?selectedDay = PickerDate.SelectedDate;
                DateTime dateDebut   = new DateTime(selectedDay.Value.Year, selectedDay.Value.Month, selectedDay.Value.Day, PickerHeureDebut.SelectedTime.Value.Hour, PickerHeureDebut.SelectedTime.Value.Minute, PickerHeureDebut.SelectedTime.Value.Second);
                DateTime dateFin     = new DateTime(selectedDay.Value.Year, selectedDay.Value.Month, selectedDay.Value.Day, PickerHeureFin.SelectedTime.Value.Hour, PickerHeureFin.SelectedTime.Value.Minute, PickerHeureFin.SelectedTime.Value.Second);
                t.dateDebut = dateDebut;
                t.dateFin   = dateFin;
                foreach (String s in this.files)
                {
                    t.Fichiers.Add(s);
                }
                t.title   = TextBoxTitle.Text;
                t.Details = TextBoxDescription.Text;
                switch (ComboBoxPriorité.SelectedIndex)
                {
                case 0:
                    t.priorite = "Urgente";
                    break;

                case 1:
                    t.priorite = "Normale";
                    break;

                case 2:
                    t.priorite = "Basse";
                    break;

                default:
                    return;
                }
                t.Activitee = (string)((ComboBoxItem)ComboBoxActivities.SelectedItem).DataContext;
                t.Alarms    = new List <Notif>();
                foreach (KeyValuePair <Chip, Notif> n in NotificationDict)
                {
                    t.Alarms.Add(n.Value);
                }

                DataSupervisor.ds.AddTache(t);
                windowParent.Close();
            }
        }
Ejemplo n.º 2
0
        public void FillWithTache(Tache t)
        {
            this.t                        = t;
            TextBoxTitle.Text             = t.title;
            TextBoxDescription.Text       = t.Details;
            PickerDate.SelectedDate       = t.dateDebut;
            PickerHeureDebut.SelectedTime = t.dateDebut;
            PickerHeureFin.SelectedTime   = t.dateFin;
            int index = -1;

            foreach (ComboBoxItem cbi in ComboBoxActivities.Items)
            {
                if ((string)cbi.DataContext == t.Activitee)
                {
                    index = ComboBoxActivities.Items.IndexOf(cbi);
                    break;
                }
            }
            ComboBoxActivities.SelectedIndex = index;
            ComboBoxPriorité.SelectedIndex   = t.priorite == "Urgente" ? 0 : t.priorite == "Normale" ? 1 : 2;
            foreach (Notif n in t.Alarms)
            {
                DateTime d = n.time;
                Chip     c = CreateAlarmChip($"{d.Year}-{d.Month}-{d.Date}-{d.Hour}:{d.Minute}");
                NotificationDict[c] = n;
                alarmeChipsField.Children.Add(c);
            }
        }
Ejemplo n.º 3
0
        public CarteTache(Tache t)
        {
            InitializeComponent();
            Regex r = new Regex(@"[^/\\]+$");

            this.TacheTitle.Text   = t.title;
            this.TacheDetails.Text = t.Details;
            string time1 = t.dateDebut.Hour >= 12 ? "AM" : "PM";
            string time2 = t.dateFin.Hour >= 12 ? "AM" : "PM";

            this.tacheDuration.Text = $@"{t.dateDebut.Hour}:{t.dateDebut.Minute} {time1}_{t.dateFin.Hour}:{t.dateFin.Minute} {time2}";
            Dictionary <string, string> colorDict = new Dictionary <string, string>();

            colorDict["Urgente"]   = "#DDFF0707";
            colorDict["Normale"]   = "#FFEB3B";
            colorDict["Basse"]     = "#DD64CEFF";
            priorityTitle.Text     = t.priorite;
            priorityIndicator.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(colorDict[t.priorite]));
            this.t = t;
            try
            {
                documentTitle.Text = r.Match(t.Fichiers[0]).Value;
                alarmText.Text     = t.Alarms[0].time.ToString();
            }
            catch (Exception e) { }
            task_activity_tag.Fill     = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataSupervisor.ds.user.Activities[t.Activitee]));
            TaskStateToggle.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(DataSupervisor.ds.user.Activities[t.Activitee]));
        }
Ejemplo n.º 4
0
        // The method that add tache to the specified day
        // TODO : make evenement add method
        public void AddDayTask(Tache task, DateTime date)
        {
            if (date > lastDay || date < firstDay)
            {
                throw new Exception("The day is not in the grid");
            }
            int[] arr = GetDayCoordinates(date);
            int   i = arr[0], j = arr[1];

            TasksStackPanel[i, j].Children.Add(CreateTaskWrapPanel(task.title, task.Activitee));
        }
Ejemplo n.º 5
0
        public static Tache ConvertFromSeanceToTache(Seance s, DateTime day)
        {
            Tache t = new Tache();

            t.title     = s.name;
            t.Details   = s.description;
            t.dateDebut = new DateTime(day.Year, day.Month, day.Day, s.begin.Hour, s.begin.Minute, s.begin.Second);
            t.dateFin   = new DateTime(day.Year, day.Month, day.Day, s.end.Hour, s.end.Minute, s.end.Second);
            t.priorite  = s.priority;
            t.Activitee = "Activité scolaire";
            return(t);
        }
Ejemplo n.º 6
0
 public void AddTache(DateTime d, Tache t)
 {
     if (this.Data.ContainsKey(d))
     {
         this.Data[d].Add(t);
     }
     else
     {
         this.Data.Add(d, new List <CalendarObj>());
         this.Data[d].Add(t);
     }
     this.StoreData();
 }
Ejemplo n.º 7
0
 public void SupprimerTache(Tache t)
 {
     if (t.dateDebut.Year == MonthData.Month.Year && t.dateDebut.Month == MonthData.Month.Month)
     {
         MonthData.Data[new DateTime(t.dateDebut.Year, t.dateDebut.Month, t.dateDebut.Day)].Remove(t);
         MonthData.StoreData();
     }
     else
     {
         CalendarInfo ci = new CalendarInfo(this.currentUserDataPath + $"\\MonthData{t.dateDebut.Month}-{t.dateDebut.Year}.json", new DateTime(t.dateDebut.Year, t.dateDebut.Month, 1));
         ci.Data[new DateTime(t.dateDebut.Year, t.dateDebut.Month, t.dateDebut.Day)].Remove(t);
         ci.StoreData();
     }
 }
Ejemplo n.º 8
0
 public void AddTache(Tache t)
 {
     if (this.user == null)
     {
         throw new Exception("User account is not loaded");
     }
     if (t.dateDebut.Month == this.MonthData.Month.Month && t.dateDebut.Year == this.MonthData.Month.Year)
     {
         this.MonthData.AddTache(new DateTime(t.dateDebut.Year, t.dateDebut.Month, t.dateDebut.Day), t);
         MainWindow.CalendarField.UpdateCalendar();
         MainWindow.TachesEventsField.Update();
     }
     else
     {
         CalendarInfo ci = new CalendarInfo(this.currentUserDataPath + $"\\MonthData{t.dateDebut.Month}-{t.dateDebut.Year}.json", new DateTime(t.dateDebut.Year, t.dateDebut.Month, 1));
         ci.AddTache(new DateTime(t.dateDebut.Year, t.dateDebut.Month, t.dateDebut.Day), t);
         ci.StoreData();
     }
     foreach (Notif n in t.Alarms)
     {
         OtherThread.sendData(ConvertToNotification(n, "tache", t.dateDebut, t.title));
     }
 }
Ejemplo n.º 9
0
        private void ButtonAddTask_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Tache    t           = new Tache();
            DateTime?selectedDay = PickerDate.SelectedDate;

            if (selectedDay == null || PickerHeureDebut.SelectedTime == null || PickerHeureFin.SelectedTime == null)
            {
                MessageBox.Show("Please select a day");
                return;
            }
            DateTime dateDebut = new DateTime(selectedDay.Value.Year, selectedDay.Value.Month, selectedDay.Value.Day, PickerHeureDebut.SelectedTime.Value.Hour, PickerHeureDebut.SelectedTime.Value.Minute, PickerHeureDebut.SelectedTime.Value.Second);
            DateTime dateFin   = new DateTime(selectedDay.Value.Year, selectedDay.Value.Month, selectedDay.Value.Day, PickerHeureFin.SelectedTime.Value.Hour, PickerHeureFin.SelectedTime.Value.Minute, PickerHeureFin.SelectedTime.Value.Second);

            t.dateDebut = dateDebut;
            t.dateFin   = dateFin;
            foreach (String s in this.files)
            {
                t.Fichiers.Add(s);
            }
            t.title       = TextBoxTitle.Text;
            t.designation = TextBoxDescription.Text;
            switch (ComboBoxPriorité.SelectedIndex)
            {
            case 0:
                t.priorite = "Urgent";
                break;

            case 1:
                t.priorite = "Normal";
                break;

            case 2:
                t.priorite = "Bas";
                break;

            default:
                MessageBox.Show("Veuillez choisir la degree d'urgence !");
                return;

                break;
            }
            t.Activitee = ComboBoxActivities.SelectedIndex != -1 ? (string)((ComboBoxItem)ComboBoxActivities.SelectedItem).DataContext : "Not specified";

            /*switch (ComboBoxEtatdutache.SelectedIndex)
             * {
             *  case 1:
             *      t.etat = "Non réalisé";
             *      break;
             *  case 2:
             *      t.etat = "En cours";
             *      break;
             *  case 3:
             *      t.etat = "Terminé";
             *      break;
             *  default:
             *      MessageBox.Show("Veuillez choisir la degree d'urgence !");
             *      return;
             *      break;
             * }*/
            // TODO : include Alarms in Tache
            DataSupervisor.ds.AddTache(t);
            windowParent.Close();
        }