Exemple #1
0
        /// <summary>
        /// Kopira termin sa rasporeda učionice na globalni raspored, uz dodavanje resusra.
        /// </summary>
        /// <param name="termin">termin koji se kopira</param>
        internal void CopyItem(MyTermin termin)
        {
            Console.WriteLine("Copy MyTermin sa id: " + termin.Id + " uz dodavanje resura " +
                              globalCalendar.Schedule.Resources[termin.InClassroom.Id].Name);

            termin.Resources.Add(GetResourceForClassroom(termin.InClassroom.Id));

            globalCalendar.Schedule.Items.Add(termin);
        }
        private void kalendar_ItemDeleted(object sender, ItemEventArgs e)
        {
            MyTermin deletedTermin        = (MyTermin)e.Item;
            Subject  deletedTerminSubject = deletedTermin.ForSubject;

            TerminHandler.Instance.RemoveTermin(deletedTermin);
            SubjectHandler.Instance.ChangeUnscheduledTermins(deletedTerminSubject.Id, false);

            (Window.GetWindow(this) as MainWindow).GlobalnaShema.globalCalendar.Schedule.Items.Remove(deletedTermin);

            UpdateSubjectRow(deletedTerminSubject);

            SubjectsList.UnselectAll();
        }
Exemple #3
0
        /// <summary>
        /// Ažuriranje termina ili brisanje ako je <code>deleted = true</code>.
        /// </summary>
        /// <param name="myTermin">termin koji ažuriramo</param>
        /// <param name="deleted">da li je obrisan u raporedu učionice</param>
        internal void UpdateTermin(MyTermin myTermin, bool deleted = false)
        {
            Console.WriteLine("Prije azuriranja ima {0} itema.", globalCalendar.Schedule.Items.Count);
            if (!deleted)
            {
                Console.WriteLine("Trazimo termin {0}", myTermin.Id);
                Console.WriteLine("stara lokacija je: {0} - {1}", myTermin.StartTime, myTermin.EndTime);
            }
            else
            {
                globalCalendar.Schedule.Items.Remove(myTermin);
            }

            Console.WriteLine("Posliej ima {0} itema.", globalCalendar.Schedule.Items.Count);
        }
        /// <summary>
        /// Pravljenje termina na Drag and DROP.
        /// </summary>
        /// <param name="e"></param>
        private void AddTerminFromDragAndDrop(DragEventArgs e)
        {
            Point    point = e.GetPosition(kalendar);
            DateTime?date  = kalendar.GetDateAt(point);

            Subject subject = (Subject)e.Data.GetData(typeof(Subject));

            // TODO: Srediti da se može dodati termin "tik uz drugi" - pogledaj kod ispod ove linije
            // trenutno preko štapa i kanapa [ ili nije? :) ]
            DateTime start = date.Value;
            DateTime end   = start.AddMinutes(subject.ClassLength * 45);

            var  allItems = kalendar.Schedule.GetAllItems(start, end.AddSeconds(-1));
            bool zauzeto  = allItems.Any();

            if (date != null)
            {
                if (zauzeto) // postoji 1 ili više termina
                {
                    if (Questions.BrisanjeTermina() == MessageBoxResult.Yes)
                    {
                        // čišćenje polja sa taskovima
                        allItems.ToList().ForEach(x => RemoveFromCalendar(x));
                        zauzeto = false; // fleg za dodavanje novog
                    }
                }
                if (!zauzeto) // ne može samo "else" zbog flag-a iznad
                {
                    MyTermin termin = new MyTermin(subject.Name, start, end, SelectedScheduleClassroom, subject);

                    /// Radi se ovo u <see cref="GlobalSchedule.CopyItem"/>
                    //termin.Resources.Add(MainWindowParent.GetResourceForClassroom(SelectedScheduleClassroom));

                    SubjectHandler.Instance.ChangeUnscheduledTermins(subject.Id);
                    TerminHandler.Instance.AddTermin(termin);

                    (Window.GetWindow(this) as MainWindow).GlobalnaShema.CopyItem(termin);
                    //(Application.Current.Windows[0] as MainWindow).GlobalnaShema.CopyItem(termin);

                    UpdateSubjectRow(subject);
                    Console.WriteLine("Dodat termin sa id: " + termin.Id);
                    kalendar.Schedule.Items.Add(termin);
                }
            }
        }
Exemple #5
0
        private void CreateAppointments()
        {
            Appointment app1 = new Appointment();

            app1.HeaderText      = "APP 1";
            app1.DescriptionText = "app1 desc";
            app1.StartTime       = ScheduleDays.workDays[0].AddHours(8); // isto vrijeme
            app1.EndTime         = ScheduleDays.workDays[0].AddHours(8).AddMinutes(45);
            //app1.Location = globalCalendar.Schedule.Locations[0]; // PRVA lokacija!
            app1.Resources.Add(globalCalendar.Schedule.Resources[0]);

            Appointment app2 = new Appointment();

            app2.HeaderText      = "APP 2";
            app2.DescriptionText = "app2 desc";
            app2.StartTime       = ScheduleDays.workDays[0].AddHours(8); // isto vrijeme
            app2.EndTime         = ScheduleDays.workDays[0].AddHours(8).AddMinutes(45);
            //app2.Location = globalCalendar.Schedule.Locations[1]; // DRUGA lokacija!
            app2.Resources.Add(globalCalendar.Schedule.Resources[1]);

            Appointment app3 = new Appointment();

            app3.HeaderText      = "APP 3";
            app3.DescriptionText = "app3 desc";
            app3.StartTime       = ScheduleDays.workDays[3].AddHours(9); // razl. vrijeme
            app3.EndTime         = ScheduleDays.workDays[3].AddHours(9).AddMinutes(45);
            //app3.Location = globalCalendar.Schedule.Locations[1]; // DRUGA lokacija!
            app3.Resources.Add(globalCalendar.Schedule.Resources[1]);

            globalCalendar.Schedule.Items.Add(app1);
            globalCalendar.Schedule.Items.Add(app2);
            globalCalendar.Schedule.Items.Add(app3);

            // Appointments creation END */

            DateTime start  = ScheduleDays.workDays[0].AddHours(9);
            DateTime end    = ScheduleDays.workDays[0].AddHours(9).AddMinutes(20);
            MyTermin termin = new MyTermin("app3", start, end);

            termin.Resources.Add(globalCalendar.Schedule.Resources[1]);
            globalCalendar.Schedule.Items.Add(termin);
        }