Ejemplo n.º 1
0
        /// <summary>
        /// Raises the PreRender event.
        /// </summary>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (ReadOnly)
            {
                m_RadDateTimePicker.DatePopupButton.Attributes["onclick"] = m_RadDateTimePicker.TimePopupButton.Attributes["onclick"] = "return false;";
            }

            RadCalendar calendar = ((this.SharedCalendar == null) ? m_RadDateTimePicker.Calendar : this.SharedCalendar);

            calendar.ShowRowHeaders = false;

            if (this.Width.IsEmpty)
            {
                if (this.Theme == Pages.MasterPageTheme.Modern)
                {
                    m_RadDateTimePicker.Width = Unit.Pixel(180);
                }
            }
            else
            {
                m_RadDateTimePicker.Width = this.Width;
            }
        }
Ejemplo n.º 2
0
 protected override void SelectStateCore(CalendarCellStateContext context, RadCalendar container)
 {
     if (context.Date > DateTime.Now)
     {
         context.IsBlackout = true;
     }
 }
Ejemplo n.º 3
0
 public MonthViewElement(RadCalendar calendar, CalendarView view)
     : base(calendar, view)
 {
     this.view = view;
     this.view.PropertyChanged += new PropertyChangedEventHandler(this.view_PropertyChanged);
     this.InitializeChildren();
 }
