Exemple #1
0
 /// <summary>
 /// Adds the specified unit as a passing unit
 /// </summary>
 /// <param name="calendarTimeScaleUnit"></param>
 internal void AddUnitPassing(CalendarTimeScaleUnit calendarTimeScaleUnit)
 {
     if (!UnitsPassing.Contains(calendarTimeScaleUnit))
     {
         UnitsPassing.Add(calendarTimeScaleUnit);
     }
 }
Exemple #2
0
        /// <summary>
        /// Updates the value of <see cref="TimeUnits"/> property
        /// </summary>
        internal void UpdateUnits()
        {
            var factor = 0;

            switch (Calendar.TimeScale)
            {
            case CalendarTimeScale.SixtyMinutes:
                factor = 1;
                break;

            case CalendarTimeScale.ThirtyMinutes:
                factor = 2;
                break;

            case CalendarTimeScale.FifteenMinutes:
                factor = 4;
                break;

            case CalendarTimeScale.TenMinutes:
                factor = 6;
                break;

            case CalendarTimeScale.SixMinutes:
                factor = 10;
                break;

            case CalendarTimeScale.FiveMinutes:
                factor = 12;
                break;

            default:
                throw new NotImplementedException("TimeScale not supported");
            }

            _timeUnits = new CalendarTimeScaleUnit[24 * factor];

            var hourSum = 0;
            var minSum  = 0;

            for (var i = 0; i < _timeUnits.Length; i++)
            {
                _timeUnits[i] = new CalendarTimeScaleUnit(this, i, hourSum, minSum);

                minSum += 60 / factor;

                if (minSum >= 60)
                {
                    minSum = 0;
                    hourSum++;
                }
            }

            UpdateHighlights();
        }
        public override void OnDrawTimeScale(CalendarRendererEventArgs e)
        {
            int margin  = 5;
            int largeX1 = TimeScaleBounds.Left + margin;
            int largeX2 = TimeScaleBounds.Right - margin;
            int shortX1 = TimeScaleBounds.Left + TimeScaleBounds.Width / 2;
            int shortX2 = largeX2;
            int top     = 0;
            Pen p       = new Pen(ColorTable.TimeScaleLine);

            for (int i = 0; i < e.Calendar.Days[0].TimeUnits.Length; i++)
            {
                CalendarTimeScaleUnit unit = e.Calendar.Days[0].TimeUnits[i];

                if (!unit.Visible)
                {
                    continue;
                }

                top = unit.Bounds.Top;

                if (unit.Minutes == 0)
                {
                    e.Graphics.DrawLine(p, largeX1, top, largeX2, top);
                }
                else
                {
                    e.Graphics.DrawLine(p, shortX1, top, shortX2, top);
                }
            }

            if (e.Calendar.DaysMode == CalendarDaysMode.Expanded &&
                e.Calendar.Days != null &&
                e.Calendar.Days.Length > 0 &&
                e.Calendar.Days[0].TimeUnits != null &&
                e.Calendar.Days[0].TimeUnits.Length > 0
                )
            {
                top = e.Calendar.Days[0].BodyBounds.Top;

                //Timescale top line is full
                e.Graphics.DrawLine(p, TimeScaleBounds.Left, top, TimeScaleBounds.Right, top);
            }

            p.Dispose();

            base.OnDrawTimeScale(e);
        }
 /// <summary>
 /// Comparison delegate to sort units
 /// </summary>
 /// <param name="item1"></param>
 /// <param name="item2"></param>
 /// <returns></returns>
 private static int CompareUnits(CalendarTimeScaleUnit item1, CalendarTimeScaleUnit item2)
 {
     return item1.Date.CompareTo(item2.Date);
 }
 /// <summary>
 /// Ivalidates the bounds of the specified unit
 /// </summary>
 /// <param name="unit"></param>
 public void Invalidate(CalendarTimeScaleUnit unit)
 {
     Invalidate(unit.Bounds);
 }
        /// <summary>
        /// Ensures the scrolling shows the specified time unit. It doesn't affect View date ranges.
        /// </summary>
        /// <param name="unit">Unit to ensure visibility</param>
        public void EnsureVisible(CalendarTimeScaleUnit unit)
        {
            if (Days == null || Days.Length == 0) return;

            Rectangle view = Days[0].BodyBounds;

            if (unit.Bounds.Bottom > view.Bottom)
            {
                TimeUnitsOffset = -Convert.ToInt32(Math.Ceiling(unit.Date.TimeOfDay.TotalMinutes / (double)TimeScale))
                     + Renderer.GetVisibleTimeUnits();
            }
            else if (unit.Bounds.Top < view.Top)
            {
                TimeUnitsOffset = -Convert.ToInt32(Math.Ceiling(unit.Date.TimeOfDay.TotalMinutes / (double)TimeScale));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CalendarRendererTimeUnitEventArgs"/> class.
 /// </summary>
 /// <param name="original">The <see cref="System.Windows.Forms.Calendar.CalendarRendererEventArgs"/> instance containing the event data.</param>
 /// <param name="unit">The unit.</param>
 public CalendarRendererTimeUnitEventArgs(CalendarRendererEventArgs original, CalendarTimeScaleUnit unit)
     : base(original)
 {
     _unit = unit;
 }
Exemple #8
0
        /// <summary>
        /// Updates the value of <see cref="TimeUnits"/> property
        /// </summary>
        internal void UpdateUnits()
        {
            int factor = 0;

            switch (Calendar.TimeScale)
            {
                case CalendarTimeScale.SixtyMinutes:    factor = 1;     break;
                case CalendarTimeScale.ThirtyMinutes:   factor = 2;     break;
                case CalendarTimeScale.FifteenMinutes:  factor = 4;     break;
                case CalendarTimeScale.TenMinutes:      factor = 6;     break;
                case CalendarTimeScale.SixMinutes:      factor = 10;    break;
                case CalendarTimeScale.FiveMinutes:     factor = 12;    break;
                default: throw new NotImplementedException("TimeScale not supported");
            }

            _timeUnits = new CalendarTimeScaleUnit[24 * factor];
            
            int hourSum = 0;
            int minSum = 0;

            for (int i = 0; i < _timeUnits.Length; i++)
            {
                _timeUnits[i] = new CalendarTimeScaleUnit(this, i, hourSum, minSum);

                minSum += 60 / factor;

                if (minSum >= 60)
                {
                    minSum = 0;
                    hourSum++;
                }
            }

            UpdateHighlights();
        }
 /// <summary>
 /// Adds the specified unit as a passing unit
 /// </summary>
 /// <param name="calendarTimeScaleUnit"></param>
 internal void AddUnitPassing(CalendarTimeScaleUnit calendarTimeScaleUnit)
 {
     if (!UnitsPassing.Contains(calendarTimeScaleUnit))
     {
         UnitsPassing.Add(calendarTimeScaleUnit);
     }
 }
 public CalendarRendererTimeUnitEventArgs(CalendarRendererEventArgs original, CalendarTimeScaleUnit unit)
     : base(original)
 {
     _unit = unit;
 }