Ejemplo n.º 1
0
        private int GetAppointmentSlotDuration(AppointmentSlot appSlot)
        {
            RadScheduler scheduler = this.AppointmentItemsControl != null ? this.AppointmentItemsControl.Scheduler : null;

            if (scheduler != null)
            {
                TimelineViewDefinition viewDefinition = scheduler.ActiveViewDefinition as TimelineViewDefinition;
                if (viewDefinition != null && viewDefinition.CustomTimeSlotLength != DateTimeInterval.Zero)
                {
                    TimeSpan customTimeSpan;

                    var customTimeSlotLength = viewDefinition.CustomTimeSlotLength;
                    if (customTimeSlotLength.Months > 0)
                    {
                        DateTime date      = appSlot.TimeSlot.Start;
                        DateTime startDate = appSlot.TimeSlot.Start;
                        DateTime endDate   = appSlot.TimeSlot.End;
                        TimeSpan duration  = endDate - startDate;

                        int daysInMonth = DateTime.DaysInMonth(date.Year, date.Month);
                        int span        = 0;
                        while (duration.TotalSeconds > 0)
                        {
                            duration   -= TimeSpan.FromDays(daysInMonth);
                            date        = date.AddMonths(1);
                            daysInMonth = DateTime.DaysInMonth(date.Year, date.Month);
                            span++;
                        }

                        if (span < 1)
                        {
                            return(1);
                        }
                        else
                        {
                            return(span);
                        }
                    }
                    else if (customTimeSlotLength.Weeks > 0)
                    {
                        customTimeSpan = TimeSpan.FromDays(customTimeSlotLength.Weeks * 7);
                    }
                    else
                    {
                        customTimeSpan = new TimeSpan(customTimeSlotLength.Days, customTimeSlotLength.Hours, 0, 0, 0);
                    }

                    return((int)(appSlot.TimeSlot.Duration().TotalSeconds / customTimeSpan.TotalSeconds));
                }
                else
                {
                    return((int)(appSlot.TimeSlot.Duration().TotalSeconds / this.timeSlotTimeSpan.TotalSeconds));
                }
            }

            return(1);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application
        /// code or internal processes (such as a rebuilding layout pass) call
        /// <see cref="M:System.Windows.Controls.Control.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            this.parentScheduler = this.GetParent <RadScheduler>();

            this.EnsureBinding();

            Binding bd = new Binding("TimeSlotsView.GroupedFirstGroupItems");

            bd.RelativeSource = RelativeSource.TemplatedParent;
            this.SetBinding(TimeRuler.ItemsSourceProperty, bd);
            this.ConfigureTimeRulerStyle();

            base.OnApplyTemplate();
            this.SetDefaultsIfTimeFormatStringNotDefined();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Provides the behavior for the Measure pass of Silverlight layout. Classes can override this method to define their own Measure pass behavior.
        /// </summary>
        /// <param name="availableSize">The available size that this object can give to child objects. Infinity can be specified as a value to indicate that the object will size to whatever content is available.</param>
        /// <returns>
        /// The size that this object determines it needs during layout, based on its calculations of child object allotted sizes.
        /// </returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            // This is need for WPF to initialize ItemConteinerGenerator property.
            if (this.InternalChildren != null)
            {
            }

            int  timeSlotsCount;
            bool isHorizontal = this.Orientation == Orientation.Horizontal;

            AppointmentItemsControl appointmentsItemsControl = this.AppointmentItemsControl;
            Size timeSlotSize = this.GetTimeSlotItemContentHostRenderSize(out timeSlotsCount);

            if (timeSlotSize.IsEmpty || timeSlotSize == new Size() || (this.previousAvailableSize != availableSize && !isHorizontal))
            {
                this.previousAvailableSize = availableSize;

                if (timeSlotsCount > 0)
                {
                    this.containersGenerated = false;
                }

                if (!isHorizontal)
                {
                    this.RecycleAllAppointmentItems();
                }

                return(base.MeasureOverride(availableSize));
            }
            else
            {
                this.previousAvailableSize = availableSize;

                if (isHorizontal)
                {
                    if (this.columns.Count == 0)
                    {
                        this.InitializeColumns();
                    }
                    this.GenerateContainers();
                }
                else
                {
                    RadScheduler scheduler = this.AppointmentItemsControl != null ? this.AppointmentItemsControl.Scheduler : null;
                    if (scheduler != null && scheduler.ActiveViewDefinition != null && scheduler.ActiveViewDefinition.TimeSlotLength != TimeSpan.Zero)
                    {
                        this.timeSlotTimeSpan = scheduler.ActiveViewDefinition.TimeSlotLength;
                    }
                    else
                    {
                        this.timeSlotTimeSpan = singleDayTimeSpan;
                    }

                    if (this.slots.Count == 0)
                    {
                        this.GenerateSlots(timeSlotsCount);
                    }

                    if (this.IsVirtualizing && this.InRecyclingMode)
                    {
                        this.HideShowMoreButtons();
                    }

                    var source = this.AppointmentItemsControl.ItemsSource as AppointmentSlotCollection;

                    for (int i = 0; i < timeSlotsCount; i++)
                    {
                        TimeSlotItemAppointments item = this.slots[i] as TimeSlotItemAppointments;
                        this.GenerateContainers(item, source);
                    }
                }

                if (double.IsInfinity(availableSize.Width) || double.IsInfinity(availableSize.Height))
                {
                    return(this.TimeSlotItemsControl.DesiredSize);
                }

                return(availableSize);
            }
        }
Ejemplo n.º 4
0
 internal SchedulerAnimation(RadScheduler scheduler)
 {
     this.scheduler = scheduler;
 }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes (such as a rebuilding layout pass) call <see cref="M:System.Windows.Controls.Control.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            RadContextMenu menu = this.GetChildByName("PART_categoryMenu") as RadContextMenu;

            if (menu != null)
            {
                menu.ItemClick += this.MenuItemClick;

                menu.ClickToOpen = true;
            }

            RadComboBox timeMarker = this.GetChildByName("PART_TimeMarkers") as RadComboBox;

            if (timeMarker != null)
            {
                timeMarker.ClearSelectionButtonContent = LocalizationManager.GetString("Clear");
            }
            RadScheduler scheduler = Scheduler as RadScheduler;

            if (scheduler != null && !String.IsNullOrEmpty(scheduler.GroupBy) && this.RecurrenceMode == RecurrenceMode.Occurrence)
            {
                this.ResourceTypesVisibility = Visibility.Collapsed;
            }
            var appointment = this.EditedAppointment as AppointmentBase;

            if (appointment != null)
            {
                if (appointment.TimeMarker != null)
                {
                    this.TimeMarker = this.TimeMarkers.SingleOrDefault(tm => tm.TimeMarkerName == appointment.TimeMarker.TimeMarkerName);
                }
                if (appointment.Category != null)
                {
                    this.Category = appointment.Category;
                }
            }
            if (scheduler != null)
            {
                if (this.Categories == null)
                {
                    if (scheduler.Categories != null && scheduler.Categories.Count > 0)
                    {
                        this.Categories = scheduler.Categories;
                    }
                    else
                    {
                        this.Categories = Telerik.Windows.Controls.Scheduler.Categories.AllCategories;
                    }
                }
                this.ResourceTypeModels = new ResourceTypeViewModelCollection();
                foreach (var resourceType in scheduler.ResourceTypes)
                {
                    this.ResourceTypeModels.Add(new ResourceTypeViewModel(resourceType, this.EditedAppointment));
                }
            }

            this.ConfigureDateTimePickers();
            this.ConfigureButtons();
        }