コード例 #1
0
        public override void RenderEvents(Canvas canvas, CalendarDayCell cell)
        {
            int startX = cell.Left + shapeSpacing;
            int startY = cell.Top + shapeSpacing;

            Rect drawTextRect = new Rect();

            if (cell.Text != null)
            {
                String text = cell.Text;
                cell.TextPaint.GetTextBounds(text, 0, text.Length, drawTextRect);
            }

            int x = startX;
            int y = startY;

            int spacingForDate = drawTextRect.Width();

            for (int i = 0; i < cell.Events.Count; i++)
            {
                Event e = cell.Events[i];
                paint.Color = new Color(e.EventColor);
                canvas.DrawCircle(x, y, shapeRadius, paint);
                x += shapeSpacing;
                if (x > cell.Right - spacingForDate - shapeSpacing)
                {
                    x  = startX;
                    y += shapeSpacing;
                }
            }
        }
コード例 #2
0
            public void Apply(Java.Lang.Object calendarCell)
            {
                if (calendarCell.Class.SimpleName == "CalendarMonthCell")
                {
                    return;
                }

                CalendarDayCell dayCell = calendarCell.JavaCast <CalendarDayCell> ();

                if (dayCell.CellType != CalendarCellType.Date)
                {
                    return;
                }

                this.calendar.TimeInMillis = dayCell.Date;

                if (calendar.Get(CalendarField.DayOfWeek) == Calendar.Saturday)
                {
                    dayCell.Selectable = false;
                }
                else
                {
                    dayCell.Selectable = true;
                }
            }
コード例 #3
0
        public void Apply(Java.Lang.Object p0)
        {
            if (!(p0 is CalendarDayCell))
            {
                return;
            }

            CalendarDayCell calendarCell = p0.JavaCast <CalendarDayCell>();

            if (calendarCell.CellType != CalendarCellType.Date)
            {
                return;
            }

            calendarCell.SetBackgroundColor(
                Android.Graphics.Color.ParseColor("#F8F8F8"),  // used when the cell is enabled
                Android.Graphics.Color.ParseColor("#E0E0E0")); // used when the cell is disabled

            calendarCell.SetTextColor(
                Android.Graphics.Color.ParseColor("#000000"),  // used when the cell is enabled
                Android.Graphics.Color.ParseColor("#FFFFFF")); // used when the cell is disabled

            calendar.TimeInMillis = calendarCell.Date;

            var weekDay = calendar.Get(Java.Util.CalendarField.DayOfWeek);

            if (weekDay == 1 || weekDay == 7)
            {
                calendarCell.SetBackgroundColor(
                    Android.Graphics.Color.ParseColor("#EEEEEE"),  // used when the cell is enabled
                    Android.Graphics.Color.ParseColor("#E0E0E0")); // used when the cell is disabled

                calendarCell.SetTextColor(
                    Android.Graphics.Color.ParseColor("#999999"),  // used when the cell is enabled
                    Android.Graphics.Color.ParseColor("#AAAAAA")); // used when the cell is disabled
            }

            var currentDate = Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Date);
            var currentMoth = Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Month);
            var currentYear = Java.Util.Calendar.Instance.Get(Java.Util.CalendarField.Year);

            var boldTypeface = Android.Graphics.Typeface.Create(
                calendarCell.TextPaint.Typeface, Android.Graphics.TypefaceStyle.Bold);

            if (calendar.Get(Java.Util.CalendarField.Date) == currentDate &&
                calendar.Get(Java.Util.CalendarField.Month) == currentMoth &&
                calendar.Get(Java.Util.CalendarField.Year) == currentYear)
            {
                calendarCell.BorderColor = Android.Graphics.Color.ParseColor("#00FF44");
                calendarCell.BorderWidth = global::Android.App.Application.Context.ToPixels(2);

                calendarCell.Typeface = boldTypeface;
            }

            if (calendarCell.Selected)
            {
                calendarCell.Typeface = boldTypeface;
            }
        }