예제 #1
0
 private void ShowDayName()
 {
     clockGrid.RepresentingDate = Date;
     dateNumber.DisplayText     = _day.ToString();
     dateNumber.IsDayOne        = _day == 1;
     dayHeader.DisplayText      = CalendarHelpers.DayOfWeek(CalendarHelpers.DayOfWeek(_year, _month, _day)).ToUpper();
 }
예제 #2
0
        private void FocusDate(int d)
        {
            int beginningOfMonth = CalendarHelpers.DayOfWeek(_year, _month, 1);

            RadioButton button = grid.Children[9 + beginningOfMonth + d] as RadioButton;

            if (button.IsChecked == false)
            {
                _suppressCheck   = true;
                button.IsChecked = true;
            }
        }
예제 #3
0
        private void InitializeNewDisplay()
        {
            removeRecurrenceButton.IsEnabled = false;
            startDate.SelectedDate           = _appointment.StartDate;

            int dow = CalendarHelpers.DayOfWeek(_appointment.StartDate.DayOfWeek);

            ((ToggleButton)weeklyGrid.Children[dow - 1]).IsChecked = true;

            yearlyRadio1Text1.Text           = monthlyRadio1Text1.Text = _appointment.StartDate.Day.ToString();
            yearlyRadio2Combo1.SelectedIndex = monthlyRadio2Combo1.SelectedIndex = CalendarHelpers.Week(_appointment.StartDate) - 1;
            yearlyRadio2Combo2.SelectedIndex = monthlyRadio2Combo2.SelectedIndex = CalendarHelpers.DayOfWeek(_appointment.StartDate.DayOfWeek) + 2;
            yearlyRadio1Combo1.SelectedIndex = yearlyRadio2Combo3.SelectedIndex = _appointment.StartDate.Month - 1;

            dailyRadio1Text1.Text = "1";
            weeklyText1.Text      = "1";
            monthlyText1.Text     = "1";
            yearlyText1.Text      = "1";
            rangeRadio2Text1.Text = "10";
        }
예제 #4
0
        private void InitializeLayout()
        {
            title.Text = CalendarHelpers.Month(_month) + " " + _year.ToString();

            int beginningOfMonth = CalendarHelpers.DayOfWeek(_year, _month, 1);
            int daysInMonth      = CalendarHelpers.DaysInMonth(_month, _year);

            int row    = 2;
            int column = 0;

            int counter = 0;

            bool hasBegin = DisplayDateStart != null;
            bool hasEnd   = DisplayDateEnd != null;

            //
            // Previous month
            //
            int prevMonth     = _month > 1 ? _month - 1 : 12;
            int prevYear      = _month > 1 ? _year : _year - 1;
            int daysLastMonth = CalendarHelpers.DaysInMonth(prevMonth, prevYear);

            for (int i = beginningOfMonth - 2; i >= 0; i--)
            {
                RadioButton text = new RadioButton();
                text.Style   = FindResource("DateButton") as Style;
                text.Opacity = 0.5;
                text.Content = (daysLastMonth - i).ToString();

                DateTime dt = new DateTime(prevYear, prevMonth, daysLastMonth - i);

                if (!hasEnd || (DateTime)DisplayDateEnd >= dt)
                {
                    if (!hasBegin || (DateTime)DisplayDateStart <= dt)
                    {
                        text.Tag               = dt;
                        text.Checked          += text_Checked;
                        text.MouseDoubleClick += text_MouseDoubleClick;
                    }
                    else
                    {
                        text.IsEnabled = false;
                    }
                }
                else
                {
                    text.IsEnabled = false;
                }

                Grid.SetRow(text, row);
                Grid.SetColumn(text, column);
                grid.Children.Add(text);

                if (column < 6)
                {
                    column++;
                }
                else
                {
                    column = 0;
                    row++;
                }

                counter++;
            }

            //
            // This month
            //
            for (int i = 1; i <= daysInMonth; i++)
            {
                RadioButton text = new RadioButton();
                text.Style   = FindResource("DateButton") as Style;
                text.Content = i.ToString();

                DateTime dt = new DateTime(_year, _month, i);
                InitRadioButton(hasBegin, hasEnd, dt, text, ref row, ref column);

                counter++;
            }

            //
            // Next month
            //
            int nextMonth = _month < 12 ? _month + 1 : 1;
            int nextYear  = _month < 12 ? _year : _year + 1;

            for (int i = 1; i <= 42 - counter; i++)
            {
                RadioButton text = new RadioButton();
                text.Style   = FindResource("DateButton") as Style;
                text.Opacity = 0.5;
                text.Content = i.ToString();

                DateTime dt = new DateTime(nextYear, nextMonth, i);
                InitRadioButton(hasBegin, hasEnd, dt, text, ref row, ref column);
            }
        }