//Calculate points for a day given the date and the tour name. public static double GetPointsForDay(Day d) { var dayType = d.Date.DayOfWeek; var tourType = d.Notes; if (tourType != null) { switch (dayType) { case DayOfWeek.Sunday: if (tourType.ToLower() == "a") { return Rules.SundayA; } else if (tourType.ToLower() == "c") { return Rules.SundayC; } else if (tourType.ToLower() == "n") { return Rules.SundayN; } break; case DayOfWeek.Monday: if (tourType.ToLower() == "a") { return Rules.MondayA; } else if (tourType.ToLower() == "c") { return Rules.MondayC; } else if (tourType.ToLower() == "n") { return Rules.MondayN; } break; case DayOfWeek.Tuesday: if (tourType.ToLower() == "a") { return Rules.TusedayA; } else if (tourType.ToLower() == "c") { return Rules.TusedayC; } else if (tourType.ToLower() == "n") { return Rules.TusedayN; } break; case DayOfWeek.Wednesday: if (tourType.ToLower() == "a") { return Rules.WednesdayA; } else if (tourType.ToLower() == "c") { return Rules.WednesdayC; } else if (tourType.ToLower() == "n") { return Rules.WednesdayN; } break; case DayOfWeek.Thursday: if (tourType.ToLower() == "a") { return Rules.ThursdayA; } else if (tourType.ToLower() == "c") { return Rules.ThursdayC; } else if (tourType.ToLower() == "n") { return Rules.ThursdayN; } break; case DayOfWeek.Friday: if (tourType.ToLower() == "a") { return Rules.FridayA; } else if (tourType.ToLower() == "c") { return Rules.FridayC; } else if (tourType.ToLower() == "n") { return Rules.FridayN; } break; case DayOfWeek.Saturday: if (tourType.ToLower() == "a") { return Rules.SaturdayA; } else if (tourType.ToLower() == "c") { return Rules.SaturdayC; } else if (tourType.ToLower() == "n") { return Rules.SaturdayN; } break; default: //nop break; } } return 0.0; }
public void BuildCalendar(DateTime targetDate) { Days.Clear(); //Calculate when the first day of the month is and work out an //offset so we can fill in any boxes before that. DateTime d = new DateTime(targetDate.Year, targetDate.Month, 1); int offset = DayOfWeekNumber(d.DayOfWeek); if (offset != 1) d = d.AddDays(-offset); //Show 6 weeks each with 7 days = 42 for (int box = 1; box <= 42; box++) { Day day = new Day {Date = d, Enabled = true, IsTargetMonth = targetDate.Month == d.Month}; day.PropertyChanged += Day_Changed; day.IsToday = d == DateTime.Today; Days.Add(day); d = d.AddDays(1); } }
private void Calendar_DayChanged(object sender, DayChangedEventArgs e) { //if ( currentDay!=null) currentDay.PropertyChanged -= Day_PropertyChanged; currentDay = e.Day; currentDay.PropertyChanged += Day_PropertyChanged; }
public DayChangedEventArgs(Day day) { this.Day = day; }