Beispiel #1
0
 private void DayComboBoxOnSelectionChanged(object sender, SelectionChangedEventArgs selectionChangedEventArgs)
 {
     if (selectionChangedEventArgs.AddedItems.Any())
     {
         selectedDay = selectionChangedEventArgs.AddedItems[0] as DayElement;
         DateChanged();
     }
 }
Beispiel #2
0
 private void InitializeForDate(DateTime date)
 {
     selectedDay = new DayElement { Number = date.Day, Name = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName(calendar.GetDayOfWeek(new DateTime(date.Year, date.Month, date.Day)))};
     selectedMonth = new MonthElement { Number = date.Month, Name = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(date.Month)};
     selectedYear = date.Year;
     yearTextBox.Text = date.Year.ToString();
 }
Beispiel #3
0
        private void MonthChanged()
        {
            dayComboBox.Items.Clear();

            var daysForMonth = Enumerable.Range(1, calendar.GetDaysInMonth(selectedYear, selectedMonth.Number));
            foreach (var day in daysForMonth)
            {
                var dayName = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedDayName(calendar.GetDayOfWeek(new DateTime(selectedYear, selectedMonth.Number, day)));
                var dayElement = new DayElement { Name = dayName, Number = day };

                dayComboBox.Items.Add(dayElement);
            }

            dayComboBox.SelectedIndex = selectedDay.Number - 1;
        }