Esempio n. 1
0
 public MonthGridView(CalendarMonthView calendarMonthView, DateTime month, DateTime day)
 {
     SelectedDate       = day;
     _calendarMonthView = calendarMonthView;
     _currentDay        = DateTime.Today;
     _currentMonth      = month.Date;
 }
Esempio n. 2
0
 public override void ViewDidLoad()
 {
     MonthView = new CalendarMonthView(CurrentDate);
     MonthView.OnDateSelected += (date) => {
         CurrentDate = date;
         Console.WriteLine(String.Format("Selected {0}", date.ToShortDateString()));
     };
     MonthView.OnFinishedDateSelection += (date) => {
         Console.WriteLine(String.Format("Finished selecting {0}", date.ToShortDateString()));
     };
     MonthView.IsDayMarkedDelegate += (date) => {
         return((date.Day % 2 == 0) ? true : false);
     };
     View.AddSubview(MonthView);
 }
 public override void ViewDidLoad()
 {
     MonthView = new CalendarMonthView(CurrentDate);
     MonthView.OnDateSelected += (date) => {
         CurrentDate = date;
         Console.WriteLine(String.Format("Selected {0}", date.ToShortDateString()));
     };
     MonthView.OnFinishedDateSelection += (date) => {
         Console.WriteLine(String.Format("Finished selecting {0}", date.ToShortDateString()));
     };
     MonthView.IsDayMarkedDelegate += (date) => {
         return (date.Day % 2==0) ? true : false;
     };
     View.AddSubview(MonthView);
 }
Esempio n. 4
0
 public MonthGridView(CalendarMonthView calendarMonthView, DateTime month, DateTime day)
 {
     SelectedDate = day;
     _calendarMonthView = calendarMonthView;
     _currentDay = DateTime.Today;
     _currentMonth = month.Date;
 }
Esempio n. 5
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);
                //
            }
        }
Esempio n. 6
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();
        }