Quintiq file version 2.0
#parent: #root
Method ShowAllDay () id:Method_LibCal_dlgEvent_ShowAllDay
{
  #keys: '[131092.0.2119818754]'
  Body:
  [*
    // Show the controls according to the state of ckbAllDay.
    // Keep as is when running in days only mode.
    if( not LibCal_Event::USE_ONLY_DAYS() )
    {
      if( ckbIsAllDay.Checked() )
      {
        // Store the EndDate before updating the StartTime, otherwise setting the StartTime can already have influenced the EndDate.
        endDate := dsEndDate.Date();
        
        // Set to whole day if this is not yet the case.
        if( durStartTimeOfDay.Duration() <> Duration::Zero() )
        {
          durStartTimeOfDay.Duration( Duration::Zero() );
        }
      
        if( durEndTimeOfDay.Duration() <> Duration::Zero() )
        {
          durEndTimeOfDay.Duration( Duration::Zero() );
          dsEndDate.Date( endDate + 1 );
        }
        
        // Disable the controls.
        durStartTimeOfDay.Enabled( false, "All day is selected" );
        durEndTimeOfDay  .Enabled( false, "All day is selected" );
      }
      else
      {
        if( durStartTimeOfDay.Duration() <> dhStartTimeOfDay.Data() )
        {
          durStartTimeOfDay.Duration( dhStartTimeOfDay.Data() );
        }
        
        if( durEndTimeOfDay.Duration() <> dhEndTimeOfDay.Data() )
        {
          durEndTimeOfDay.Duration( dhEndTimeOfDay.Data() );
      
          // During initialization, just take over the value from the DataHolder.
          endDate := dsEndDate.Date();
          if( endDate.IsInfinite() )
          {
            endDate := dhEndDate.Data();
          }
          // See if the EndDate must be corrected.
          else if( dhEndTimeOfDay.Data() <> Duration::Zero() )
          {
            endDate := endDate - 1;
          }
          dsEndDate.Date( endDate );
        }
      
        durStartTimeOfDay.Enabled( true, "" );
        durEndTimeOfDay  .Enabled( true, "" );
      }
    }
  *]
}
