Completed
Last Updated: 19 Jun 2017 12:04 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 19 Jan 2017 11:03
Category: Scheduler/Reminder
Type: Bug Report
1
FIX. RadScheduler - when only one resource is displayed in Timeline view there is incorrect gap below the horizontal scrollbar
Please refer to the attached sample project and gif file.

Workaround: this.radScheduler1.ElementProvider = new CustomSchedulerElementProvider(this.radScheduler1);

public class CustomSchedulerElementProvider : SchedulerElementProvider
{ 
    public CustomSchedulerElementProvider(RadScheduler scheduler) : base(scheduler)
    {
    }

    protected override T CreateElement<T>(SchedulerView view, object context)
    {
        if (typeof(T) == typeof(TimelineGroupingByResourcesElement))
        {
            return new CustomTimelineGroupingByResourcesElement(this.Scheduler,view)as T;
        }
         
        return base.CreateElement<T>(view, context);
    }
}

public class CustomTimelineGroupingByResourcesElement : TimelineGroupingByResourcesElement
{
    public CustomTimelineGroupingByResourcesElement(RadScheduler scheduler, SchedulerView view) : base(scheduler, view)
    {
    }

    protected override SizeF ArrangeOverride(SizeF finalSize)
    {
        RectangleF contentRect = new RectangleF(PointF.Empty, finalSize);
        int vScrollOffset = this.View.AllowResourcesScrolling ? this.ResourceScrollBarThickness : 0;

        if (this.VScrollBar != null && this.VScrollBar.Maximum < this.VScrollBar.LargeChange)
        {
            vScrollOffset = 0;
        }

        IList<SchedulerTimelineViewElement> timelineElements = this.GetChildViewElements();
        IList<LightVisualElement> viewSeparators = this.GetViewSeparators();

        List<RectangleF> resourcesBounds = new List<RectangleF>();
        List<RectangleF> separatorsBounds = new List<RectangleF>();

        int scrollBarOffset = 0;

        if (timelineElements.Count > 0)
        {
            if (timelineElements[timelineElements.Count - 1].NavigationElement.Visibility == ElementVisibility.Visible)
            {
                scrollBarOffset = 17;
            }
        }

        int headerHeight = 0;
        if (timelineElements.Count > 0 && timelineElements[0].Header.Visibility != ElementVisibility.Collapsed)
        {
            headerHeight = timelineElements[0].ViewHeaderHeight + timelineElements[0].ColumnHeaderHeight;
        }
        FieldInfo fi = typeof(TimelineGroupingByResourcesElement).GetField("leftCell", BindingFlags.Instance | BindingFlags.NonPublic);
        SchedulerCellElement leftCell = fi.GetValue(this) as SchedulerCellElement;
        FieldInfo fi2 = typeof(TimelineGroupingByResourcesElement).GetField("bottomCell", BindingFlags.Instance | BindingFlags.NonPublic);
        SchedulerCellElement bottomCell = fi2.GetValue(this) as SchedulerCellElement;
        if (leftCell != null)
        {
            RectangleF arrangeRectangle = new RectangleF(0, 0, ResourceHeaderWidth, headerHeight);
            if (this.RightToLeft)
            {
                arrangeRectangle = LayoutUtils.RTLTranslateNonRelative(arrangeRectangle, contentRect);
            }

            leftCell.Arrange(arrangeRectangle);
        }

        if (bottomCell != null)
        {
            RectangleF arrangeRectangle = new RectangleF(0, finalSize.Height - scrollBarOffset, ResourceHeaderWidth, scrollBarOffset);
            if (this.RightToLeft)
            {
                arrangeRectangle = LayoutUtils.RTLTranslateNonRelative(arrangeRectangle, contentRect);
            }

            bottomCell.Arrange(arrangeRectangle);
        }

        float separatorsWidth = this.View.GroupSeparatorWidth * (this.View.ResourcesPerView - 1);
        float resourcesHeight = finalSize.Height - separatorsWidth - headerHeight ;
        float y = 0;

        for (int i = 0; i < timelineElements.Count; i++)
        {
            SchedulerTimelineViewElement timelineElement = timelineElements[i];
            LightVisualElement separator = i < viewSeparators.Count ? viewSeparators[i] : null;

            if (timelineElement != null)
            {
                float calculatedHeight = this.GetResourceSize(i, resourcesHeight);
                RectangleF arrangeRect = new RectangleF(this.ResourceHeaderWidth, y,
                    finalSize.Width - this.ResourceHeaderWidth - vScrollOffset, calculatedHeight);

                if (i == 0)
                {
                    arrangeRect.Height += headerHeight;
                }
                else if (i == timelineElements.Count - 1)
                {
                    arrangeRect.Height = finalSize.Height - arrangeRect.Top - 1;
                }

                if (this.RightToLeft)
                {
                    arrangeRect = LayoutUtils.RTLTranslateNonRelative(arrangeRect, contentRect);
                }

                timelineElement.Arrange(arrangeRect);

                y += arrangeRect.Height;

                if (i == 0)
                {
                    arrangeRect.Height -= headerHeight;
                }
                else
                {
                    arrangeRect.Y -= headerHeight;
                }

                resourcesBounds.Add(arrangeRect);
            }

            if (separator != null)
            {
                float calculatedHeight = this.View.GroupSeparatorWidth;
                RectangleF arrangeRect = new RectangleF(this.ResourceHeaderWidth, y,
                    finalSize.Width - this.ResourceHeaderWidth - vScrollOffset, calculatedHeight);
                if (this.RightToLeft)
                {
                    arrangeRect = LayoutUtils.RTLTranslateNonRelative(arrangeRect, contentRect);
                }

                separator.Arrange(arrangeRect);
                arrangeRect.Y -= headerHeight;
                separatorsBounds.Add(arrangeRect);
                y += calculatedHeight;
            }
        }

        if (this.ResourcesHeader != null)
        {
            RectangleF arrangeRectangle = new RectangleF(0, headerHeight,
                this.ResourceHeaderWidth, finalSize.Height - scrollBarOffset - headerHeight);
            if (this.RightToLeft)
            {
                arrangeRectangle = LayoutUtils.RTLTranslateNonRelative(arrangeRectangle, contentRect);
            }
            this.ResourcesHeader.SetResourcesLayoutInfo(resourcesBounds, separatorsBounds);
            this.ResourcesHeader.Arrange(arrangeRectangle);
        }

        if (this.View.AllowResourcesScrolling)
        {
            RectangleF scrollbarRect = new RectangleF(finalSize.Width - vScrollOffset,
                0, vScrollOffset, finalSize.Height - scrollBarOffset);
            if (this.RightToLeft)
            {
                scrollbarRect = LayoutUtils.RTLTranslateNonRelative(scrollbarRect, contentRect);
            }

            this.VScrollBar.Arrange(scrollbarRect);
        }
        else
        {
            this.VScrollBar.Arrange(RectangleF.Empty);
        }

        return finalSize;
    }
}
0 comments