Esempio n. 1
0
        private void ComboBoxDropDownClosed_Solar(object sender, object e)
        {
            int      solarYear  = comboBoxYears.SelectedIndex + 1970;
            int      solarMonth = comboBoxMonths.SelectedIndex + 1;
            int      solarDay   = comboBoxDays.SelectedIndex + 1;
            DateTime dateTime   = new DateTime(solarYear, solarMonth, solarDay);

            Refresh(dateTime);

            int lunarMonthDays = LunarCalendar.DaysOfLunarMonth(solarYear, solarMonth);

            if (lunarMonthDays == 29)
            {
                comboBoxLunarDays.ItemsSource = datas29LunarDays;
            }//if
            else
            {
                comboBoxLunarDays.ItemsSource = datas30LunarDays;
            }//else
            int daysOfSolarMonth = DaysOfSolarMonth(solarYear, solarMonth);

            switch (daysOfSolarMonth)
            {
            case 28: comboBoxDays.ItemsSource = datas28Days; break;

            case 29: comboBoxDays.ItemsSource = datas29Days; break;

            case 30: comboBoxDays.ItemsSource = datas30Days; break;

            case 31: comboBoxDays.ItemsSource = datas31Days; break;

            default: break;
            }

            comboBoxDays.SelectedIndex = solarDay - 1;

            int    lunarYear  = LunarCalendar.GetLunarYear(solarYear, solarMonth, solarDay);
            string lunarMonth = LunarCalendar.GetStringLunarMonth(solarYear, solarMonth, solarDay);
            int    lunarDay   = LunarCalendar.GetIntLunarDay(solarYear, solarMonth, solarDay);

            comboBoxLunarYears.SelectedItem  = $"{lunarYear}年";
            comboBoxLunarMonths.SelectedItem = lunarMonth;
            comboBoxLunarDays.SelectedIndex  = lunarDay - 1;
            TextBlock_loaded();
        }
Esempio n. 2
0
        public void Combobox_loaded(DateTime currentTime)
        {
            comboBoxYears.ItemsSource = datas100Years;
            int year = currentTime.Year;

            comboBoxYears.SelectedItem  = $"{year}年";
            comboBoxMonths.SelectedItem = $"{currentTime.Month}月";
            int daysOfSolarMonth = DaysOfSolarMonth(currentTime.Year, currentTime.Month);

            switch (daysOfSolarMonth)
            {
            case 28: comboBoxDays.ItemsSource = datas28Days; break;

            case 29: comboBoxDays.ItemsSource = datas29Days; break;

            case 30: comboBoxDays.ItemsSource = datas30Days; break;

            case 31: comboBoxDays.ItemsSource = datas31Days; break;

            default: break;
            }
            comboBoxDays.SelectedIndex = currentTime.Day - 1;

            comboBoxLunarYears.ItemsSource  = datas100Years;
            comboBoxLunarYears.SelectedItem = LunarCalendar.GetLunarYear(currentTime.Year, currentTime.Month, currentTime.Day) + "年";
            string LunarDay = LunarCalendar.GetLunarDay(currentTime.Year, currentTime.Month, currentTime.Day, false);

            comboBoxLunarMonths.SelectedItem = LunarCalendar.GetStringLunarMonth(currentTime.Year, currentTime.Month, currentTime.Day);

            int lunarMonthDays = LunarCalendar.GetIntLunarMonth(currentTime.Year, currentTime.Month, currentTime.Day)[1];

            if (lunarMonthDays == 29)
            {
                comboBoxLunarDays.ItemsSource = datas29LunarDays;
            }
            else
            {
                comboBoxLunarDays.ItemsSource = datas30LunarDays;
            }
            comboBoxLunarDays.SelectedItem = LunarCalendar.GetLunarDay(currentTime.Year, currentTime.Month, currentTime.Day, true);
        }
Esempio n. 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = (Button)sender;

            if (priClickButton != null)
            {
                priClickButton.BorderBrush = brushTransparent;
            }
            b.BorderBrush  = brushBrown;
            priClickButton = b;
            int i = b.Name[b.Name.Length - 2] - '0';
            int j = b.Name[b.Name.Length - 1] - '0';
            int d = dayInButton[i, j];//该按钮显示的天数

            //更新显示的日期
            comboBoxDays.SelectedIndex = d - 1;
            int      solarYear      = comboBoxYears.SelectedIndex + 1970;
            int      solarMonth     = comboBoxMonths.SelectedIndex + 1;
            int      solarDay       = comboBoxDays.SelectedIndex + 1;
            DateTime dateTime       = new DateTime(solarYear, solarMonth, solarDay);
            int      lunarMonthDays = LunarCalendar.DaysOfLunarMonth(solarYear, solarMonth);

            if (lunarMonthDays == 29)
            {
                comboBoxLunarDays.ItemsSource = datas29LunarDays;
            }//if
            else
            {
                comboBoxLunarDays.ItemsSource = datas30LunarDays;
            }//else
            int    lunarYear  = LunarCalendar.GetLunarYear(solarYear, solarMonth, solarDay);
            string lunarMonth = LunarCalendar.GetStringLunarMonth(solarYear, solarMonth, solarDay);
            int    lunarDay   = LunarCalendar.GetIntLunarDay(solarYear, solarMonth, solarDay);

            comboBoxLunarYears.SelectedItem  = $"{lunarYear}年";
            comboBoxLunarMonths.SelectedItem = lunarMonth;
            comboBoxLunarDays.SelectedIndex  = lunarDay - 1;
            TextBlock_loaded();
        }