lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
Quintiq file version 2.0
#parent: #root
Method InitializeRecurrencePattern (
  shadow[LibCal_RecurrencePattern] sRecurrencePattern_i,
  Date startDate_i
) id:Method_LibCal_dlgEvent_InitializeRecurrencePattern
{
  #keys: '[131092.0.2141055344]'
  Body:
  [*
    // First initialize everything as new...
    this.InitializeRecurrencePatternAsNew( startDate_i );
    
    // ... then take over the existing pattern (if applicable)
    if( not isnull( sRecurrencePattern_i ) )
    {
      // Daily
      if( sRecurrencePattern_i.istype( shadow[LibCal_RecurrencePatternDaily] ) )
      {
        pattern := sRecurrencePattern_i.astype( shadow[LibCal_RecurrencePatternDaily] );
    
        edtEveryNrOfDays.Text( [String]pattern.RecurrenceInterval() );
        ckbEveryWeekday.Checked( pattern.IsEveryWeekday() );
        
        this.ToggleRecurrencePattern( LibCal_RecurrencePattern::TYPE_DAILY() );
      }
      
      // Weekly
      else if( sRecurrencePattern_i.istype( shadow[LibCal_RecurrencePatternWeekly] ) )
      {
        pattern := sRecurrencePattern_i.astype( shadow[LibCal_RecurrencePatternWeekly] );
    
        edtEveryNrOfWeeks.Text( [String]pattern.RecurrenceInterval() );
    
        btnMonday   .IsPressed( pattern.Monday()    );
        btnTuesday  .IsPressed( pattern.Tuesday()   );
        btnWednesday.IsPressed( pattern.Wednesday() );
        btnThursday .IsPressed( pattern.Thursday()  );
        btnFriday   .IsPressed( pattern.Friday()    );
        btnSaturday .IsPressed( pattern.Saturday()  );
        btnSunday   .IsPressed( pattern.Sunday()    );
        
        this.ToggleRecurrencePattern( LibCal_RecurrencePattern::TYPE_WEEKLY() );
      }
    
      // Monthly
      else if( sRecurrencePattern_i.istype( shadow[LibCal_RecurrencePatternMonthly] ) )
      {
        pattern := sRecurrencePattern_i.astype( shadow[LibCal_RecurrencePatternMonthly] );
    
        // Specific day    
        ckbMonthlyDay.Checked( pattern.IsDay() );
    
        if( pattern.Day() <> 0 )
        {
          edtMonthlyDay.Text( [String]pattern.Day() );
        }
        edtMonthlyDayEveryNrOfMonths.Text( [String]pattern.RecurrenceInterval() );
        
        // Pattern
        ckbMonthlyPattern.Checked( not pattern.IsDay() );
    
        if( pattern.PatternWeekOfMonth() <> "" and
            pattern.PatternDayOfWeek()   <> "" )
        {
          ssMonthlyPatternWeekOfMonth.Text( pattern.PatternWeekOfMonth() );
          ssMonthlyPatternDayOfWeek  .Text( pattern.PatternDayOfWeek()   );
        }
        edtMonthlyPatternEveryNrOfMonths.Text( [String]pattern.RecurrenceInterval() );
    
        this.ToggleRecurrencePattern( LibCal_RecurrencePattern::TYPE_MONTHLY() );
      }
    
      // Yearly
      else if( sRecurrencePattern_i.istype( shadow[LibCal_RecurrencePatternYearly] ) )
      {
        pattern := sRecurrencePattern_i.astype( shadow[LibCal_RecurrencePatternYearly] );
    
        edtEveryNrOfYears.Text( [String]pattern.RecurrenceInterval() );
    
        // Specific day
        ckbYearlyDay.Checked( pattern.IsDay() );
        if( pattern.Month() <> 0 and pattern.Day() <> 0 )
        {
          this.SetYearlyMonthAndDay( pattern.Month(), pattern.Day() );
        }
    
        // Pattern
        ckbYearlyPattern.Checked( not pattern.IsDay() );
        if( pattern.PatternWeekOfMonth() <> "" and
            pattern.PatternDayOfWeek()   <> "" )
        {
          ssYearlyPatternWeekOfMonth.Text( pattern.PatternWeekOfMonth() );
          ssYearlyPatternDayOfWeek  .Text( pattern.PatternDayOfWeek()   );
          
          if( pattern.Month() <> 0 )
          {
            this.SetYearlyPatternMonth( pattern.Month() );
          }
        }
        
        this.ToggleRecurrencePattern( LibCal_RecurrencePattern::TYPE_YEARLY() );
      }
    }
    
    else  // Event is not recurring.
    {
      this.ToggleRecurrencePattern( LibCal_RecurrencePattern::TYPE_NONE() );
    }
  *]
}