private string[] GetPanSeqStep(string[] srcArr, string[,] dipan, string zhishi, string hg) { string[,] panSeqSrc = DyadicArrayHelper.InitNineGong(srcArr, true); int[] fromSeq = DyadicArrayHelper.GetPanSeq(dipan, zhishi); int[] toSeq = DyadicArrayHelper.GetPanSeq(dipan, hg); return(new string[] { panSeqSrc[fromSeq[0], fromSeq[1]], panSeqSrc[toSeq[0], toSeq[1]] }); }
private string[,] OrderGodPan(string[,] dipan, string zhishi, string hg, bool order) { string[,] panSeqSrc = new string[3, 3]; if (!order) { panSeqSrc = DyadicArrayHelper.InitNineGong(xgodArr, true); } else { panSeqSrc = DyadicArrayHelper.InitNineGong(godArr, true); } int[] toSeq = DyadicArrayHelper.GetPanSeq(dipan, hg); int step = 0; step = DyadicArrayHelper.GetOrderStep(panSeqSrc, godArr[7], panSeqSrc[toSeq[0], toSeq[1]]); string[,] newPan = DyadicArrayHelper.DyadicNineGongToSideEigthGong(panSeqSrc, step, true); return(newPan); }
private void CalCurrentAllGZ(int day, string jd, string jm, string jy, string jnd, string jnm) { int g = DyadicArrayHelper.GetArrayIndexByValue(ganArr, jd.Substring(0, 1)); int z = DyadicArrayHelper.GetArrayIndexByValue(zhiArr, jd.Substring(1, 1)); day = day - 1;//约一个记时日,因交节气时间不可能是24:00,时家奇门,如果有刻奇门,或分奇门理论上要比时家奇门要精确。 for (int i = 0; i <= day; i++) { g++; if (g > 9) { g = g - 10; } z++; if (z > 11) { z = z - 12; } } dayGZ = ganArr[g] + zhiArr[z];//得到日干支 yearGZ = jy; monthGZ = jm; int monthIndex = DyadicArrayHelper.GetArrayIndexByValue(JieQiHelper.Days(true).ToArray(), jnd.Replace("日", "")); int mdays = 30; if (jnm.IndexOf("小") > 0) { mdays = 29; } if (monthIndex + day > mdays) //跨月 { SQLiteDataReader reader = SelectJieQI.GetReadData((-1) * day + 10); //因节气在上个月,时间回本月,取节气前一个月的月干支,年干支 if (reader != null) { while (reader.Read()) { monthGZ = reader["MonthGZ"].ToString(); yearGZ = reader["YearGZ"].ToString(); } } reader.Close(); reader.Dispose(); } }
private string[,] OrderStarPan(string[,] dipan, string zhishi, string hg) { string[,] panSeqSrc = DyadicArrayHelper.InitNineGong(starArr, true); string[] fromto = GetPanSeqStep(starArr, dipan, zhishi, hg); int step = 0; //if (fromSeq[0] == toSeq[0] && fromSeq[1] == toSeq[1]) //{ // step = DyadicArrayHelper.GetOrderStep(panSeqSrc, srcArr[7], panSeqSrc[toSeq[0], toSeq[1]]); //} //else { step = DyadicArrayHelper.GetOrderStep(panSeqSrc, fromto[0], fromto[1]); } string[,] newPan = DyadicArrayHelper.DyadicNineGongToSideEigthGong(panSeqSrc, step, true); return(newPan); ; }
private string[,] OrderDoorPan(string[,] dipan, string zhishi, string xunz, string hg, string hz, bool order) { zhishi = GetZHISHI(GetFuTou(hourGZ, true)); string[,] panSeqSrc = DyadicArrayHelper.InitNineGong(doorArr, true); int[] fromSeq = DyadicArrayHelper.GetPanSeq(dipan, zhishi);//值坐标 zhimen = panSeqSrc[fromSeq[0], fromSeq[1]]; //if (zhimen == "") //落中宫,寄坤宫 记五数 //{ // fromSeq[0] = 2; // fromSeq[1] = 0; //} int[] toSeq = DyadicArrayHelper.GetNineGongSeq(fromSeq, Diffz(xunz, hz), xunz, hz, order);//旬支飞时支的坐标 string from = panSeqSrc[fromSeq[0], fromSeq[1]]; if (from.Trim() == string.Empty) { from = panSeqSrc[2, 0]; } string to = panSeqSrc[toSeq[0], toSeq[1]]; if (to.Trim() == string.Empty) { to = panSeqSrc[2, 0]; } int step = 0; if (from == to) { return(panSeqSrc); } else { step = DyadicArrayHelper.GetOrderStep(panSeqSrc, from, to); } string[,] newPan = DyadicArrayHelper.DyadicNineGongToSideEigthGong(panSeqSrc, step, true); return(newPan); }
private void Start() { //1,准备数据 InitStaticData(); GetAllGZ(); //2,根据日干和节气求局数 int ju = GetJu(dayGZ); //3,根据局数飞布定地盘; string[] dipan = OrderDIPan(ju); string[,] dealDiPan = DyadicArrayHelper.InitNineGong(dipan, false); Dictionary <int, string> dicDP = GetDPDic(dealDiPan); //4,根据值使和地盘求天盘; hourGZ = GetShiGZ(dayGZ);//根据日求时 string shiG = hourGZ.Substring(0, 1); zhifu = GetZF(dicDP, shiG); string zhiyi = GetDiPan6Yi(hourGZ); string zhishi = zhiyi;// GetZHISHI(GetFuTou(hourGZ, true));//根据时求符首 if (zhishi == dealDiPan[1, 1]) { zhishi = dealDiPan[2, 0]; //特例中宫落二宫 } if (shiG == dealDiPan[1, 1]) { shiG = dealDiPan[2, 0]; //特例中宫落二宫 } int step = DyadicArrayHelper.GetOrderStep(dealDiPan, zhishi, shiG); //偏移量 if (shiG == ganArr[0]) { step = 0; //元帅特例 } string[,] tianPan = OrderTianPan(dealDiPan, step); //5,九星盘 string[,] starPan = OrderStarPan(dealDiPan, zhishi, shiG); //6,八神盘 bool order = ju > 0; string[,] godPan = OrderGodPan(dealDiPan, zhishi, shiG, order); //7,八门盘 string shiZ = hourGZ.Substring(1, 1); string xunZ = GetFuTou(hourGZ, true); string[,] doorPan = OrderDoorPan(dealDiPan, zhishi, xunZ, shiG, shiZ, order); //以下调试=========================================================================================================== if (order) { JU = "阳遁: " + ju + "局"; } else { JU = "阴遁: " + ju + "局"; } if (zhimen.Trim().Length == 0) { zhimen = "死五"; } string msg = "时间: " + yearGZ + monthGZ + dayGZ + "日" + hourGZ + "时" + System.Environment.NewLine + "节气: " + jieQi + System.Environment.NewLine + JU + System.Environment.NewLine + "旬首: 甲" + xunZ + (zhiyi != zhishi? zhiyi + "转 " + zhishi: zhiyi) + System.Environment.NewLine + "直使: " + zhimen + "门" + System.Environment.NewLine + "直符: 落" + zhifu + shiG + "宫"; //MessageBox.Show(msg); label1.Text = msg; DataTable dt = DyadicArrayHelper.ArrayToTable(dealDiPan); subGrid1.Location = new System.Drawing.Point(13, 27); subGrid1.Size = new System.Drawing.Size(303, 72); subGrid1.DataSource = dt; int[] focusCell = DyadicArrayHelper.GetPanSeq(dealDiPan, zhiyi); subGrid1.focusColmunIndex = focusCell[0]; subGrid1.focusRowIndex = focusCell[1]; DataTable dt4 = DyadicArrayHelper.ArrayToTable(godPan); subGrid4.Location = new System.Drawing.Point(13, 101); subGrid4.Size = new System.Drawing.Size(303, 72); subGrid4.DataSource = dt4; focusCell = DyadicArrayHelper.GetPanSeq(godPan, godArr[7]); subGrid4.focusColmunIndex = focusCell[0]; subGrid4.focusRowIndex = focusCell[1]; DataTable dt6 = DyadicArrayHelper.ArrayToTable(DyadicArrayHelper.InitNineGong(guaArr, true)); subGrid6.Location = new System.Drawing.Point(13, 175); subGrid6.Size = new System.Drawing.Size(303, 72); subGrid6.DataSource = dt6; focusCell = DyadicArrayHelper.GetPanSeq(dealDiPan, yiqiArr[0]); subGrid6.focusColmunIndex = focusCell[0]; subGrid6.focusRowIndex = focusCell[1]; DataTable dt2 = DyadicArrayHelper.ArrayToTable(tianPan); subGrid2.Location = new System.Drawing.Point(326, 27); subGrid2.Size = new System.Drawing.Size(303, 72); subGrid2.DataSource = dt2; focusCell = DyadicArrayHelper.GetPanSeq(tianPan, shiG); subGrid2.focusColmunIndex = focusCell[0]; subGrid2.focusRowIndex = focusCell[1]; DataTable dt3 = DyadicArrayHelper.ArrayToTable(starPan); subGrid3.Location = new System.Drawing.Point(326, 101); subGrid3.Size = new System.Drawing.Size(303, 72); subGrid3.DataSource = dt3; focusCell = DyadicArrayHelper.GetPanSeq(starPan, shiG); subGrid3.focusColmunIndex = focusCell[0]; subGrid3.focusRowIndex = focusCell[1]; DataTable dt5 = DyadicArrayHelper.ArrayToTable(doorPan); subGrid5.Location = new System.Drawing.Point(326, 175); subGrid5.Size = new System.Drawing.Size(303, 72); subGrid5.DataSource = dt5; focusCell = DyadicArrayHelper.GetPanSeq(doorPan, zhimen); subGrid5.focusColmunIndex = focusCell[0]; subGrid5.focusRowIndex = focusCell[1]; }
private string[,] OrderTianPan(string[,] dipan, int step) { string[,] tian = DyadicArrayHelper.DyadicNineGongToSideEigthGong(dipan, step, true); return(tian); }