Ejemplo n.º 1
0
        private void ComboBoxDropDownClosed_Lunar(object sender, object e)
        {
            int     lunarYear  = comboBoxLunarYears.SelectedIndex + 1970;
            int     lunarMonth = comboBoxLunarMonths.SelectedIndex + 1;
            int     lunarDay   = comboBoxLunarDays.SelectedIndex + 1;
            bool    isLeap     = LunarToSolar.IsLunarLeapYear(lunarYear);
            Lunar_t lunar_T    = new Lunar_t(lunarYear, lunarMonth, lunarDay, isLeap);

            int solarYear  = 0;
            int solarMonth = 0;
            int solarDay   = 0;

            if (LunarToSolar.ToSolar(lunar_T, ref solarYear, ref solarMonth, ref solarDay))
            {
                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;
                }

                comboBoxYears.SelectedIndex  = solarYear - 1970;
                comboBoxMonths.SelectedIndex = solarMonth - 1;
                comboBoxDays.SelectedIndex   = solarDay - 1;

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

                if (lunarMonthDays == 29)
                {
                    comboBoxLunarDays.ItemsSource = datas29LunarDays;
                }//if
                else
                {
                    comboBoxLunarDays.ItemsSource = datas30LunarDays;
                }//else
                if (lunarDay > lunarMonthDays)
                {
                    comboBoxLunarDays.SelectedIndex = lunarMonthDays - 1;
                }//if
                else
                {
                    comboBoxLunarDays.SelectedIndex = lunarDay - 1;
                }//else
                DateTime dateTime = new DateTime(solarYear, solarMonth, solarDay);
                Refresh(dateTime);
                TextBlock_loaded();
            }
        }
Ejemplo n.º 2
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();
        }
Ejemplo 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();
        }