Exemplo n.º 1
0
        private string GetHaoDesc(Hao hao, bool isHaoDong, CanChi nhatThan, CanChi nguyetKien, List <LucThan> lucThan)
        {
            var result   = "";
            var isAmDong = IsAmDong(hao, nhatThan, nguyetKien);

            result += GetDiaChiVaLucThanCuaHao(hao, isHaoDong, lucThan, isAmDong);
            result += GetSuyVuongCuaHao(hao, nhatThan, nguyetKien);

            return(result);
        }
Exemplo n.º 2
0
        private void SetNgayThangComboboxes(DateTime ngayLayQue)
        {
            CanChi ngayAm  = ngayLayQue.ToAmLich().NgayAm;
            CanChi thangAm = ngayLayQue.ToAmLich().ThangAm;

            cbxNgayCan.SelectedIndex  = ngayAm.Can.Id - 1;
            cbxNgayChi.SelectedIndex  = ngayAm.Chi.Id - 1;
            cbxThangCan.SelectedIndex = thangAm.Can.Id - 1;
            cbxThangChi.SelectedIndex = thangAm.Chi.Id - 1;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Hào ám động là hào tĩnh, vượng tướng và xung với nhật thần.
        /// </summary>
        /// <param name="hao"></param>
        /// <param name="nhatThan"></param>
        /// <param name="nguyetKien"></param>
        /// <returns></returns>
        private bool IsAmDong(Hao hao, CanChi nhatThan, CanChi nguyetKien)
        {
            if (nhatThan.Chi.Xung == hao.Chi)
            {
                if (nhatThan.IsVuongTuong(hao.Chi) || nguyetKien.IsVuongTuong(hao.Chi))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 4
0
        private string GetHaoBienDesc(Hao haoBien, Hao haoGoc, bool isHaoDong, CanChi nhatThan, CanChi nguyetKien)
        {
            var result = "";

            result = GetDiaChiVaLucThanCuaHao(haoBien, isHaoDong, null);

            if (!isHaoDong)
            {
                return(result);
            }

            result += GetHaoBienExtraDesc(haoBien, haoGoc);

            result += GetSuyVuongCuaHao(haoBien, nhatThan, nguyetKien);

            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Nếu chọn chi thì phải cập nhật lại can.
        /// </summary>
        /// <param name="combobox"></param>
        /// <param name="comboboxToUpdate"></param>
        private void CapNhatCan(ComboBox combobox, ComboBox comboboxToUpdate)
        {
            DiaChi   selectedChi = DiaChi.All[combobox.SelectedIndex];
            ThienCan firstCan    = CanChi.GetCanDauTienHopLe(selectedChi);

            if (comboboxToUpdate.SelectedIndex < 0)
            {
                comboboxToUpdate.SelectedIndex = firstCan.Id - 1;
            }
            else
            {
                ThienCan currentCan = ThienCan.All[comboboxToUpdate.SelectedIndex];
                // Cập nhật chi nếu khác loại âm dương.
                if (currentCan.Duong != firstCan.Duong)
                {
                    comboboxToUpdate.SelectedIndex = firstCan.Id - 1;
                }
            }
        }
Exemplo n.º 6
0
        private void SetUIControls(AmLich amLich)
        {
            CanChi ngayAm  = amLich.NgayAm;
            CanChi thangAm = amLich.ThangAm;
            CanChi namAm   = amLich.NamAm;

            cbxNgayCan.SelectedIndex  = ngayAm.Can.Id - 1;
            cbxNgayChi.SelectedIndex  = ngayAm.Chi.Id - 1;
            cbxThangCan.SelectedIndex = thangAm.Can.Id - 1;
            cbxThangChi.SelectedIndex = thangAm.Chi.Id - 1;
            cbxNamCan.SelectedIndex   = namAm.Can.Id - 1;
            cbxNamChi.SelectedIndex   = namAm.Chi.Id - 1;

            DiaChi   gioChi = DiaChi.All[cbxGioChi.SelectedIndex];
            ThienCan gioCan = amLich.GetCanCuaGio(gioChi);

            cbxGioCan.SelectedIndex = gioCan.Id - 1;

            labelNgayDuongLich.Text = $"Ngày dương lịch: {amLich.SolarDate.Year}-{amLich.SolarDate.Month}-{amLich.SolarDate.Day}";
            labelNgayAmLich.Text    = $"Ngày âm lịch: {amLich.LunarYear}-{amLich.LunarMonth}-{amLich.LunarDay}";
        }
Exemplo n.º 7
0
 private string GetGioDescChoCongThucBatThuong(CanChi gio, bool batThuong)
 {
     return(batThuong ? $" + giờ {gio.Chi.Name} {gio.Chi.Id}" : "");
 }
Exemplo n.º 8
0
 public static CanChi Next(this CanChi canChi)
 {
     return(new CanChi {
         Can = canChi.Can.Next(), Chi = canChi.Chi.Next()
     });
 }
Exemplo n.º 9
0
        private string GetSuyVuongCuaHao(Hao hao, CanChi nhatThan, CanChi nguyetKien)
        {
            var result = "";

            if (nhatThan.IsLamKhong(hao.Chi))
            {
                result += ", lâm không";
            }

            // Nguyệt kiến
            if (nguyetKien.Chi.Xung == hao.Chi)
            {
                result += ", nguyệt phá";
            }
            else if (nguyetKien.Chi.Hop == hao.Chi)
            {
                result += ", nguyệt hợp";
            }

            if (nguyetKien.Chi == hao.Chi)
            {
                result += ", nguyệt kiến";
            }
            else if (nguyetKien.IsVuongTuong(hao.Chi))
            {
                result += ", nguyệt vượng";
            }
            else if (nguyetKien.IsHuuTu(hao.Chi))
            {
                result += ", nguyệt tù";
            }

            // Tháng thổ (thìn tuất sửu mùi) sẽ có hào gặp mộ.
            if (nguyetKien.Chi.NguHanh == Tho)
            {
                if (VongTruongSinh.IsMo(hao.Chi.NguHanh, nguyetKien.Chi))
                {
                    result += ", nguyệt mộ";
                }
            }

            // Nhật thần
            if (nhatThan.Chi == hao.Chi)
            {
                result += ", nhật kiến";
            }
            else if (nhatThan.Chi.Xung == hao.Chi)
            {
                if (nhatThan.IsVuongTuong(hao.Chi) || nguyetKien.IsVuongTuong(hao.Chi))
                {
                    result += ", ám động";
                }
                else
                {
                    result += ", nhật phá";
                }
            }
            else
            {
                if (nhatThan.IsVuongTuong(hao.Chi))
                {
                    result += ", nhật vượng";
                }
                else if (nhatThan.IsHuuTu(hao.Chi))
                {
                    result += ", nhật tù";
                }
            }

            // Ngày thổ (thìn tuất sửu mùi) sẽ có hào gặp mộ.
            if (nhatThan.Chi.NguHanh == Tho)
            {
                if (VongTruongSinh.IsMo(hao.Chi.NguHanh, nhatThan.Chi))
                {
                    result += ", nhật mộ";
                }
            }

            return(result);
        }