コード例 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            //Calendar view.
            View Calendar = inflater.Inflate(Resource.Layout.tab_cigarette_Calendar, null);

            base.OnCreateView(inflater, container, savedInstanceState);

            UserCalendar = Calendar.FindViewById <CalendarPickerView>(Resource.Id.Calendar);

            //Elements from the layout.
            TimeSpan ChangeMinus = TimeSpan.FromDays(365);
            TimeSpan ChangePlus  = TimeSpan.FromDays(365);
            DateTime Beginning   = DateTime.Now - ChangeMinus;
            DateTime Ending      = DateTime.Now + ChangePlus;

            //List with dates to be marked.
            DatesUsingALcohol = new List <DateTime>();

            //Adding dates to the list.
            foreach (Cigarette TempCigarette in DatabaseUser.GetUser(User.CurrentUser).Cigarettes)
            {
                if (TempCigarette.Date >= Beginning)
                {
                    DatesUsingALcohol.Add(TempCigarette.Date);
                }
            }

            //Selecting dates.
            UserCalendar.Init(Beginning, Ending).WithSelectedDates(DateTime.Now).WithHighlightedDates(DatesUsingALcohol);

            return(Calendar);
        }
コード例 #2
0
        /// <summary>
        ///     Called when [element changed].
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <CalendarView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                _view = e.NewElement;
                var inflatorservice = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
                _containerView = inflatorservice.Inflate(Resource.Layout.calendar_picker, null);
                _picker        = _containerView.FindViewById <CalendarPickerView>(Resource.Id.calendar_view);
                _picker.Init(Element.MinDate, Element.MaxDate, Element.HighlightedDaysOfWeek);
                _picker.OnDateSelected +=
                    (object sender, DateSelectedEventArgs evt) =>
                {
                    ProtectFromEventCycle(() => { Element.NotifyDateSelected(evt.SelectedDate); });
                };
                _picker.OnMonthChanged += (object sender, MonthChangedEventArgs mch) =>
                {
                    SetNavigationArrows();
                    ProtectFromEventCycle(() => { Element.NotifyDisplayedMonthChanged(mch.DisplayedMonth); });
                };
                SetDisplayedMonth(Element.DisplayedMonth);
                SetNavigationArrows();
                SetColors();
                SetFonts();

                _picker.SelectDates(e.NewElement.SelectedDates);

                SetNativeControl((RelativeLayout)_containerView);
            }
        }
コード例 #3
0
        private CalendarPickerView.FluentInitializer SetupCalendar(CalendarPickerView calendar, int diffMonths)
        {
            _currentDate = new DateTime(_currentDate.Year, _currentDate.Month, 1).AddMonths(diffMonths);

            var isCurrentMonth = _currentDate.Year == DateTime.Now.Year && _currentDate.Month == DateTime.Now.Month;

            if (isCurrentMonth)
            {
                _currentDate = DateTime.Now;
            }

            var lastDay = new DateTime(_currentDate.Year, _currentDate.Month, 1).AddMonths(1);

            return(calendar.Init(_currentDate, lastDay));
        }
コード例 #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <Controls.CalendarView> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement == null)
            {
                var inflatorService = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
                _view       = (LinearLayout)inflatorService.Inflate(Resource.Layout.CalendarView, null, false);
                _pickerView = _view.FindViewById <CalendarPickerView>(Resource.Id.calendar_view);
                _pickerView.Init(DateTime.Now.AddYears(-4), DateTime.Now.AddYears(4))
                .WithSelectedDate(DateTime.Today)
                .InMode(CalendarPickerView.SelectionMode.Single);
                _pickerView.DateSelected += (sender, args) =>
                {
                    Element.SelectedDate = args.Date;
                    Element.NotifyDateSelected(args.Date);
                };

                _pickerView.HighlightDates(Element.HighlightedDays);
                SetNativeControl(_view);
            }
        }
コード例 #5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            this.EnsureBindingContextIsSet(savedInstanceState);
            var view = this.BindingInflate(Resource.Layout.ItemViewPagerCalendar, container, false);

            AddSpotCalendarViewModelVM = ViewModel as AddSpotCalendarViewModel;

            calendar = view.FindViewById <CalendarPickerView>(Resource.Id.calendaritem);

            if (AddSpotCalendarViewModelVM.Events != null && AddSpotCalendarViewModelVM.Events.Count != 0)
            {
                ListDateEvent.Clear();
                for (int i = 0; i < AddSpotCalendarViewModelVM.Events.Count; i++)
                {
                    if (AddSpotCalendarViewModelVM.Events[i].StartDate.Month == DateTime.UtcNow.AddMonths(month).Month&&
                        AddSpotCalendarViewModelVM.Events[i].StartDate.Year == DateTime.UtcNow.AddMonths(month).Year)
                    {
                        if (ListDateEvent.Count != 0)
                        {
                            var IsExits = false;
                            for (int j = 0; j < ListDateEvent.Count; j++)
                            {
                                if (ListDateEvent[j].Day == AddSpotCalendarViewModelVM.Events[i].StartDate.Day)
                                {
                                    IsExits = true;
                                }
                            }
                            if (!IsExits)
                            {
                                ListDateEvent.Add(AddSpotCalendarViewModelVM.Events[i].StartDate);
                            }
                        }
                        else
                        {
                            ListDateEvent.Add(AddSpotCalendarViewModelVM.Events[i].StartDate);
                        }
                    }
                }
            }
            else
            {
                if (ListDateEvent.Count != 0)
                {
                    ListDateEvent.Clear();
                }
            }

            int NumberLanguage = 0;
            var LanguageText   = AddSpotCalendarViewModelVM.SharedTextSource.GetText("YesText");

            switch (LanguageText)
            {
            case "Oui":
                NumberLanguage = 1; break;

            default:
                NumberLanguage = 0; break;
            }

            calendar.Language = NumberLanguage;

            //for (int j = 1; j <= DateTime.DaysInMonth(2015, 11); j++)
            //    {
            //        ListDateEvent.Add(new DateTime(2015, 11, j));
            //    }

            if (AddSpotCalendarViewModelVM.DateSelected != null)
            {
                calendar.Init(DateTime.UtcNow.AddMonths(month).AddDays(-(DateTime.UtcNow.Day - 1)), DateTime.UtcNow.AddMonths(month + 1).AddDays(-(DateTime.UtcNow.Day + 1)))
                .InMode(CalendarPickerView.SelectionMode.Single)
                .WithSelectedDate(AddSpotCalendarViewModelVM.DateSelected)
                .WithHighlightedDates(ListDateEvent);

                if (ListDateEvent.Count != 0)
                {
                    foreach (var dateTime in ListDateEvent)
                    {
                        Console.WriteLine(dateTime.ToString() + "\n");
                    }
                }
            }
            else
            {
                calendar.Init(DateTime.UtcNow.AddMonths(month).AddDays(-(DateTime.UtcNow.Day - 1)), DateTime.UtcNow.AddMonths(month + 1).AddDays(-(DateTime.UtcNow.Day + 1)))
                .InMode(CalendarPickerView.SelectionMode.Single)
                .WithHighlightedDates(ListDateEvent);
            }



            calendar.OnDateSelected +=
                (s, e) =>
            {
                UpdateEventFilterByDay(e.SelectedDate);
            };

            UpdateEventFilterByDay(AddSpotCalendarViewModelVM.SelectedDate);

            return(view);
        }
