Пример #1
0
        private void setYearMode()
        {
            this.monthUniformGrid.Visibility = this.decadeUniformGrid.Visibility = Visibility.Collapsed;
            this.yearUniformGrid.Visibility  = Visibility.Visible;

            this.titleButton.Content = this.DisplayDate.Year.ToString();

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    int month = j + i * 3 + 1;
                    if (new PersianDate(DisplayDate.Year, month, PersianDate.DaysInMonth(DisplayDate.Year, month)) >= DisplayDateStart &&
                        new PersianDate(DisplayDate.Year, month, 1) <= DisplayDateEnd)
                    {
                        yearModeButtons[i, j].Content   = ((PersianMonth)month).ToString();
                        yearModeButtons[i, j].IsEnabled = true;
                    }
                    else
                    {
                        yearModeButtons[i, j].Content   = "";
                        yearModeButtons[i, j].IsEnabled = false;
                    }
                }
            }
        }
Пример #2
0
        private void previousButton_Click(object sender, RoutedEventArgs e)
        {
            int m = this.DisplayDate.Month;
            int y = this.DisplayDate.Year;

            try
            {
                PersianDate newDisplayDate = DisplayDate;

                if (this.DisplayMode == CalendarMode.Month)
                {
                    if (m == 1)
                    {
                        newDisplayDate = new PersianDate(y - 1, 12, PersianDate.DaysInMonth(y - 1, 12));
                    }
                    else
                    {
                        newDisplayDate = new PersianDate(y, m - 1, PersianDate.DaysInMonth(y, m - 1));
                    }
                }
                else if (this.DisplayMode == CalendarMode.Year)
                {
                    newDisplayDate = new PersianDate(y - 1, 12, PersianDate.DaysInMonth(y - 1, 12));
                }
                else if (this.DisplayMode == CalendarMode.Decade)
                {
                    newDisplayDate = new PersianDate(y - y % 10 - 1, 12, PersianDate.DaysInMonth(y - y % 10 - 1, 12));
                }

                if (newDisplayDate >= DisplayDateStart && newDisplayDate <= DisplayDateEnd)
                {
                    this.SetCurrentValue(DisplayDateProperty, newDisplayDate);
                }
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }