Exemplo n.º 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 < 12; i++)
            {
                int month = i + 1;

                if (PersianDate.IsValid(DisplayDate.Year, month, 1) &&
                    new PersianDate(DisplayDate.Year, month, PersianDate.DaysInMonth(DisplayDate.Year, month)) >= DisplayDateStart &&
                    new PersianDate(DisplayDate.Year, month, 1) <= DisplayDateEnd)
                {
                    yearModeButtons[i].Content   = ((PersianMonth)month).ToString();
                    yearModeButtons[i].IsEnabled = true;
                }
                else
                {
                    yearModeButtons[i].Content   = "";
                    yearModeButtons[i].IsEnabled = false;
                }
            }
        }
Exemplo n.º 2
0
        private PersianDate AddYear(int year, int month, int day, int factor)
        {
            year += factor;
            if (!PersianDate.IsValid(year, month, day))
            {
                if (PersianDate.DaysInMonth(year, month) < day)
                {
                    day = PersianDate.DaysInMonth(year, month);
                }
            }

            return(new PersianDate(year, month, day));
        }
Exemplo n.º 3
0
        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            int m = this.DisplayDate.Month;
            int y = this.DisplayDate.Year;

            try
            {
                PersianDate newDisplayDate = DisplayDate;
                if (this.DisplayMode == CalendarType.Month)
                {
                    if (m == 12)
                    {
                        if (PersianDate.IsValid(y + 1, 1, 1))
                        {
                            newDisplayDate = new PersianDate(y + 1, 1, 1);
                        }
                    }
                    else
                    {
                        if (PersianDate.IsValid(y, m + 1, 1))
                        {
                            newDisplayDate = new PersianDate(y, m + 1, 1);
                        }
                    }
                }
                else if (this.DisplayMode == CalendarType.Year)
                {
                    if (PersianDate.IsValid(y + 1, 1, 1))
                    {
                        newDisplayDate = new PersianDate(y + 1, 1, 1);
                    }
                }
                else if (this.DisplayMode == CalendarType.Decade)
                {
                    if (PersianDate.IsValid(y - y % 10 + 10, 1, 1))
                    {
                        newDisplayDate = new PersianDate(y - y % 10 + 10, 1, 1);
                    }
                }

                if (newDisplayDate >= DisplayDateStart && newDisplayDate <= DisplayDateEnd)
                {
                    this.SetCurrentValue(DisplayDateProperty, newDisplayDate);
                }
            }
            catch (ArgumentOutOfRangeException)
            {
            }
        }
Exemplo n.º 4
0
        private PersianDate AddMonth(int year, int month, int day, int factor)
        {
            month += factor;
            if (!PersianDate.IsValid(year, month, day))
            {
                if (month > 12)
                {
                    year++;
                    month = 1;
                }
                else if (month < 1)
                {
                    year--;
                    month = 12;
                }

                if (PersianDate.DaysInMonth(year, month) < day)
                {
                    day = PersianDate.DaysInMonth(year, month);
                }
            }

            return(new PersianDate(year, month, day));
        }