Example #1
0
        private void initCalendar()
        {
            removeUselessData();
            List <EventDay> events = new List <EventDay>();

            foreach (KeyValuePair <string, List <HMEvent> > entry in mDict)
            {
                Calendar         calendar = Calendar.GetInstance(new Locale("en_AU"));
                SimpleDateFormat sdf      = new SimpleDateFormat("MM-dd-yyyy", new Locale("en_AU"));
                calendar.Time = sdf.Parse(entry.Key);
                EventDay eventDay = new EventDay(calendar, Resource.Mipmap.cleaning);
                events.Add(eventDay);
            }
            mCalendarView.SetEvents(events);
        }
Example #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            _databaseService = new DatabaseService();
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Home);

            // Adding Toolbar to Main screen
            Toolbar toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            toolbar.Title = "Kalendorius";
            SetSupportActionBar(toolbar);


            MV.CalendarView calendarView = (MV.CalendarView)FindViewById(Resource.Id.calendarView);

            List <MV.EventDay> events = new List <MV.EventDay>();

            foreach (var dayEvent in _databaseService.GetUserEvents())
            {
                Calendar calendar = Calendar.Instance;
                calendar.Set(dayEvent.Time.Year, dayEvent.Time.Month - 1, dayEvent.Time.Day);
                switch (dayEvent.Category)
                {
                case "Egzaminas":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.egzas));
                    break;

                case "Teorija":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.teorija));
                    break;

                case "Testas":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.laborai));
                    break;

                case "Praktika":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.laborai));
                    break;

                case "Laboratoriniai":
                    events.Add(new MV.EventDay(calendar, Resource.Drawable.laborai));
                    break;
                }
            }

            calendarView.SetEvents(events);
            calendarView.DayClick += CalendarView_DayClick;
        }
Example #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.calendar_activity);

            List <EventDay> events = new List <EventDay>();

            Calendar calendarToday = Calendar.Instance;

            events.Add(new EventDay(calendarToday, Resource.Drawable.sample_icon_1));

            Calendar calendarTwoDaysFromToday = Calendar.Instance;

            calendarTwoDaysFromToday.Add(CalendarField.DayOfMonth, 2);
            events.Add(new EventDay(calendarTwoDaysFromToday, Resource.Drawable.sample_icon_2));

            calendarToday.ToDateTime();
            Calendar calendarFiveDaysFromToday = Calendar.Instance;

            calendarFiveDaysFromToday.Add(CalendarField.DayOfMonth, 5);
            events.Add(new EventDay(calendarFiveDaysFromToday, Resource.Drawable.sample_icon_3));

            MCV.CalendarView calendarView = (MCV.CalendarView)FindViewById(Resource.Id.calendarView);

            calendarView.PreviousButtonClick += (sender, e) =>
                                                Toast.MakeText(this, "LEFT", ToastLength.Short).Show();

            calendarView.ForwardButtonClick += (sender, e) =>
                                               Toast.MakeText(this, "RIGHT", ToastLength.Short).Show();

            Calendar min = Calendar.Instance;

            min.Add(CalendarField.Month, -2);

            Calendar max = Calendar.Instance;

            max.Add(CalendarField.Month, 2);

            calendarView.SetMinimumDate(min);
            calendarView.SetMaximumDate(max);

            calendarView.SetEvents(events);

            calendarView.DayClick += (sender, e) =>
            {
                Toast.MakeText(this, e.P0.Calendar.Time.ToString(),
                               ToastLength.Short).Show();
            };

            Button setDateButton = (Button)FindViewById(Resource.Id.setDateButton);

            setDateButton.Click += (sender, e) =>
            {
                try
                {
                    calendarView.SetDate(GetRandomCalendar());
                }
                catch (OutOfDateRangeException exception)
                {
                    exception.PrintStackTrace();
                    Toast.MakeText(this, "Date is out of range", ToastLength.Short).Show();
                }
            };
        }