internal int StartTimeToRow(DateTime time)
        {
            int row = -1;

            switch (TimeView)
            {
            case TimePeriodType.Monthly:
                // row denotes day in month
                row = (int)Math.Floor(time.Subtract(TimePeriodStart.ToFirstDayOfMonth().ToMidnight()).TotalDays);
                break;

            case TimePeriodType.DailyHourly:
                // row denotes hour of day
                row = (int)Math.Ceiling(time.Subtract(TimePeriodStart.ToMidnight()).TotalHours);
                break;

            case TimePeriodType.DailyHalfHourly:
                // row denotes 30'th minute of day
                row = (int)Math.Ceiling(time.Subtract(TimePeriodStart.ToMidnight()).TotalHours * 2.0f);
                break;

            case TimePeriodType.DailyQuaterHourly:
                // row denotes 15'th minute of
                row = (int)Math.Ceiling(time.Subtract(TimePeriodStart.ToMidnight()).TotalHours * 4.0f);
                break;

            default:
                throw new SoftwareException("Internal error. Unsupported time period type {0}", TimeView);
            }
            return(row);
        }
        internal DateTime RowToStartTime(int row)
        {
            DateTime time;

            switch (TimeView)
            {
            case TimePeriodType.Monthly:
                // row denotes day in month
                time = TimePeriodStart.ToFirstDayOfMonth().ToMidnight().AddDays(row);
                break;

            case TimePeriodType.DailyHourly:
                // row denotes hour of day
                time = TimePeriodStart.ToMidnight().AddHours(row);
                break;

            case TimePeriodType.DailyHalfHourly:
                // row denotes 30'th minute of day
                time = TimePeriodStart.ToMidnight().AddMinutes(row * 30.0);
                break;

            case TimePeriodType.DailyQuaterHourly:
                // row denotes 15'th minute of
                time = TimePeriodStart.ToMidnight().AddMinutes(row * 15.0);
                break;

            default:
                throw new SoftwareException("Internal error. Unsupported time period type {0}", TimeView);
            }
            return(time);
        }