private void SetContentView()
        {
            var calendar = new CalendarMonthView(MonthViewDate, MonthViewCurrentGregorianDate, true);

            HandleDateSelectedEvent(calendar);
            MonthView = calendar;
        }
Пример #2
0
        private void CloseCalendar(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            tableView.ReloadRows(new NSIndexPath[] { path }, UITableViewRowAnimation.None);
            RectangleF screenRect = dvc.View.Window.Frame;
            RectangleF endFrame   = new RectangleF(calView.Frame.X, calView.Frame.Y + screenRect.Size.Height,
                                                   calView.Frame.Size.Width, calView.Frame.Size.Height);

            //endFrame.origin.y = screenRect.Y + screenRect.Size.Height;

            // start the slide down animation
            UIView.BeginAnimations(null);
            UIView.SetAnimationDuration(0.3);

            // we need to perform some post operations after the animation is complete
            UIView.SetAnimationDelegate(dvc);
            //UIView.SetAnimationDidStopSelector(slideDownDidStop());

            calView.Frame = endFrame;
            UIView.CommitAnimations();

            // remove the "Done" button in the nav bar
            dvc.NavigationItem.RightBarButtonItem = rightOld;
            dvc.NavigationItem.LeftBarButtonItem  = leftOld;

            // deselect the current table row
            tableView.DeselectRow(path, true);
            calView.RemoveFromSuperview();
            calView = null;
            if (DoneEditing != null)
            {
                DoneEditing();
            }
        }
Пример #3
0
        protected override void OnModelSet(VisualElement model)
        {
            _view = (CalendarView)model;
            base.OnModelSet(model);

            var calendarView = new CalendarMonthView(DateTime.Now, true);

            calendarView.OnDateSelected += (date) => {
                _view.NotifyDateSelected(date);
            };

            base.SetNativeControl(calendarView);
        }
Пример #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <CalendarView> e)
        {
            _view = (CalendarView)e.NewElement;
            base.OnElementChanged(e);

            var calendarView = new CalendarMonthView(DateTime.Now, true);

            calendarView.OnDateSelected += (date) =>
            {
                _view.NotifyDateSelected(date);
            };

            base.SetNativeControl(calendarView);
        }
 private void HandleDateSelectedEvent(CalendarMonthView calendar)
 {
     calendar.dateSelected += (CalendarViewEventArgs _args) =>
     {
         if (GlobalSetting.IsArabic)
         {
             SelectedHijriYear  = _args.hijriSelectedYear;
             SelectedHijriMonth = _args.hijriSelectedMonth;
             SelectedHijriDay   = _args.hijriSelectedDay;
         }
         else
         {
             SelectedGregorianDate = _args.gregorianSelectedDate;
         }
     };
 }
        protected override void OnElementChanged(ElementChangedEventArgs <View> e)
        {
            base.OnElementChanged(e);

            view = (CalendarView)Element;

            if (view != null)
            {
                calendarView                 = new CalendarMonthView(view?.SelectedDate ?? DateTime.Today, false);
                calendarView.SwipedUp       += view.Hide;
                calendarView.OnDateSelected += view.NotifyDateSelected;
                calendarView.MonthChanged   += view.NotifyMonthChanged;

                try {
                    SetNativeControl(calendarView);
                } catch {
                    // Hiding calendar causes null reference exception.
                }
            }
        }
        public CalendarPageViewModel(INavigationService navigationService, IPageDialogService dialog) : base(navigationService, dialog)
        {
            IsBusy = false;

            // make sure we have a default item collection
            EventsCollection = new ScheduleAppointmentCollection();

            // test locale.
            Locale = GlobalSetting.CultureCode;

            AppointmentCommand = new DelegateCommand <ScheduleAppointment>(ShowAppointment);

            LoadEventData();

            MonthViewDate = DateTime.Now;
            MonthView     = new CalendarMonthView(MonthViewDate, DateTime.MinValue);

            OnPrevCommand = new DelegateCommand(SetPreviousMonth);
            OnNextCommand = new DelegateCommand(SetNextMonth);
        }