Ejemplo n.º 4
0
 protected override void DisposeManagedResources()
 {
     this.view     = (CalendarView)null;
     this.calendar = (RadCalendar)null;
     this.owner    = (CalendarVisualElement)null;
     base.DisposeManagedResources();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CalendarView"/> class.
 /// </summary>
 /// <param name="calendar">The owner calendar of the calendar view.</param>
 public CalendarView(RadCalendar calendar)
 {
     this.calendar              = calendar;
     calendar.FocusDateChanged += new EventHandler <RoutedPropertyChangedEventArgs <DateTime> >(this.FocusDateChanged);
     calendar.SelectionHelper.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(this.SelectionHelperSelectionChanged);
     this.DateToContent = new Dictionary <DateTime, CalendarButtonContent>();
 }
Ejemplo n.º 6
0
 public RadCalendarElement(RadCalendar calendar, CalendarView view)
     : base(calendar, view)
 {
     this.view     = view;
     this.calendar = calendar;
     this.InitializeChildren();
 }
Ejemplo n.º 7
0
        protected override void DisposeManagedResources()
        {
            this.calendar = null;
            this.view     = null;

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

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

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

            base.DisposeManagedResources();
        }
Ejemplo n.º 8
0
        internal void ScrollAppointmentIntoView(IAppointment appointment)
        {
            RadCalendar calendar = this.Owner;

            if (calendar != null)
            {
                CalendarMultiDayViewModel model = calendar.Model.multiDayViewModel;
                var appointmentInfos            = model.appointmentInfos;
                if (appointmentInfos != null && appointmentInfos.Count > 0)
                {
                    DateTime startDate = calendar.DisplayDate;
                    DateTime endDate   = calendar.DisplayDate.AddDays(calendar.MultiDayViewSettings.VisibleDays - 1);
                    CalendarAppointmentInfo appointmentInfo = appointmentInfos.FirstOrDefault(a => a.childAppointment == appointment && startDate <= a.Date && endDate >= a.Date);
                    if (appointmentInfo != null)
                    {
                        RadRect layoutSlot = appointmentInfo.layoutSlot;
                        if (this.scrollViewer.VerticalOffset != layoutSlot.Y)
                        {
                            this.isScrollingInvoked = true;
                            this.scrollViewer.ChangeView(0.0f, layoutSlot.Y, 1.0f);
                        }
                    }
                }
            }
        }
Ejemplo n.º 9
0
        internal void ArrangeVisualElement()
        {
            RadCalendar calendar = this.Owner;
            CalendarMultiDayViewModel multiDayViewModel = calendar.Model.multiDayViewModel;

            if (multiDayViewModel.allDayAppointmentInfos != null && multiDayViewModel.allDayAppointmentInfos.Count > 0)
            {
                Size availableCalendarViewSize = calendar.CalendarViewSize;

                double timeRulerWidth   = multiDayViewModel.timeRulerWidth;
                double totalWidth       = (availableCalendarViewSize.Width - timeRulerWidth) * 2;
                double allDayAreaHeight = multiDayViewModel.totalAllDayAreaHeight;

                this.allDayAreaScrollViewer.Width  = 2 * totalWidth;
                this.allDayAreaScrollViewer.Height = allDayAreaHeight;

                int allDayAreaRowCount = multiDayViewModel.allDayAreaRowCount;
                this.allDayAreaPanel.Height = multiDayViewModel.allDayAppointmentInfos.First().layoutSlot.Bottom *allDayAreaRowCount
                                              + (allDayAreaRowCount - 1) * calendar.MultiDayViewSettings.AllDayAppointmentSpacing;

                double cellHeight = multiDayViewModel.dayViewLayoutSlot.Height / multiDayViewModel.SpecificColumnCount;
                double topOffset  = Math.Abs(cellHeight + multiDayViewModel.dayViewLayoutSlot.Y + calendar.GridLinesThickness);
                Canvas.SetTop(this.allDayAreaScrollViewer, topOffset);
                this.UpdatePanelBackground(calendar.MultiDayViewSettings.AllDayAreaBackground);
            }
            else
            {
                this.allDayAreaPanel.Height        = 0;
                this.allDayAreaScrollViewer.Width  = 0;
                this.allDayAreaScrollViewer.Height = 0;
            }
        }
Ejemplo n.º 10
0
        protected override void SelectStyleCore(CalendarCellStyleContext context, RadCalendar container)
        {
            if (container.DisplayMode != CalendarDisplayMode.MonthView)
            {
                return;
            }

            var events = (container.DataContext as ExampleViewModel).Events;

            if (events.TryGetValue(context.Date, out this.eventsForDate))
            {
                bool appointmentEvent = context.Date.Day % 2 == 0;

                if (context.IsFromAnotherView)
                {
                    context.CellTemplate = appointmentEvent ? this.AnotherMonthAppointmentEvent : this.AnotherMonthEvent;
                }
                else if (!context.IsSelected)
                {
                    context.CellTemplate = appointmentEvent ? this.NormalAppointmentEvent : this.NormalEvent;
                }
                else if (context.IsSelected)
                {
                    context.CellTemplate = appointmentEvent ? this.SelectedAppointmentEvent : this.SelectedEvent;
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Register client script.
        /// </summary>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            ScriptManager.RegisterClientScriptInclude(this.Page, this.Page.GetType(), "DateRangeClientScripts", ResourceProvider.GetResourceUrl("Scripts.DateRange.js", true));

            if (this.ShowDateRange)
            {
                m_DateRange.Attributes["onchange"] = "DateRange_OnChange('" + m_DateRange.ClientID + "', '" + m_DateStartPicker.ClientID + "', '" + m_DateEndPicker.ClientID + "', '" + m_Validator.ClientID + "');";

                m_StartupScript = "Sys.Application.add_load(function() { DateRange_OnChange('" + m_DateRange.ClientID + "', '" + m_DateStartPicker.ClientID + "', '" + m_DateEndPicker.ClientID + "', ''); });\r\n";

                ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "DatesRangesClientScript", DatesRangesClientScript, true);
            }

            if (this.SharedCalendar == null)
            {
                m_RadCalendar    = new RadCalendar();
                m_RadCalendar.ID = "sc";
                m_DateStartPicker.SharedCalendar = m_DateEndPicker.SharedCalendar = m_RadCalendar;
                m_RadCalendar.Skin = "Default";
                this.Controls.Add(m_RadCalendar);
            }

            m_Validator.Attributes["dateStartPickerId"]    = m_DateStartPicker.ClientID;
            m_Validator.Attributes["dateEndPickerId"]      = m_DateEndPicker.ClientID;
            m_Validator.Attributes["required"]             = (this.Required ? "true" : "false");
            m_Validator.Attributes["requiredErrorMessage"] = Resources.DateRange_RequiredValidator_ErrorMessage;
            m_Validator.Attributes["compareErrorMessage"]  = Resources.DateRange_CompareValidator_ErrorMessage;
        }
Ejemplo n.º 12
0
        /* CalendarViewModel handles mostly all the events that may be triggered when interacting with buttons/gestures of CalendarPage, which may be, for example,
         * a change of view mode (Month mode to Years mode), a new page may be pushed (if Settings button is pressed, a SettingsPage() will be shown. If a new appointment is
         * added, we will switch to AppointmentCreationPage(). */
        public CalendarViewModel(CalendarPage page, INavigation navigation, RadCalendar calendar)
        {
            this.page       = page;
            this.navigation = navigation;
            this.calendar   = calendar;

            LoadAppointments();

            MessagingCenter.Subscribe <AppointmentCreationPage, object[]>(this, "CreationAppointments", (sender, values) =>
            {
                if (values[0].ToString() == "Update")
                {
                    Appointment oldAppointment = values[1] as Appointment;
                    appointmentsList.Remove(oldAppointment);
                    CognitoSyncViewModel.GetInstance().RemoveFromDataset(Constants.APPOINTMENTS_DATASET_NAME, oldAppointment.Key);
                }

                Appointment newAppointment = values[2] as Appointment;
                appointmentsList.Add(newAppointment);

                string json = JsonConvert.SerializeObject(newAppointment);
                CognitoSyncViewModel.GetInstance().WriteDataset(Constants.APPOINTMENTS_DATASET_NAME, newAppointment.Key, json);

                calendar.AppointmentsSource = AppointmentList;
            });

            calendar.AppointmentTapped += async(sender, e) =>
            {
                Appointment a  = (e.Appointment as Appointment);
                var         az = appointmentsList.FirstOrDefault(item => item.Title == a.Title && item.StartDate == a.StartDate && item.EndDate == a.EndDate && item.IsAllDay == a.IsAllDay);
                /* We can safely assume we got the key */
                a.Key = az.Key;
                await navigation.PushAsync(new AppointmentCreationPage(appointmentsList, "Update", a));
            };
        }
Ejemplo n.º 13
0
        protected override void SelectStyleCore(CalendarCellStyleContext context, RadCalendar container)
        {
            var scheduleViewModel = container.DataContext as ScheduleViewModel;

            if (scheduleViewModel != null)
            {
                var events = scheduleViewModel.CoursesScheduleList;
                switch (scheduleViewModel.DisplayMode)
                {
                case CalendarDisplayMode.MonthView:

                    if (events.Any(e => e.DateDebut <= context.Date && e.DateFin >= context.Date))
                    {
                        context.CellTemplate = this.EventTemplate;
                    }
                    break;

                case CalendarDisplayMode.YearView:
                    if (events.Any(e => (e.DateDebut.Month == context.Date.Month && e.DateDebut.Year == context.Date.Year) || (e.DateFin.Month == context.Date.Month && e.DateFin.Year == context.Date.Year)))
                    {
                        context.CellTemplate = this.EventTemplate;
                    }
                    break;

                default:
                    if (events.Any(e => e.DateDebut.Year == context.Date.Year || e.DateFin.Year == context.Date.Year))
                    {
                        context.CellTemplate = this.EventTemplate;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 14
0
        private void UpdateAllDayAppointments(List <CalendarAppointmentInfo> allDayAppointmentInfos)
        {
            int         index    = 0;
            RadCalendar calendar = this.Owner;

            foreach (var appInfo in allDayAppointmentInfos)
            {
                if (!this.allDayClipArea.IntersectsWith(appInfo.layoutSlot))
                {
                    continue;
                }

                AppointmentControl appointmentControl = this.GetDefaultAllDayAppointmentVisual(index);
                if (appointmentControl != null)
                {
                    RadRect layoutSlot = appInfo.layoutSlot;
                    appointmentControl.Header = appInfo.Subject;
                    if (appInfo.Brush != null)
                    {
                        appointmentControl.Background = appInfo.Brush;
                    }

                    appointmentControl.appointmentInfo = appInfo;

                    StyleSelector styleSelector = calendar.AppointmentStyleSelector;
                    if (styleSelector != null)
                    {
                        var style = styleSelector.SelectStyle(appInfo, appointmentControl);
                        if (style != null)
                        {
                            appointmentControl.Style = style;
                        }
                    }
                    else if (appointmentControl.Style != null)
                    {
                        appointmentControl.ClearValue(AppointmentControl.StyleProperty);
                    }

                    AppointmentTemplateSelector headerTemplateSelector = calendar.AppointmentHeaderTemplateSelector;
                    if (headerTemplateSelector != null)
                    {
                        DataTemplate template = headerTemplateSelector.SelectTemplate(appInfo, appInfo.cell);
                        if (template != null)
                        {
                            appointmentControl.HeaderTemplate = template;
                        }
                    }

                    XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true);
                    index++;
                }
            }

            while (index < this.realizedAllDayAppointmentDefaultPresenters.Count)
            {
                this.realizedAllDayAppointmentDefaultPresenters[index].Visibility = Visibility.Collapsed;
                index++;
            }
        }
Ejemplo n.º 15
0
 protected override void CreateChildElements()
 {
     base.CreateChildElements();
     this.calendar = new RadCalendar();
     this.calendar.AllowMultipleSelect = true;
     this.hostItem = new RadHostItem((Control)this.calendar);
     this.Children.Add((RadElement)this.hostItem);
 }
Ejemplo n.º 16
0
 public RadCalendarElement(RadCalendar calendar, CalendarView view)
     : base(calendar, view)
 {
     this.view     = view;
     this.calendar = calendar;
     this.InitializeChildren();
     LocalizationProvider <CalendarLocalizationProvider> .CurrentProviderChanged += new EventHandler(this.CalendarLocalizationProvider_CurrentProviderChanged);
 }
Ejemplo n.º 17
0
        protected override void DisposeManagedResources()
        {
            this.view     = null;
            this.calendar = null;
            this.owner    = null;

            base.DisposeManagedResources();
        }
Ejemplo n.º 18
0
        public CalendarPage()
        {
            var calendar = new RadCalendar();

            Title = "CALENDAR";

            Content = calendar;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Evaluates the appearance settings to be applied on the respective calendar cell.
        /// </summary>
        /// <param name="value">The context.</param>
        /// <param name="container">The RadCalendar container.</param>
        public Windows.UI.Xaml.Style SelectStyle(object context, RadCalendar container)
        {
            //if (context == null || container == null)
            //{
            //    return;
            //}

            return(this.SelectStyleCore(context, container));
        }
Ejemplo n.º 20
0
 internal CalendarDayCollection(RadCalendar owner, CalendarDayCollection days, int capacity)
 {
     this.children.Capacity = capacity;
     this.calendar          = owner;
     if (days != null)
     {
         this.AddRange(days);
     }
 }
        public CalendarGettingStartedCSharp()
        {
            // >> calendar-gettingstarted-csharp
            var calendar = new RadCalendar();

            // << calendar-gettingstarted-csharp

            this.Content = calendar;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Evaluates the appearance settings to be applied on the respective calendar cell.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="container">The RadCalendar container.</param>
        public Windows.UI.Xaml.Style SelectStyle(object context, RadCalendar container)
        {
            //if (context == null || container == null)
            //{
            //    throw new ArgumentException();
            //}

            return(this.SelectStyleCore(context, container));
        }
Ejemplo n.º 23
0
 public RadDateTimePickerCalendar(RadDateTimePickerElement dateTimePicker)
 {
     this.dateTimePickerElement = dateTimePicker;
     this.calendar           = new RadCalendar();
     this.calendar.Focusable = false;
     this.CreateElements();
     this.calendar.AllowMultipleSelect = false;
     this.calendar.SelectionChanged   += new EventHandler(this.calendar_SelectionChanged);
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Evaluates the state (behavior) to be applied on the respective calendar cell.
        /// </summary>
        /// <param name="container">The <see cref="RadCalendar"/> instance that contains the respective cell.</param>
        /// <param name="context">The <see cref="CalendarCellStateContext"/> associated with the respective cell.</param>
        public void SelectState(CalendarCellStateContext context, RadCalendar container)
        {
            if (container == null)
            {
                return;
            }

            this.SelectStateCore(context, container);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Localizes the calendar.
 /// </summary>
 /// <param name="calendar">The calendar.</param>
 public static void LocalizeCalendar(RadCalendar calendar)
 {
     if (calendar != null)
     {
         calendar.FastNavigationSettings.CancelButtonCaption = Localization.GetString("Date Picker Cancel", LocalSharedResourceFile);
         calendar.FastNavigationSettings.OkButtonCaption     = Localization.GetString("Date Picker OK", LocalSharedResourceFile);
         calendar.FastNavigationSettings.TodayButtonCaption  = Localization.GetString("Date Picker Today", LocalSharedResourceFile);
     }
 }
Ejemplo n.º 26
0
 public CalendarVisualElement(
     CalendarVisualElement owner,
     RadCalendar calendar,
     CalendarView view)
 {
     this.calendar = calendar;
     this.owner    = owner;
     this.view     = view;
 }
Ejemplo n.º 27
0
        public override void Execute(object parameter)
        {
            base.Execute(parameter);

            RadCalendar calendar = this.Owner;
            MultiDayViewAppointmentsCRUDViewModel vm = (MultiDayViewAppointmentsCRUDViewModel)this.Owner.DataContext;

            vm.AppointmentTapCommand.Execute(parameter);
        }
Ejemplo n.º 28
0
        public CalendarAppointmentTapped()
        {
            // >> calendar-gettingstarted-appointmentssource-csharp
            var date = new DateTime(2017, 4, 12);

            var calendar = new RadCalendar
            {
                DisplayDate        = date,
                AppointmentsSource = new List <Appointment> {
                    new Appointment {
                        Title     = "Meeting with Tom",
                        Detail    = "Sea Garden",
                        StartDate = date.AddHours(1),
                        EndDate   = date.AddHours(2),
                        Color     = Color.Tomato
                    },
                    new Appointment {
                        Title     = "Lunch with Sara",
                        Detail    = "Restaurant",
                        StartDate = date.AddHours(2).AddMinutes(30),
                        EndDate   = date.AddHours(3),
                        Color     = Color.DarkTurquoise
                    },
                    new Appointment {
                        Title     = "Birthday",
                        StartDate = date.AddHours(2).AddMinutes(30),
                        EndDate   = date.AddHours(3),
                        IsAllDay  = true,
                        Color     = Color.Orange
                    },
                    new Appointment {
                        Title     = "Football Game",
                        StartDate = date.AddDays(1).AddHours(2).AddMinutes(30),
                        EndDate   = date.AddDays(1).AddHours(3),
                        Color     = Color.Green
                    }
                }
            };

            // << calendar-gettingstarted-appointmentssource-csharp

            // >> calendar-features-setviewmode-csharp
            calendar.NativeControlLoaded += (sender, e) =>
            {
                calendar.TrySetViewMode(CalendarViewMode.Day);
            };
            // << calendar-features-setviewmode-csharp

            // >> calendar-features-appointmenttapped-csharp
            calendar.AppointmentTapped += (sender, e) =>
            {
                DisplayAlert(e.Appointment.Title, e.Appointment.Detail, "OK");
            };
            // << calendar-features-appointmenttapped-csharp
            this.Content = calendar;
        }
Ejemplo n.º 29
0
        /// <inheritdoc />
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            RadCalendar calendar = ElementTreeHelper.FindVisualAncestor <RadCalendar>(this);

            if (calendar != null)
            {
                return(new CalendarViewHostAutomationPeer(this, calendar));
            }
            return(null);
        }
Ejemplo n.º 30
0
        private void UpdateAllDayAppointments(List <CalendarAppointmentInfo> allDayAppointmentInfos)
        {
            if (allDayAppointmentInfos == null)
            {
                return;
            }

            foreach (var appointmentInfo in allDayAppointmentInfos)
            {
                AppointmentControl appControl;
                if (this.realizedAppointmentPresenters.TryGetValue(appointmentInfo, out appControl))
                {
                    this.visibleAppointmentPresenters.Add(appointmentInfo, appControl);
                }
            }

            RadCalendar calendar = this.Owner;

            foreach (var appInfo in allDayAppointmentInfos)
            {
                AppointmentControl appointmentControl;
                this.visibleAppointmentPresenters.TryGetValue(appInfo, out appointmentControl);

                if (!this.allDayClipArea.IntersectsWith(appInfo.layoutSlot))
                {
                    if (appointmentControl != null)
                    {
                        this.RecycleAppointmentVisual(appInfo, appointmentControl);
                    }

                    continue;
                }

                if (appointmentControl != null)
                {
                    RadRect layoutSlot = appInfo.layoutSlot;
                    XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true);
                    continue;
                }

                appointmentControl = this.GetDefaultAllDayAppointmentVisual(appInfo);
                if (appointmentControl != null)
                {
                    appointmentControl.appointmentInfo = appInfo;
                    calendar.PrepareContainerForAppointment(appointmentControl, appInfo);

                    RadRect layoutSlot = appInfo.layoutSlot;
                    XamlContentLayer.ArrangeUIElement(appointmentControl, layoutSlot, true);
                }
            }

            this.RecycleAppointments(this.recycledAppointments);
            this.recycledAppointments.Clear();
            this.visibleAppointmentPresenters.Clear();
        }
 protected override void SelectStateCore(CalendarCellStateContext context, RadCalendar container) {
     for (int i = 0; i < list.Count; i++) {
         if (container.DisplayMode == CalendarDisplayMode.MonthView) {
             if (context.Date.ToString("MMMM dd, yyyy").Equals(list[i].StartDate.ToString("MMMM dd, yyyy"))) {
                 context.IsBlackout = true;
             } else if (context.Date > list[i].StartDate && context.Date <= list[i].EndDate) {
                 context.IsBlackout = true;  
             }
         }
     }
 }
 protected override void SelectStyleCore(CalendarCellStyleContext context, RadCalendar container) {
     if (context.IsBlackout && container.DisplayMode == CalendarDisplayMode.MonthView) {
         int position = allDangerDates.IndexOf(context.Date.ToString("MMMM dd, yyyy")) % 7;
         context.CellStyle = listCellStyle[position];
     } else {
         foreach (DateTime d in listBloodyDay) {
             if (context.Date.ToString("MMMM dd, yyyy").Equals(d.ToString("MMMM dd, yyyy"))) {
                 context.CellStyle = bloodyCellStyle;
             }
         }
     }
 }
Ejemplo n.º 33
0
 public DnnCalendarDay(RadCalendar calendar) : base(calendar)
 {
 }