コード例 #6
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.MeusAgendamentosCalendario);

            string id = Intent.GetStringExtra("id") ?? "Data not available";

            Console.WriteLine("IDDDD = " + id);

            btnVoltar           = FindViewById <Button>(Resource.Id.btn_voltar);
            calendarPickerView1 = FindViewById <CalendarPickerView>(Resource.Id.calendarPickerView1);

            var nextYear = DateTime.Now.AddYears(1);

            calendarPickerView1
            .Init(DateTime.Now, nextYear)
            .InMode(CalendarPickerView.SelectionMode.Single)
            .WithSelectedDate(DateTime.Now);

            calendarPickerView1.DateSelected += delegate
            {
                DateTime selectedDate = calendarPickerView1.SelectedDate;
                Console.WriteLine("clicked on " + selectedDate.ToString());

                MySqlConnection con = new MySqlConnection("Server=mysql873.umbler.com;Port=41890;database=ufscarpds;User Id=ufscarpds;Password=ufscar1993;charset=utf8");

                try
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                        Console.WriteLine("Conectado com sucesso2!");

                        MySqlCommand cmd = new MySqlCommand("select id from agendamento where id_usuario = @id_usuario and data = @data", con);
                        cmd.Parameters.AddWithValue("@id_usuario", id);
                        cmd.Parameters.AddWithValue("@data", selectedDate);

                        using (MySqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                // abrir MeusAgendamentos com filtro de data para selectedDate
                                var intent = new Intent(this, typeof(MeusAgendamentos));
                                intent.PutExtra("id", id);
                                intent.PutExtra("data", selectedDate.ToString());
                                Console.WriteLine("MenuUsuario ID = " + id);
                                StartActivity(intent);
                            }
                        }
                    }
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    con.Close();
                }
            };

            retrieveAndHighlight(id, calendarPickerView1);


            btnVoltar.Click += (sender, e) =>
            {
                Finish();
            };
        }
コード例 #7
0
        // ListView resultAgenda;
        // AgendamentoAdapter adapter;
        // List<Agendamento> agendamentos = new List<Agendamento>();
        // JavaList<string> agendamentosDisplay = new JavaList<string>();

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AgendamentoAdministradorCalendario);

            calendarPickerView1 = FindViewById <CalendarPickerView>(Resource.Id.calendarPickerView1);
            // resultAgenda = FindViewById<ListView>(Resource.Id.resultAgenda);
            // adapter = new AgendamentoAdapter(this, agendamentos);
            btnVoltar = FindViewById <Button>(Resource.Id.btn_voltar);


            btnVoltar.Click += (sender, e) =>
            {
                Finish();
            };

            var nextYear = DateTime.Now.AddYears(1);

            calendarPickerView1
            .Init(DateTime.Now, nextYear)
            .InMode(CalendarPickerView.SelectionMode.Single)
            .WithSelectedDate(DateTime.Now);

            calendarPickerView1.DateSelected += delegate
            {
                DateTime selectedDate = calendarPickerView1.SelectedDate;

                MySqlConnection con = new MySqlConnection("Server=mysql873.umbler.com;Port=41890;database=ufscarpds;User Id=ufscarpds;Password=ufscar1993;charset=utf8");

                try
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                        Console.WriteLine("Conectado com sucesso2!");

                        MySqlCommand cmd = new MySqlCommand("select id from agendamento where data = @data AND confirmado=1", con);
                        cmd.Parameters.AddWithValue("@data", selectedDate);

                        using (MySqlDataReader reader = cmd.ExecuteReader())
                        {
                            if (reader.Read())
                            {
                                // abrir AgendamentoAdmin com filtro de data para selectedDate
                                var intent = new Intent(this, typeof(AgendamentoAdministrador));
                                intent.PutExtra("data", selectedDate.ToString());
                                StartActivity(intent);
                            }
                        }
                    }
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    con.Close();
                }
            };

            // DateTime today = DateTime.Now.Date;
            // Console.WriteLine("DATE = " + today.Year + "-" + today.Month + "-" + today.Day);

            retrieveAndHighlight(calendarPickerView1);
        }