Ignore:
Timestamp:
Aug 17, 2010, 8:50:19 AM (14 years ago)
Author:
Sam Habiel
Message:

CGAVDocument contains changes for start day of grid based on weekday locale and colummns
CGAVView: Shortcut keys; correct updating when number of columns is changed in grid
CGDocument: changes for start day of grid. Modified algorithm.
DAccessTemplate: Takes any weekday now for applying a template, not just Monday. Then calculation of start day is done in CGAVView based on locale in the same algorithm that the rest of the GUI uses.
DAppointPage: Now says Mobile/Cell instead of Cell Phone.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGAVDocument.cs

    r864 r913  
    401401                }
    402402
    403                 /// <summary>
    404                 /// Given a selected date,
    405                 /// Calculates StartDay and End Day and returns them in output params. 
    406                 /// nWeeks == number of Weeks to display
    407                 /// nColumnCount is number of days displayed per week.  If 5 columns, begin on
    408                 /// Monday, if 7 Columns, begin on Sunday
    409                 ///
    410                 /// Returns TRUE if the document's data needs refreshing based on
    411                 /// this newly selected date.
    412                 /// </summary>
     403        /// <summary>
     404        /// Given a selected date,
     405        /// Calculates StartDay and End Day and returns them in output params. 
     406        /// nWeeks == number of Weeks to display
     407        /// nColumnCount is number of days displayed per week. 
     408        /// If 5 columns, begin on Second Day of Week
     409        /// If 7 Columns, begin on First Day of Week
     410        /// (this is a change from the hardcoded behavior for US-based calendars)
     411        ///
     412        /// Returns TRUE if the document's data needs refreshing based on
     413        /// this newly selected date.
     414        /// </summary>
     415        /// TODO: This is a duplicate of the method in CGDocument. We need to put them together.
    413416                public bool WeekNeedsRefresh(int nWeeks, DateTime SelectedDate,
    414417                        out DateTime WeekStartDay, out DateTime WeekEndDay)
    415418                {
    416                         DateTime OldStartDay = m_dStartDate;
    417                         DateTime OldEndDay = m_dEndDate;
    418                         int nWeekDay = (int) SelectedDate.DayOfWeek; //0 == Sunday
    419 
    420                         int nOff = 1;
    421                         TimeSpan ts = new TimeSpan(nWeekDay - nOff,0,0,0); //d,h,m,s
    422 
    423                         if (m_nColumnCount == 1)
    424                         {
    425                                 ts = new TimeSpan(0,23,59,59);
    426                                 WeekStartDay = SelectedDate;
    427                         }
    428                         else
    429                         {
    430                                 WeekStartDay = SelectedDate - ts;
    431                                 if (m_nColumnCount == 7)
    432                                 {
    433                                         ts = new TimeSpan(1,0,0,0);
    434                                         WeekStartDay -= ts;
    435                                 }
    436                                 int nEnd = (m_nColumnCount == 7) ? 1 : 3;
    437                                 ts = new TimeSpan((7* nWeeks) - nEnd, 23, 59,59);
    438                         }
    439                         WeekEndDay = WeekStartDay + ts;
    440                         bool bRet = (( WeekStartDay.Date != OldStartDay.Date) || (WeekEndDay.Date != OldEndDay.Date));
    441                         return bRet;
     419            DateTime OldStartDay = m_dStartDate;
     420            DateTime OldEndDay = m_dEndDate;
     421            // Week start based on thread locale
     422            int nStartWeekDay = (int)System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
     423            // Current Day
     424            int nWeekDay = (int)SelectedDate.DayOfWeek; //0 == Sunday
     425
     426            // this offset gets approrpriate day based on locale.
     427            int nOff = (nStartWeekDay + 1) % 7;
     428            TimeSpan ts = new TimeSpan(nWeekDay - nOff, 0, 0, 0); //d,h,m,s
     429
     430            // if ts is negative, we will jump to the next week in the logic.
     431            // to show the correct week, add 7. Confusing, I know.
     432            if (ts < new TimeSpan()) ts = ts + new TimeSpan(7, 0, 0, 0);
     433
     434            if (m_nColumnCount == 1) // if one column start and end on the same day.
     435            {
     436                ts = new TimeSpan(0, 23, 59, 59);
     437                WeekStartDay = SelectedDate;
     438                WeekEndDay = WeekStartDay + ts;
     439            }
     440            else if (m_nColumnCount == 5 || m_nColumnCount == 0) // if 5 column start (or default) at the 2nd day of this week and end in 4:23:59:59 days.
     441            {
     442                // if picked day is start of week (Sunday in US), start in the next day since that's the first day of work week
     443                // else, just substract the calculated time span to get to the start of week (first work day)
     444                WeekStartDay = (nWeekDay == nStartWeekDay) ? SelectedDate + new TimeSpan(1, 0, 0, 0) : SelectedDate - ts;
     445                // End day calculation
     446                int nEnd = 3;
     447                ts = new TimeSpan((7 * nWeeks) - nEnd, 23, 59, 59);
     448                WeekEndDay = WeekStartDay + ts;
     449            }
     450            else // if 7 column start at the 1st day of this week and end in 6:23:59:59 days.
     451            {
     452                // if picked day is start of week, use that. Otherwise, go to the fist work day and substract one to get to start of week.
     453                WeekStartDay = (nWeekDay == nStartWeekDay) ? SelectedDate : SelectedDate - ts - new TimeSpan(1, 0, 0, 0);
     454                // End day calculation
     455                int nEnd = 1;
     456                ts = new TimeSpan((7 * nWeeks) - nEnd, 23, 59, 59);
     457                WeekEndDay = WeekStartDay + ts;
     458            }
     459
     460            bool bRet = ((WeekStartDay.Date != OldStartDay.Date) || (WeekEndDay.Date != OldEndDay.Date));
     461            return bRet;
    442462                }
    443463
Note: See TracChangeset for help on using the changeset viewer.