예제 #1
0
        public static string Convert12(PocalAppointment appt)
        {
            var ampM   = appt.StartTime.ToString("tt", CultureSettings.CiEn);
            var result = string.Format("{0:h:mm}", appt.StartTime);

            return(result + " " + ampM);
        }
예제 #2
0
        private void CalcClusterIDs(PocalAppointment currentPocalAppointment)
        {
            for (var indexInDictionary = _entriesInDictionary - 1; indexInDictionary >= 0; indexInDictionary--)
            {
                var pocalAppointment = _day.PocalApptsOfDay[indexInDictionary];

                // Beim letzten Eintrag angekommen
                if (indexInDictionary == 0)
                {
                    if (Isconfliciting(currentPocalAppointment, pocalAppointment))
                    {
                        AddToClusterAccordingToOtherEntry(currentPocalAppointment, pocalAppointment, 0);
                        break;
                    }
                    var lastApptInDictionary = _day.PocalApptsOfDay[_entriesInDictionary - 1];
                    AddToClusterAccordingToOtherEntry(currentPocalAppointment, lastApptInDictionary, +1);
                    break;
                }

                if (!Isconfliciting(currentPocalAppointment, pocalAppointment))
                {
                    continue;
                }

                AddToClusterAccordingToOtherEntry(currentPocalAppointment, pocalAppointment, 0);
                break;
            }
        }
예제 #3
0
 private static bool ArePocaAppointmentsEqual(PocalAppointment a, PocalAppointment b)
 {
     if (a.AllDay != b.AllDay)
     {
         return(false);
     }
     if (a.Subject != b.Subject)
     {
         return(false);
     }
     if (a.Location != b.Location)
     {
         return(false);
     }
     if (a.StartTime != b.StartTime)
     {
         return(false);
     }
     if (a.Duration != b.Duration)
     {
         return(false);
     }
     if (a.Details != b.Details)
     {
         return(false);
     }
     if (!IsRecurrenceEqual(a, b))
     {
         return(false);
     }
     return(true);
 }
예제 #4
0
 private static void Add(PocalAppointment pA)
 {
     SetResponsibleDays(pA);
     foreach (var day in _responsibleDaysOfPa)
     {
         InsertInto_PocalApptsOfDay(day, pA);
     }
 }
예제 #5
0
        private static bool Isconfliciting(PocalAppointment currentAppt, PocalAppointment previousAppt)
        {
            var currentStart = currentAppt.StartTime.DateTime;
            var currentEnd   = currentStart + currentAppt.Duration;

            // Wenn zwei PAs sich überschneiden,
            return(currentAppt != previousAppt && previousAppt.isInTimeFrame_IgnoreAllDays(currentStart, currentEnd));
        }
예제 #6
0
        private void AddToClusterAccordingToOtherEntry(PocalAppointment currentAppt, PocalAppointment previousAppt,
                                                       int add)
        {
            int clusterOfPreviousAppt;

            _clusterId.TryGetValue(previousAppt, out clusterOfPreviousAppt);
            _clusterId.Add(currentAppt, clusterOfPreviousAppt + add);
        }
예제 #7
0
        private bool IsCurrentConflictingWithColumn(PocalAppointment currentAppt, int columnN)
        {
            var allInColumn = GetFromColumnDicitonaryAllWith(columnN);

            return
                (allInColumn.Where(entry => entry.Key != currentAppt)
                 .Any(entry => Isconfliciting(currentAppt, entry.Key)));
        }
예제 #8
0
 private static void SetResponsibleDays(PocalAppointment pA)
 {
     _responsibleDaysOfPa = new List <Day>();
     foreach (var day in App.ViewModel.Days.Where(day => pA.IsInTimeFrameOfDate(day.Dt)))
     {
         _responsibleDaysOfPa.Add(day);
     }
 }
예제 #9
0
        private static void UpdateIfSingle(PocalAppointment oldPa, PocalAppointment newPa)
        {
            if (oldPa != null && oldPa.Appt.Recurrence == null)
            {
                RemoveAllWith(oldPa.Appt.LocalId);
            }

            if (newPa != null && newPa.Appt.Recurrence == null)
            {
                Add(newPa);
            }
        }
예제 #10
0
        // ******** *************************** *********//
        // ******** Edits exisiting Appointment *********//
        // ******** *************************** *********//


        public static async void EditAppointment(PocalAppointment pA)
        {
            var appt = await CalendarAPI.Edit(pA.Appt);

            PocalAppointment newPa = null;

            if (appt != null)
            {
                newPa = await App.ViewModel.CreatePocalAppoinment(appt);
            }
            PocalAppointmentUpdater.Update(pA, newPa);
        }
예제 #11
0
        private static void InsertInto_PocalApptsOfDay(Day day, PocalAppointment pA)
        {
            var nextDay = day.PocalApptsOfDay.FirstOrDefault(x => x.Appt.StartTime > pA.Appt.StartTime);

            if (nextDay != null)
            {
                var index = day.PocalApptsOfDay.IndexOf(nextDay);
                day.PocalApptsOfDay.Insert(index, pA);
            }
            else
            {
                day.PocalApptsOfDay.Insert(day.PocalApptsOfDay.Count(), pA);
            }
        }
        public void SDV_AppointmentTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            PocalAppointment pocalAppointment = ((FrameworkElement)sender).DataContext as PocalAppointment;


            Storyboard storyboard = ((FrameworkElement)sender).Resources["tapFeedback"] as Storyboard;

            if (storyboard != null)
            {
                storyboard.Begin();
            }

            Dispatcher.BeginInvoke(() =>
            {
                PocalAppointmentHelper.EditAppointment(pocalAppointment);
            });
        }
