Exemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (this.appointmentCollection != null)
            {
                this.appointmentCollection = null;
            }

            if (this.scheduleViews != null)
            {
                this.scheduleViews.Clear();
            }

            if (this.scheduleViewPicker != null)
            {
                this.scheduleViewPicker.Dispose();
                this.scheduleViewPicker = null;
            }

            if (this.label != null)
            {
                this.label.Dispose();
                this.label = null;
            }

            if (this.button != null)
            {
                this.button.Dispose();
                this.button = null;
            }

            if (this.textButton != null)
            {
                this.textButton.Dispose();
                this.textButton = null;
            }

            if (this.schedule != null)
            {
                this.schedule.Dispose();
                this.schedule = null;
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// Initialize a new instance of the class <see cref="ScheduleGettingStarted"/> class
        /// </summary>
        public ScheduleGettingStarted()
        {
            schedule        = new SFSchedule();
            label.Text      = "Schedule View";
            label.TextColor = UIColor.Black;
            this.AddSubview(label);

            textButton.SetTitle("WeekView", UIControlState.Normal);
            textButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            textButton.BackgroundColor     = UIColor.Clear;
            textButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            textButton.Hidden             = false;
            textButton.Layer.BorderColor  = UIColor.FromRGB(246, 246, 246).CGColor;
            textButton.Layer.BorderWidth  = 4;
            textButton.Layer.CornerRadius = 8;
            textButton.TouchUpInside     += ShowPicker;
            this.AddSubview(textButton);

            button.SetTitle("Done\t", UIControlState.Normal);
            button.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            button.BackgroundColor     = UIColor.FromRGB(240, 240, 240);
            button.SetTitleColor(UIColor.Black, UIControlState.Normal);
            button.Hidden         = true;
            button.TouchUpInside += HidePicker;

            appointmentCollection = new AppointmentCollection();
            schedule.ScheduleView = SFScheduleView.SFScheduleViewWeek;
            schedule.MonthViewSettings.ShowAppointmentsInline = true;

            // Custom appointment mapping
            AppointmentMapping mapping = new AppointmentMapping();

            mapping.Subject               = "EventName";
            mapping.StartTime             = "From";
            mapping.EndTime               = "To";
            mapping.AppointmentBackground = "color";
            mapping.Location              = "Organizer";
            mapping.IsAllDay              = "isAllDay";
            mapping.MinHeight             = "MinimumHeight";
            schedule.AppointmentMapping   = mapping;

            schedule.ItemsSource = appointmentCollection.GetAppointments();


            this.AddSubview(schedule);

            this.scheduleViews.Add((NSString)"Week View");
            this.scheduleViews.Add((NSString)"Day View");
            this.scheduleViews.Add((NSString)"Work Week View");
            this.scheduleViews.Add((NSString)"Month View");

            SchedulePickerModel model = new SchedulePickerModel(this.scheduleViews);

            // Event occurs when the item picked in the picker
            model.PickerChanged += (sender, e) =>
            {
                this.selectedView = e.SelectedValue;
                textButton.SetTitle(selectedView, UIControlState.Normal);
                if (selectedView == "Day View")
                {
                    schedule.ScheduleView = SFScheduleView.SFScheduleViewDay;
                }
                else if (selectedView == "Week View")
                {
                    schedule.ScheduleView = SFScheduleView.SFScheduleViewWeek;
                }
                else if (selectedView == "Work Week View")
                {
                    schedule.ScheduleView = SFScheduleView.SFScheduleViewWorkWeek;
                }
                else if (selectedView == "Month View")
                {
                    schedule.ScheduleView = SFScheduleView.SFScheduleViewMonth;
                }
            };

            scheduleViewPicker.ShowSelectionIndicator = true;
            scheduleViewPicker.Hidden          = true;
            scheduleViewPicker.Model           = model;
            scheduleViewPicker.BackgroundColor = UIColor.White;

            this.OptionView = new UIView();
        }