Пример #8
0
        public void buildMonthView()
        {
            calMonthView = new CalendarMonthView (currentDate, monthEvents.Select (x => x.startDate.Date).ToArray ());
            eventDvc = buildMonthSingleDayEventList (calMonthView.Frame);
            calMonthView.IsDayMarkedDelegate += date => { return monthEvents.Where (x => x.startDate.Date == date.Date || x.endDate == date.Date).Count () > 0; };
            calMonthView.OnDateSelected += date =>
            {
                //SelectedView = 0;
                SetDate (date);
                eventDvc.TableView.RemoveFromSuperview ();
                eventDvc = buildMonthSingleDayEventList (new RectangleF(calMonthView.Frame.Location, calMonthView.Size));
                eventDvc.Root = getMonthDayEvents ();
                monthView.AddSubview (eventDvc.TableView);
                monthView.BringSubviewToFront (calMonthView);

            };

            eventDvc.Root = getMonthDayEvents ();
            calMonthView.SizeChanged += delegate {
                eventDvc.TableView.RemoveFromSuperview ();
                eventDvc = buildMonthSingleDayEventList (new RectangleF(calMonthView.Frame.Location, calMonthView.Size));
                eventDvc.Root = getMonthDayEvents ();
                monthView.AddSubview (eventDvc.TableView);
                monthView.BringSubviewToFront (calMonthView);
            };
            calMonthView.MonthChanged += delegate {
                SetDate (calMonthView.CurrentMonthYear);
                eventDvc.TableView.RemoveFromSuperview ();
                eventDvc = buildMonthSingleDayEventList (new RectangleF(calMonthView.Frame.Location, calMonthView.Size));
                eventDvc.Root = getMonthDayEvents ();
                monthView.AddSubview (eventDvc.TableView);
                monthView.BringSubviewToFront (calMonthView);
            };
            monthView.BackgroundColor = UIColor.White;
            monthView.AddSubview (eventDvc.TableView);
            monthView.AddSubview (calMonthView);
            buildMonthSingleDayEventList (calMonthView.Frame);
        }
