Completed
Last Updated: 12 Jun 2015 10:10 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 08 Apr 2015 15:12
Category: Scheduler/Reminder
Type: Bug Report
0
FIX. RadScheduler - the SchedulerTimescale.DisplayedCellsCount property does not affect the view when custom MinutesTimescale is used and the scheduler is grouped by resources
To reproduce:

RadScheduler radScheduler1 = new RadScheduler();
SchedulerTimelineView timelineView;

public Form1()
{
    InitializeComponent();
   
    this.Controls.Add(radScheduler1);
    radScheduler1.Dock = DockStyle.Fill;

    Color[] colors = new Color[]
    {
        Color.LightYellow, Color.LightYellow, Color.Red,
        Color.LightYellow, Color.LightYellow, Color.Red,
        Color.LightYellow, Color.LightYellow, Color.LightYellow
    };

    for (int i = 0; i < colors.Length; i++)
    {
        Resource resource = new Resource();
        resource.Id = new EventId(i);
        resource.Name = "Room " + (i + 1).ToString();
        resource.Color = colors[i];
        this.radScheduler1.Resources.Add(resource);
    }
  
    radScheduler1.ActiveViewType = SchedulerViewType.Timeline;
    timelineView = radScheduler1.GetTimelineView();    
    
    TenMinutesTimescale tenMinutes = new TenMinutesTimescale();
    timelineView.SchedulerTimescales.Add(tenMinutes);
    tenMinutes.Visible = true;
    this.radScheduler1.GroupType = GroupType.Resource;
    this.button1.Click += button1_Click;
}

public class TenMinutesTimescale : MinutesTimescale
{
    public override int ScalingFactor
    {
        get
        {
            return 10;
        }
    }
}

private void button1_Click(object sender, EventArgs e)
{  
    timelineView.GetScaling().DisplayedCellsCount += 10;
}


Workaround:

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

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

public class MyTimelineHeader:TimelineHeader
{
    public MyTimelineHeader(RadScheduler scheduler, SchedulerView view, 
        SchedulerTimelineViewElement timeLineViewElement) : base(scheduler, view, timeLineViewElement)
    {
    }

    protected override SizeF ArrangeOverride(SizeF finalSize)
    {
        List<SchedulerTimescale> allSortedScale = new List<SchedulerTimescale>();
        allSortedScale.Add(new SchedulerTimescale());
        typeof(TimelineHeader).GetField("allSortedScales",
            System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(this, allSortedScale);
        return base.ArrangeOverride(finalSize);
    }
}

public Form1()
{
    InitializeComponent();

   this.radScheduler1.ElementProvider = new MyElementProvider(this.radScheduler1);
    this.Controls.Add(radScheduler1);
    radScheduler1.Dock = DockStyle.Fill;

    Color[] colors = new Color[]
    {
        Color.LightYellow, Color.LightYellow, Color.Red,
        Color.LightYellow, Color.LightYellow, Color.Red,
        Color.LightYellow, Color.LightYellow, Color.LightYellow
    };

    for (int i = 0; i < colors.Length; i++)
    {
        Resource resource = new Resource();
        resource.Id = new EventId(i);
        resource.Name = "Room " + (i + 1).ToString();
        resource.Color = colors[i];
        this.radScheduler1.Resources.Add(resource);
    }
  
    radScheduler1.ActiveViewType = SchedulerViewType.Timeline;
    timelineView = radScheduler1.GetTimelineView();    
    
    TenMinutesTimescale tenMinutes = new TenMinutesTimescale();
     timelineView.SchedulerTimescales.Insert(0, tenMinutes); 
    //timelineView.SchedulerTimescales.Add(tenMinutes);
    tenMinutes.Visible = true;


    this.radScheduler1.GroupType = GroupType.Resource;
    this.button1.Click += button1_Click;
}
0 comments