Exemplo n.º 1
0
        private void ResetAndSelectYear(int year)
        {
            if (GrdYearPanel.Children.Count != 15)
            {
                return;
            }

            BtnYearInterval.Content = SelectedDateTime.AddYears(-7).Year + "年 - " + SelectedDateTime.AddYears(7).Year + "年";

            for (int i = -7; i < 8; i++)
            {
                var radio = GrdYearPanel.Children[i + 7] as PURadioButton;
                radio.Content = (year + i) + "年";
                radio.Tag     = year + i;
                if (i == 0)
                {
                    radio.IsChecked = true;
                }

                if (MaxDateTime == null && MinDateTime == null)
                {
                    radio.IsEnabled = true;
                    radio.Opacity   = 1;
                }

                else if (MaxDateTime != null && MinDateTime != null)
                {
                    if ((year + i) <= ((DateTime)MaxDateTime).Year && (year + i) >= ((DateTime)MinDateTime).Year)
                    {
                        radio.IsEnabled = true;
                        radio.Opacity   = 1;
                    }
                    else
                    {
                        radio.IsEnabled = false;
                        radio.Opacity   = 0.2;
                    }
                }
                else if (MaxDateTime != null && (year + i) <= ((DateTime)MaxDateTime).Year)
                {
                    radio.IsEnabled = true;
                    radio.Opacity   = 1;
                }
                else if (MinDateTime != null && (year + i) >= ((DateTime)MinDateTime).Year)
                {
                    radio.IsEnabled = true;
                    radio.Opacity   = 1;
                }
                else
                {
                    radio.IsEnabled = false;
                    radio.Opacity   = 0.2;
                }
            }
        }
Exemplo n.º 2
0
 private void BtnMonthRight_Click(object sender, RoutedEventArgs e)
 {
     if (MaxDateTime == null || SelectedDateTime.AddYears(1) <= MaxDateTime)
     {
         SelectedDateTime = SelectedDateTime.AddYears(1);
     }
     else
     {
         SelectedDateTime = (DateTime)MaxDateTime;
     }
 }
Exemplo n.º 3
0
 private void BtnMonthLeft_Click(object sender, RoutedEventArgs e)
 {
     if (MinDateTime == null || SelectedDateTime.AddYears(-1) >= MinDateTime)
     {
         SelectedDateTime = SelectedDateTime.AddYears(-1);
     }
     else
     {
         SelectedDateTime = (DateTime)MinDateTime;
     }
 }