Пример #9
0
        private void ShowCalendar(DialogViewController dvc, UITableView tableView, NSIndexPath path)
        {
            if (calView == null)
            {
                calView = new CalendarMonthView(DateValue, true)
                {
                    AutoresizingMask = UIViewAutoresizing.FlexibleWidth
                };
                //calView.ToolbarColor = dvc.SearchBarTintColor;
                calView.SizeChanged += delegate {
                    RectangleF screenRect = tableView.Window.Frame;

                    SizeF pickerSize = calView.Size;
                    // compute the end frame
                    RectangleF pickerRect = new RectangleF(0.0f,
                                                           screenRect.Y + screenRect.Size.Height - pickerSize.Height,
                                                           pickerSize.Width,
                                                           pickerSize.Height);
                    // start the slide up animation
                    UIView.BeginAnimations(null);
                    UIView.SetAnimationDuration(0.3);

                    // we need to perform some post operations after the animation is complete
                    UIView.SetAnimationDelegate(dvc);

                    calView.Frame = pickerRect;

                    UIView.CommitAnimations();
                };
            }
            if (calView.Superview == null)
            {
                if (DateValue.Year < 2010)
                {
                    DateValue = DateTime.Today;
                }
                calView.SizeThatFits(SizeF.Empty);
                calView.OnDateSelected += (date) => {
                    DateValue = date;
                    if (OnDateSelected != null)
                    {
                        OnDateSelected(date);
                    }
                    //Console.WriteLine(String.Format("Selected {0}", date.ToShortDateString()));
                    if (closeOnSelect)
                    {
                        CloseCalendar(dvc, tableView, path);
                    }
                };


                tableView.Window.AddSubview(calView);
                //dvc.View.Window.AddSubview(datePicker);
                //
                // size up the picker view to our screen and compute the start/end frame origin for our slide up animation
                //
                // compute the start frame
                RectangleF screenRect = tableView.Window.Frame;

                SizeF      pickerSize = calView.Size;
                RectangleF startRect  = new RectangleF(0.0f,
                                                       screenRect.Y + screenRect.Size.Height,
                                                       pickerSize.Width, pickerSize.Height);
                calView.Frame = startRect;

                // compute the end frame
                RectangleF pickerRect = new RectangleF(0.0f,
                                                       screenRect.Y + screenRect.Size.Height - pickerSize.Height,
                                                       pickerSize.Width,
                                                       pickerSize.Height);
                // start the slide up animation
                UIView.BeginAnimations(null);
                UIView.SetAnimationDuration(0.3);

                // we need to perform some post operations after the animation is complete
                UIView.SetAnimationDelegate(dvc);

                calView.Frame = pickerRect;

                // shrink the table vertical size to make room for the date picker
                RectangleF newFrame = new RectangleF(tableView.Frame.X, tableView.Frame.Y,
                                                     tableView.Frame.Size.Width, tableView.Frame.Size.Height + 55 - calView.Frame.Height);
                // newFrame.Size.Height -= datePicker.Frame.Height;
                //tableView.Frame = newFrame;
                UIView.CommitAnimations();
                rightOld = dvc.NavigationItem.RightBarButtonItem;
                //Multi Buttons

                // create a toolbar to have two buttons in the right
                UIToolbar tools = new UIToolbar(new RectangleF(0, 0, 133, 44.01f));
                tools.TintColor = dvc.NavigationController.NavigationBar.TintColor;
                // create the array to hold the buttons, which then gets added to the toolbar
                List <UIBarButtonItem> buttons = new List <UIBarButtonItem>(3);

                // create switch button
                switchButton = new UIBarButtonItem("Switch", UIBarButtonItemStyle.Bordered, delegate {
                    CloseCalendar(dvc, tableView, path);
                    ShowDatePicker(dvc, tableView, path);
                });

                buttons.Add(switchButton);

                // create a spacer
                UIBarButtonItem spacer = new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace, null, null);
                buttons.Add(spacer);

                //create done button
                doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, delegate {
                    //DateValue = calView.CurrentDate;
                    CloseCalendar(dvc, tableView, path);
                });
                buttons.Add(doneButton);

                tools.SetItems(buttons.ToArray(), false);

                //
                dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(tools);

                leftOld = dvc.NavigationItem.LeftBarButtonItem;
                dvc.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("None", UIBarButtonItemStyle.Bordered, delegate {
                    DateValue = DateTime.MinValue;
                    if (OnDateSelected != null)
                    {
                        OnDateSelected(CalendarDateTimeElement.DateTimeMin);
                    }
                    CloseCalendar(dvc, tableView, path);
                });
                // add the "Done" button to the nav bar
                //dvc.NavigationItem.SetRightBarButtonItem(doneButton,true);
                //
            }
        }
