public bool RemoveEvent(DateTime date, Func <CalendarEvent, bool> predicate) { ShortDateString sDate = new ShortDateString(date); if (!mEvents.ContainsKey(sDate)) { return(false); } else { List <CalendarEvent> list = mEvents[sDate]; if (list == null) { return(false); } else { CalendarEvent ev = list.First(predicate); if (ev != null) { return(list.Remove(ev)); } else { return(false); } } } }
private bool HasEvents(ShortDateString sDate) { if (mEvents.ContainsKey(sDate)) { return(mEvents[sDate] != null && mEvents[sDate].Count > 0); } else { return(false); } }
private List <CalendarEvent> FindEventsByDate(DateTime dateTime) { ShortDateString sDate = new ShortDateString(dateTime); if (mEvents.ContainsKey(sDate)) { return(mEvents[sDate]); } else { return(null); } }
public bool RemoveEvent(DateTime date, CalendarEvent _event) { ShortDateString sDate = new ShortDateString(date); if (!mEvents.ContainsKey(sDate)) { return(false); } else { List <CalendarEvent> list = mEvents[sDate]; if (list == null) { return(false); } else { return(list.Remove(_event)); } } }
public void AddNewEvent(DateTime date, CalendarEvent _event) { ShortDateString sDate = new ShortDateString(date); if (!mEvents.ContainsKey(sDate)) { mEvents.Add(sDate, new List <CalendarEvent>() { _event }); } else { List <CalendarEvent> list = mEvents[sDate]; if (list == null) { list = new List <CalendarEvent>(); } list.Add(_event); } }
private void InizializeCalendar(DateTime dateTime) { SetMonthYear(dateTime); int days = DateTime.DaysInMonth(dateTime.Year, dateTime.Month); DateTime firstOfMonth = BringToFirst(dateTime); DayOfWeek startingDay = firstOfMonth.DayOfWeek; ClearDays(); int riga = 2; int colonna = GetDayNumber(startingDay); for (int i = 0; i < days; i++) { Border bord = new Border(); bord.Name = "brd" + (i + 1).ToString(); bord.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; bord.Margin = new Thickness(0); Button ba = new Button(); ba.BorderBrush = new SolidColorBrush(Colors.Transparent); ba.Width = 99; ba.Height = 99; ba.Tag = (i + 1); ba.Margin = new Thickness(1); ba.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; ba.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center; ba.VerticalAlignment = System.Windows.VerticalAlignment.Center; ba.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; ba.Content = (i + 1).ToString(); ba.Click += new RoutedEventHandler(ba_Click); ba.Foreground = new SolidColorBrush(Colors.Black); //puasa Senin-Kamis if (colonna == 0 || colonna == 3) // giorno festivo { ba.Background = new SolidColorBrush(Color.FromArgb(255, 28, 106, 129)); ba.Foreground = new SolidColorBrush(Colors.White); } //controllo sull'evento esistente #region JENIS PUASA if (HasEvents(new ShortDateString(firstOfMonth.AddDays(i)))) { ShortDateString hehe = new ShortDateString(firstOfMonth.AddDays(i)); List <CalendarEvent> wow = mEvents[hehe]; CalendarEvent jenisEvent = wow.First(); if (jenisEvent.Description.Equals("TandaToday")) { ba.Margin = new Thickness(0); bord.BorderThickness = new Thickness(5); bord.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 16, 16, 16)); jenisEvent = wow.Last(); } if (jenisEvent.Description.Equals("Muharram")) { ba.Background = new SolidColorBrush(Color.FromArgb(255, 221, 85, 123)); ba.Foreground = new SolidColorBrush(Colors.White); } else if (jenisEvent.Description.Equals("Arafah")) { ba.Background = new SolidColorBrush(Color.FromArgb(255, 129, 98, 139)); ba.Foreground = new SolidColorBrush(Colors.White); } else if (jenisEvent.Description.Equals("Ayyamul")) { ba.Background = new SolidColorBrush(Color.FromArgb(255, 22, 168, 158)); ba.Foreground = new SolidColorBrush(Colors.White); } if (jenisEvent.Description.Equals("PuasaDaud")) { ba.Background = new SolidColorBrush(Color.FromArgb(255, 140, 157, 45)); ba.Foreground = new SolidColorBrush(Colors.White); } if (jenisEvent.Description.Equals("Haram")) { ba.Background = new SolidColorBrush(Color.FromArgb(255, 193, 17, 37)); ba.Foreground = new SolidColorBrush(Colors.White); } if (jenisEvent.Description.Equals("Ramadhan")) { ba.Background = new SolidColorBrush(Color.FromArgb(255, 176, 100, 25)); ba.Foreground = new SolidColorBrush(Colors.White); } #endregion } bord.Child = ba; AddElementToGrid(riga, colonna++, bord); //countDay++; if (colonna % 7 == 0) { riga++; colonna = 0; } } mCurrentDate = dateTime; LayoutRoot.UpdateLayout(); }
public bool RemoveDateEvents(DateTime date) { ShortDateString sDate = new ShortDateString(date); return(mEvents.Remove(sDate)); }