RangeControlAdjustEventArgs.Scales Property

Provides access to the collection of scales that will be visible in the RangeControl after it is automatically adjusted.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v20.1.Core.dll

Declaration

public TimeScaleCollection Scales { get; }
Public ReadOnly Property Scales As TimeScaleCollection

Property Value

Type Description
TimeScaleCollection

A TimeScaleCollection object specifying a set of RangeControl scales.

Remarks

Handle the SchedulerControl.RangeControlAutoAdjusting event and use the Scales property to customize a scale collection of the RangeControl before it is displayed when auto-adjusting is applied (see the SchedulerOptionsRangeControl.AutoAdjustMode property). For example, you can specify your own collection of scales for each scheduler view. The specified scale collections will be automatically switched when an end-user changes the scheduler active view.

By default, the following scale collections are displayed in the RangeControl when an end-user changes a view within the SchedulerControl, if the SchedulerOptionsRangeControl.AutoAdjustMode property is set to true:

Scheduler View RangeControl scales
Day View, Work-Week View The Day and Week scales
Week View, Month View The Week and Month scales
Timeline View, Gantt View Scales that are currently visible in the scheduler view

Examples

This example demonstrates how to customize the auto-adjusting settings before they are applied to the RangeControl when an end-user switches the scheduler to the Work-Week or Month view.

  1. Set the SchedulerOptionsRangeControl.AutoAdjustMode option to true.
  2. Handle the SchedulerControl.RangeControlAutoAdjusting event. In this event handler, specify the RangeControl scales and range to be set when the Work-Week or Month view becomes active in the following way:

using System;
using System.Windows.Forms;
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Native;

namespace WindowsFormsApplication1 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void schedulerControl1_RangeControlAutoAdjusting(object sender,
                                                                RangeControlAdjustEventArgs e) {
            schedulerControl.OptionsRangeControl.AutoFormatScaleCaptions = true;
            SchedulerViewType activeViewType = schedulerControl.ActiveViewType;

            if (activeViewType == SchedulerViewType.WorkWeek) {
                schedulerControl.OptionsRangeControl.AutoFormatScaleCaptions = false;
                e.Scales[4].DisplayFormat = "dddd";
                e.Scales[4].Width = 70;
            }

            if (activeViewType == SchedulerViewType.Month) {
                schedulerControl.OptionsRangeControl.AutoFormatScaleCaptions = false;

                e.Scales.Clear();

                TimeScaleMonth monthScale = new TimeScaleMonth();
                monthScale.DisplayFormat = "MMMM yyyy";
                e.Scales.Add(monthScale);

                TwoWeekTimeScale twoWeekTimeScale = new TwoWeekTimeScale();
                twoWeekTimeScale.Width = 120;
                e.Scales.Add(twoWeekTimeScale);

                e.RangeMinimum = new DateTime(e.RangeMinimum.Year, 1, 1);
                e.RangeMaximum = e.RangeMinimum.AddYears(1);
            }
        }
    }

    public class TwoWeekTimeScale : TimeScaleFixedInterval {
        public TwoWeekTimeScale()
            : base(TimeSpan.FromDays(14)) {
        }
        public override DateTime Floor(DateTime date) {
            DateTime startOfWeeek = DateTimeHelper.GetStartOfWeekUI(date,
                                                                    DateTimeHelper.FirstDayOfWeek);
            if (DateTimeHelper.GetWeekOfYear(date) % 2 == 0)
                return startOfWeeek.AddDays(-7);

            return startOfWeeek;
        }
        public override string FormatCaption(DateTime start, DateTime end) {
            string dateString = "Week {0} - Week {1}";
            return String.Format(dateString, DateTimeHelper.GetWeekOfYear(start),
                                 DateTimeHelper.GetWeekOfYear(end.AddTicks(-1)));
        }
    }
}
See Also