Пример #10
0
        // -----------------------------Function

        public void PopulateCalendar(int month, CalendarMonthView view)
        {
            string id = "";

            view.spMonth.Children.RemoveRange(0, view.spMonth.Children.Count);
            FrameworkElement fe = GetWindow(view);

            if (fe != null)
            {
                if ((fe as MainWindow).MainWDVM.MainUser != null)
                {
                    id = (fe as MainWindow).MainWDVM.MainUser.UserID;
                }
            }

            int tmpYear = int.Parse(view.lbYear.Content.ToString());

            Days = GetCalendar(tmpYear, month);
            for (int i = 0; i < 6; i++)
            {
                StackPanel sp = new StackPanel()
                {
                    Orientation = Orientation.Horizontal,
                    Height      = 80
                };
                for (int j = 7 * i; j < (i + 1) * 7; j++)
                {
                    Label lb = new Label()
                    {
                        Content  = Days[j].ToString(),
                        Width    = 100,
                        Height   = 80,
                        FontSize = 15,
                        HorizontalContentAlignment = HorizontalAlignment.Right,
                        VerticalContentAlignment   = VerticalAlignment.Top,
                        BorderBrush     = Brushes.Black,
                        BorderThickness = new Thickness(1, 1, 1, 1),
                    };
                    if (Days[j] == 0)
                    {
                        lb.IsEnabled  = false;
                        lb.Foreground = Brushes.Gray;
                    }
                    sp.Children.Add(lb);
                    lb.MouseEnter += (sender, e) =>
                    {
                        lb.Background = new SolidColorBrush(Colors.LightGoldenrodYellow);
                    };
                    lb.MouseLeave += (sender, e) =>
                    {
                        lb.Background = new SolidColorBrush(Colors.Transparent);
                    };
                    lb.MouseUp += (sender, e) =>
                    {
                        AddEventView eventView = new AddEventView(id, int.Parse(lb.Content as string));
                        eventView.ShowDialog();
                    };
                }
                view.spMonth.Children.Add(sp);
                if (i == 0)
                {
                    Canvas.SetTop(sp, 20);
                }
                else
                {
                    Canvas.SetTop(sp, (i * 80) + 20);
                }
                //Canvas.SetLeft(sp, 20);
            }

            //IEnumerable<Label> lbList = view.gridMonth.Children.OfType<Label>();

            //foreach (Label item in lbList.Where(l => (l.Content as string).CompareTo("Mon") != 0 && ((l.Content as string).CompareTo("Tue") != 0)))
            //{
            //    item.Background = Brushes.Red;
            //}
        }
Пример #11
0
        public void buildMonthView()
        {
            foreach (var subview in monthView.Subviews)
            {
                subview.RemoveFromSuperview();
            }

            calMonthView = new CalendarMonthView(currentDate, monthEvents.Select(x => x.startDate.Date).ToArray(), _isPortrait);
            eventDvc = buildMonthSingleDayEventList(calMonthView.Frame);
            calMonthView.IsDayMarkedDelegate += date => { return monthEvents.Where(x => x.startDate.Date >= date.Date && x.startDate < date.Date.AddDays(1)).Any(); };
            calMonthView.OnDateSelected += date =>
            {
                //SelectedView = 0;
                SetDateAndReloadDay(date);
            };

            eventDvc.Root = getMonthDayEvents();
            calMonthView.SizeChanged += delegate
            {
                eventDvc.TableView.RemoveFromSuperview();
                eventDvc = buildMonthSingleDayEventList(new RectangleF(calMonthView.Frame.Location, calMonthView.Size));
                eventDvc.Root = getMonthDayEvents();
                monthView.AddSubview(eventDvc.TableView);
                monthView.BringSubviewToFront(calMonthView);
            };
            calMonthView.MonthChanged += delegate
            {
                SetDate(calMonthView.CurrentMonthYear);
                eventDvc.TableView.RemoveFromSuperview();
                eventDvc = buildMonthSingleDayEventList(new RectangleF(calMonthView.Frame.Location, calMonthView.Size));
                eventDvc.Root = getMonthDayEvents();
                monthView.AddSubview(eventDvc.TableView);
                monthView.BringSubviewToFront(calMonthView);
            };
            monthView.BackgroundColor = UIColor.White;
            monthView.AddSubview(eventDvc.TableView);
            monthView.AddSubview(calMonthView);
            buildMonthSingleDayEventList(calMonthView.Frame);
        }
 private void SetNextMonth()
 {
     MonthViewDate = MonthViewDate.AddMonths(1);
     MonthView     = new CalendarMonthView(MonthViewDate, DateTime.MinValue);
 }
 private void SetPreviousMonth()
 {
     MonthViewDate = MonthViewDate.AddMonths(-1);
     MonthView     = new CalendarMonthView(MonthViewDate, DateTime.MinValue);
 }