예제 #13
0
        public static async void Update(PocalAppointment oldPa, PocalAppointment newPa)
        {
            // soll Aufflackern des Termins verhindern, wenn keine Änderungen gemacht wurden.
            if (oldPa != null && newPa != null)
            {
                if (ArePocaAppointmentsEqual(oldPa, newPa))
                {
                    return;
                }
            }

            UpdateIfSingle(oldPa, newPa);
            await UpdateIfRecurrent(oldPa, newPa);

            App.ViewModel.ConflictManager.SolveConflicts();

            ViewSwitcher.Mainpage.SingleDayViewer.Update_PocalAppointment(oldPa, newPa);
        }
예제 #14
0
        public void SDV_AppointmentTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //UpdateLayout(); // Vielleicht verlangsamt das die UX! Vielleicht behebt das jedoch den TapOffset Bug.
            PocalAppointment pocalAppointment = ((FrameworkElement)sender).DataContext as PocalAppointment;


            Storyboard storyboard = ((FrameworkElement)sender).Resources["tapFeedback"] as Storyboard;

            if (storyboard != null)
            {
                storyboard.Begin();
            }

            Dispatcher.BeginInvoke(() =>
            {
                PocalAppointmentHelper.EditAppointment(pocalAppointment);
            });
        }
예제 #15
0
 private void CalcColumns(PocalAppointment currentAppt)
 {
     for (var columnN = 1; columnN < 5; columnN++)
     {
         if (IsCurrentConflictingWithColumn(currentAppt, columnN))
         {
             if (columnN == 4)
             {
                 InsertColumn(currentAppt, 4);
             }
         }
         else
         {
             InsertColumn(currentAppt, columnN);
             break;
         }
     }
 }
예제 #16
0
        private static async Task UpdateIfRecurrent(PocalAppointment oldPa, PocalAppointment newPa)
        {
            if (oldPa != null && oldPa.Appt.Recurrence != null)
            {
                // Todo fixme
                RemoveRecurrent(oldPa.Appt);

                // für den fall, dass Nur ein Termin entfernt wurde, müssen alle anderen alten Recurrenztermine wieder neu geaddet werden
                if (newPa == null)
                {
                    await AddRecurrent(oldPa.Appt);
                }
            }

            if (newPa != null && newPa.Appt.Recurrence != null)
            {
                await AddRecurrent(newPa.Appt);
            }
        }
예제 #17
0
        public void Update_PocalAppointment(PocalAppointment oldPA, PocalAppointment newPA)
        {
            for (int i = GridAppointments.Children.Count - 1; i >= 0; i--)
            {
                FrameworkElement item = GridAppointments.Children[i] as FrameworkElement;
                if (item.DataContext == oldPA)
                {
                    GridAppointments.Children.Remove(item);
                }
            }

            if (newPA != null && newPA.AllDay == false && newPA.StartTime.Date == App.ViewModel.SingleDayViewModel.TappedDay.Dt.Date)
            {
                //fixme
                newPA = App.ViewModel.SingleDayViewModel.TappedDay.PocalApptsOfDay.FirstOrDefault(x => x.Appt.LocalId == newPA.Appt.LocalId);
                SDV_Appointment_Control control = new SDV_Appointment_Control();
                control.DataContext = newPA;
                GridAppointments.Children.Add(control);
            }
        }
예제 #18
0
        private static bool IsRecurrenceEqual(PocalAppointment a, PocalAppointment b)
        {
            if (a.Appt.Recurrence == null && b.Appt.Recurrence == null)
            {
                return(true);
            }

            // Bei Änderung von Recurrence zu nicht Recurrenz, oder anders herum.
            if (a.Appt.Recurrence == null || b.Appt.Recurrence == null)
            {
                return(false);
            }

            if (a.Appt.Recurrence.Day != b.Appt.Recurrence.Day)
            {
                return(false);
            }
            if (a.Appt.Recurrence.DaysOfWeek != b.Appt.Recurrence.DaysOfWeek)
            {
                return(false);
            }
            if (a.Appt.Recurrence.Interval != b.Appt.Recurrence.Interval)
            {
                return(false);
            }
            if (a.Appt.Recurrence.Month != b.Appt.Recurrence.Month)
            {
                return(false);
            }
            if (a.Appt.Recurrence.RecurrenceType != b.Appt.Recurrence.RecurrenceType)
            {
                return(false);
            }

            return(true);
        }
예제 #19
0
 private void InsertColumn(PocalAppointment currentAppt, int columnN)
 {
     _column.Add(currentAppt, columnN);
 }
예제 #20
0
 public static void SetScrollToPa(PocalAppointment pa)
 {
     _scrollToPa = pa;
 }
예제 #21
0
 private void InsertClusterId(PocalAppointment currentAppt, int id)
 {
     _clusterId.Add(currentAppt, id);
 }
예제 #22
0
 public static string Convert24(PocalAppointment appt)
 {
     return(string.Format("{0:HH:mm}", appt.StartTime));
 }