示例#1
0
 /**
  * Removes an event from the calendar.
  * If removing multiple events see {@link #removeEvents(List)}
  *
  * @param event event to remove from the calendar
  * @param shouldInvalidate true if the view should invalidate
  */
 public void removeEvent(CalendarDayEvent ev, bool shouldInvalidate)
 {
     compactCalendarController.removeEvent(ev);
     if (shouldInvalidate)
     {
         Invalidate();
     }
 }
        public void removeEvent(CalendarDayEvent ev)
        {
            eventsCalendar.TimeInMillis = ev.getTimeInMillis();
            string key = getKeyForCalendarEvent(eventsCalendar);
            List <CalendarDayEvent> uniqCalendarDayEvents = events[key];

            if (uniqCalendarDayEvents != null)
            {
                uniqCalendarDayEvents.Remove(ev);
            }
        }
        public void addEvent(CalendarDayEvent ev)
        {
            eventsCalendar.TimeInMillis = ev.getTimeInMillis();
            string key = getKeyForCalendarEvent(eventsCalendar);
            List <CalendarDayEvent> uniqCalendarDayEvents = events.ContainsKey(key) ? events[key] : null;

            if (uniqCalendarDayEvents == null)
            {
                uniqCalendarDayEvents = new List <CalendarDayEvent>();
            }

            if (!uniqCalendarDayEvents.Contains(ev))
            {
                uniqCalendarDayEvents.Add(ev);
            }

            events[key] = uniqCalendarDayEvents;
        }
示例#4
0
 /**
  * see {@link #removeEvent(com.github.sundeepk.compactcalendarview.domain.CalendarDayEvent, boolean)} when removing single events
  * or {@link #removeEvents(java.util.List)} (java.util.List)}  when removing multiple events
  * @param event
  */
 public void removeEvent(CalendarDayEvent ev)
 {
     removeEvent(ev, false);
 }
示例#5
0
 /**
  * see {@link #addEvent(com.github.sundeepk.compactcalendarview.domain.CalendarDayEvent, boolean)} when adding single events
  * or {@link #addEvents(java.util.List)}  when adding multiple events
  * @param event
  */
 public void addEvent(CalendarDayEvent ev)
 {
     addEvent(ev, false);
 }
        public void drawEvents(Canvas canvas, Calendar currentMonthToDrawCalender, int offset)
        {
            var key = getKeyForCalendarEvent(currentMonthToDrawCalender);
            List <CalendarDayEvent> eventsList = events.ContainsKey(key) ? events[key] : null;

            bool shouldDrawCurrentDayCircle = currentMonthToDrawCalender.Get(CalendarField.Month) == todayCalender.Get(CalendarField.Month);
            int  todayDayOfMonth            = todayCalender.Get(CalendarField.DayOfMonth);

            if (eventsList != null)
            {
                for (int i = 0; i < eventsList.Count; i++)
                {
                    CalendarDayEvent ev         = eventsList.ElementAt(i);
                    long             timeMillis = ev.getTimeInMillis();
                    eventsCalendar.TimeInMillis = timeMillis;
                    int dayOfWeek = getDayOfWeek(eventsCalendar) - 1;

                    int   weekNumberForMonth = eventsCalendar.Get(CalendarField.WeekOfMonth);
                    float xPosition          = widthPerDay * dayOfWeek + paddingWidth + paddingLeft + accumulatedScrollOffset.X + offset - paddingRight;
                    float yPosition          = weekNumberForMonth * heightPerDay + paddingHeight;

                    if (xPosition >= growFactor || yPosition >= growFactor)
                    {
                        continue;
                    }

                    int   dayOfMonth            = eventsCalendar.Get(CalendarField.DayOfMonth);
                    bool  isSameDayAsCurrentDay = (todayDayOfMonth == dayOfMonth && shouldDrawCurrentDayCircle);
                    float eventSeperation       = screenDensity * 3.5f;
                    float yIndicatorOffset      = 12 * screenDensity;
                    int   plusColor             = Color.Argb(255, 100, 68, 65);

                    if (eventsList.Count >= 3)
                    {
                        for (int j = 0, k = -2; j < 3; j++, k += 2)
                        {
                            var evt = eventsList.ElementAt(j);
                            if (!isSameDayAsCurrentDay)
                            {
                                if (j == 2)
                                {
                                    dayPaint.Color = new Color(plusColor);
                                    float originalWidth = dayPaint.StrokeWidth;
                                    dayPaint.StrokeWidth = 4;
                                    canvas.DrawLine(xPosition + (eventSeperation * k), yPosition + yIndicatorOffset, xPosition + (eventSeperation * k) + smallIndicatorRadius, yPosition + yIndicatorOffset, dayPaint);
                                    canvas.DrawLine(xPosition + (eventSeperation * k), yPosition + yIndicatorOffset, xPosition + (eventSeperation * k) - smallIndicatorRadius, yPosition + yIndicatorOffset, dayPaint);
                                    canvas.DrawLine(xPosition + (eventSeperation * k), yPosition + yIndicatorOffset, xPosition + (eventSeperation * k), yPosition + yIndicatorOffset + smallIndicatorRadius, dayPaint);
                                    canvas.DrawLine(xPosition + (eventSeperation * k), yPosition + yIndicatorOffset, xPosition + (eventSeperation * k), yPosition + yIndicatorOffset - smallIndicatorRadius, dayPaint);
                                    dayPaint.StrokeWidth = 0;
                                }
                                else if (_showSmallIndicator)
                                {
                                    //draw small indicators below the day in the calendar
                                    drawSmallIndicatorCircle(canvas, xPosition + (eventSeperation * k), yPosition + yIndicatorOffset, evt.getColor());
                                }
                                else
                                {
                                    drawCircle(canvas, xPosition + (eventSeperation * k), yPosition, evt.getColor());
                                }
                            }
                        }
                    }
                    else if (eventsList.Count == 2)
                    {
                        for (int j = 0, k = -1; j < eventsList.Count; j++, k += 2)
                        {
                            var evt = eventsList.ElementAt(j);
                            if (!isSameDayAsCurrentDay)
                            {
                                if (_showSmallIndicator)
                                {
                                    //draw small indicators below the day in the calendar
                                    drawSmallIndicatorCircle(canvas, xPosition + (eventSeperation * k), yPosition + yIndicatorOffset, evt.getColor());
                                }
                                else
                                {
                                    drawCircle(canvas, xPosition + (eventSeperation * k), yPosition, evt.getColor());
                                }
                            }
                        }
                    }
                    else if (eventsList.Count == 1)
                    {
                        var evt = eventsList.ElementAt(0);
                        if (!isSameDayAsCurrentDay)
                        {
                            if (_showSmallIndicator)
                            {
                                //draw small indicators below the day in the calendar
                                drawSmallIndicatorCircle(canvas, xPosition, yPosition + yIndicatorOffset, evt.getColor());
                            }
                            else
                            {
                                drawCircle(canvas, xPosition, yPosition, evt.getColor());
                            }
                        }
                    }
                }
            }
        }