コード例 #1
0
        public int Step6(DayBinomialsChart dayChart, MonthBinomialChart monthChart)
        {
            int yearBinomial  = dayChart.Day1Number;
            int monthBinomial = monthChart.Number;
            int dayBinomial   = BirthDay;

            int total = yearBinomial + monthBinomial + dayBinomial;

            if (total > 60)
            {
                total -= 60;
            }

            return(total);
        }
コード例 #2
0
ファイル: BaZiCalculator.cs プロジェクト: davemos/projects
        public BaZiCalculator(DateTime birthDate, long birthTime)
        {
            FourPillarsResult = new FourPillarsTable();
            BirthDate         = birthDate;
            BirthTime         = birthTime;
            BirthYear         = BirthDate.Year;
            BirthMonth        = BirthDate.Month;
            BirthDay          = BirthDate.Day;

            DataLoad dataLoad = new DataLoad();
            List <TwelveStageGrowthCycleChart> twelveStageGrowthCycleChart = dataLoad.LoadTwelveStageGrowthCycleChartData();
            List <ChineseCalendarChart>        chineseCalendarChart        = dataLoad.LoadChineseCalendarChartData();
            List <DayBinomialsChart>           dayBinomialsChart           = dataLoad.LoadDayBinomialsChartData();
            List <HourStemAndBranchChart>      hourStemAndBranchChart      = dataLoad.LoadHourStemAndBranchChartData();
            List <HiddenElementsChart>         hiddenElementsChart         = dataLoad.LoadHiddenElementsChartData();
            List <LeapYearMonthBinomialChart>  leapYearMonthBinomialChart  = dataLoad.LoadLeapYearMonthBinomialChartData();
            List <MonthBinomialChart>          monthBinomialChart          = dataLoad.LoadMonthBinomialChartData();
            List <StemsAndBranchesCycleOf60>   stemsAndBranchesCycleOf60   = dataLoad.LoadStemsAndBranchesCycleOf60Data();
            List <YinYangMeridianChart>        yinYangMeridianChart        = dataLoad.LoadYinYangMeridianChartData();

            //step 2
            int yearNum = chineseCalendarChart.Find((ChineseCalendarChart obj) => obj.Year.Year == BirthYear).Year.Number;

            //step 3
            FourPillarsResult.YearStem   = stemsAndBranchesCycleOf60.Find((obj) => obj.Number == yearNum).Stem;
            FourPillarsResult.YearBranch = stemsAndBranchesCycleOf60.Find((obj) => obj.Number == yearNum).Branch;

            //step 4
            int monthNum = Step4(chineseCalendarChart.Find((obj) => obj.Year.Year == BirthYear));

            //step 5
            FourPillarsResult.MonthStem   = stemsAndBranchesCycleOf60.Find((obj) => obj.Number == monthNum).Stem;
            FourPillarsResult.MonthBranch = stemsAndBranchesCycleOf60.Find((obj) => obj.Number == monthNum).Branch;

            //step 6
            DayBinomialsChart   dbc = dayBinomialsChart.Find((obj) => obj.Year == BirthYear);
            IMonthBinomialChart bc;

            if (dbc.LeapYear)
            {
                bc = leapYearMonthBinomialChart.Find((obj) => obj.Month == BirthMonth);
            }
            else
            {
                bc = monthBinomialChart.Find((obj) => obj.Month == BirthMonth);
            }
            int dayBinomial = Step6(dbc, bc);

            //step 7
            FourPillarsResult.DayStem   = stemsAndBranchesCycleOf60.Find((obj) => obj.Number == dayBinomial).Stem;
            FourPillarsResult.DayBranch = stemsAndBranchesCycleOf60.Find((obj) => obj.Number == dayBinomial).Branch;

            //step 8
            HourStemAndBranchChart hsbc = Step8(hourStemAndBranchChart, FourPillarsResult.DayStem);

            FourPillarsResult.HourStem   = hsbc.HourStems.Find((obj) => obj.TimeOfBirth.TimeStart <= BirthTime && obj.TimeOfBirth.TimeEnd >= BirthTime).Stem;
            FourPillarsResult.HourBranch = hsbc.HourStems.Find((obj) => obj.TimeOfBirth.TimeStart <= BirthTime && obj.TimeOfBirth.TimeEnd >= BirthTime).Animal;

            //step 9
            HiddenElementsChart hiddenElements = new HiddenElementsChart();

            hiddenElements = hiddenElementsChart.Find((obj) => obj.Animal == FourPillarsResult.YearBranch);
            FourPillarsResult.YearHiddenElements = new HiddenElementsChart();
            FourPillarsResult.YearHiddenElements.HiddenElement       = hiddenElements.MainElement;
            FourPillarsResult.YearHiddenElements.HiddenElementValue  = hiddenElements.MainElementValue;
            FourPillarsResult.YearHiddenElements.HiddenElement2      = hiddenElements.HiddenElement;
            FourPillarsResult.YearHiddenElements.HiddenElement2Value = hiddenElements.HiddenElementValue;
            FourPillarsResult.YearHiddenElements.HiddenElement3      = hiddenElements.HiddenElement2;
            FourPillarsResult.YearHiddenElements.HiddenElement3Value = hiddenElements.HiddenElement2Value;

            hiddenElements = hiddenElementsChart.Find((obj) => obj.Animal == FourPillarsResult.MonthBranch);
            FourPillarsResult.MonthHiddenElements = new HiddenElementsChart();
            FourPillarsResult.MonthHiddenElements.HiddenElement       = hiddenElements.MainElement;
            FourPillarsResult.MonthHiddenElements.HiddenElementValue  = hiddenElements.MainElementValue;
            FourPillarsResult.MonthHiddenElements.HiddenElement2      = hiddenElements.HiddenElement;
            FourPillarsResult.MonthHiddenElements.HiddenElement2Value = hiddenElements.HiddenElementValue;
            FourPillarsResult.MonthHiddenElements.HiddenElement3      = hiddenElements.HiddenElement2;
            FourPillarsResult.MonthHiddenElements.HiddenElement3Value = hiddenElements.HiddenElement2Value;

            hiddenElements = hiddenElementsChart.Find((obj) => obj.Animal == FourPillarsResult.DayBranch);
            FourPillarsResult.DayHiddenElements = new HiddenElementsChart();
            FourPillarsResult.DayHiddenElements.HiddenElement       = hiddenElements.MainElement;
            FourPillarsResult.DayHiddenElements.HiddenElementValue  = hiddenElements.MainElementValue;
            FourPillarsResult.DayHiddenElements.HiddenElement2      = hiddenElements.HiddenElement;
            FourPillarsResult.DayHiddenElements.HiddenElement2Value = hiddenElements.HiddenElementValue;
            FourPillarsResult.DayHiddenElements.HiddenElement3      = hiddenElements.HiddenElement2;
            FourPillarsResult.DayHiddenElements.HiddenElement3Value = hiddenElements.HiddenElement2Value;

            hiddenElements = hiddenElementsChart.Find((obj) => obj.Animal == FourPillarsResult.HourBranch);
            FourPillarsResult.HourHiddenElements = new HiddenElementsChart();
            FourPillarsResult.HourHiddenElements.HiddenElement       = hiddenElements.MainElement;
            FourPillarsResult.HourHiddenElements.HiddenElementValue  = hiddenElements.MainElementValue;
            FourPillarsResult.HourHiddenElements.HiddenElement2      = hiddenElements.HiddenElement;
            FourPillarsResult.HourHiddenElements.HiddenElement2Value = hiddenElements.HiddenElementValue;
            FourPillarsResult.HourHiddenElements.HiddenElement3      = hiddenElements.HiddenElement2;
            FourPillarsResult.HourHiddenElements.HiddenElement3Value = hiddenElements.HiddenElement2Value;

            //step 10
            FourPillarsResult.YearStemValue  = 100;
            FourPillarsResult.MonthStemValue = 100;
            FourPillarsResult.DayStemValue   = 100;
            FourPillarsResult.HourStemValue  = 100;

            //step 11
            ElementTotals            = new ElementTotal();
            ElementTotals.WoodTotal  = Step11(FourPillarsResult, Stems.YangWood) + Step11(FourPillarsResult, Stems.YinWood);
            ElementTotals.FireTotal  = Step11(FourPillarsResult, Stems.YangFire) + Step11(FourPillarsResult, Stems.YinFire);
            ElementTotals.EarthTotal = Step11(FourPillarsResult, Stems.YangEarth) + Step11(FourPillarsResult, Stems.YinEarth);
            ElementTotals.MetalTotal = Step11(FourPillarsResult, Stems.YangMetal) + Step11(FourPillarsResult, Stems.YinMetal);
            ElementTotals.WaterTotal = Step11(FourPillarsResult, Stems.YangWater) + Step11(FourPillarsResult, Stems.YinWater);

            //step 12
            TwelveStageGrowthCycleChart twelveStage = twelveStageGrowthCycleChart.Find((obj) => obj.Wood.Animal == FourPillarsResult.MonthBranch);

            ElementTotals.WoodTotal  = ElementTotals.WoodTotal * twelveStage.Wood.Percent / 100;
            ElementTotals.FireTotal  = ElementTotals.FireTotal * twelveStage.Fire.Percent / 100;
            ElementTotals.EarthTotal = ElementTotals.EarthTotal * twelveStage.Earth.Percent / 100;
            ElementTotals.MetalTotal = ElementTotals.MetalTotal * twelveStage.Metal.Percent / 100;
            ElementTotals.WaterTotal = ElementTotals.WaterTotal * twelveStage.Water.Percent / 100;

            //step 13
            double elementTotals = ElementTotals.WoodTotal + ElementTotals.FireTotal + ElementTotals.EarthTotal + ElementTotals.MetalTotal + ElementTotals.WaterTotal;

            ElementTotals.WoodPercent  = (int)(ElementTotals.WoodTotal / elementTotals * 100);
            ElementTotals.FirePercent  = (int)(ElementTotals.FireTotal / elementTotals * 100);
            ElementTotals.EarthPercent = (int)(ElementTotals.EarthTotal / elementTotals * 100);
            ElementTotals.MetalPercent = (int)(ElementTotals.MetalTotal / elementTotals * 100);
            ElementTotals.WaterPercent = (int)(ElementTotals.WaterTotal / elementTotals * 100);

            // Step 14
            FourPillarsResult.DayMasterLabel = Step14(FourPillarsResult.DayStem);

            //step 16
            Step16(FourPillarsResult, yinYangMeridianChart);
            YinYangMeridianResult = yinYangMeridianChart;
        }