コード例 #1
0
ファイル: PaiPanFormat.cs プロジェクト: snamper/ZW
        public string FormatHtml(PaiPan pan, int formatType, ChineseCalendar2 cc2 = null)
        {
            ChineseCalendar tt     = new ChineseCalendar(DateTime.Now);
            var             age    = tt.ChineseYear - pan.birthday.ChineseYear;
            var             daxian = "  ";

            var datas = parseGong(pan);

            foreach (var d in datas)
            {
                d.formatType = formatType;

                try
                {
                    var arr = d.daXian.Split('-');
                    var f   = Convert.ToInt32(arr[0]);
                    var t   = Convert.ToInt32(arr[1]);
                    if (age >= f && age <= t)
                    {
                        daxian = d.ganStr + d.zhiStr;
                    }
                }
                catch (Exception ex)
                {
                }
            }

            var sb = new StringBuilder();

            sb.Append(FormatHead(pan));
            sb.Append("<table border=1 cols=1 width=135 CELLSPACING=0 CELLPADDING=0>");
            sb.Append("<tbody><tr>");

            sb.Append(FormatCell(datas.First(d => d.zhiStr == "巳")));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "午")));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "未")));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "申")));

            sb.Append("</tr><tr>");

            sb.Append(FormatCell(datas.First(d => d.zhiStr == "辰")));
            sb.Append(FormatCenter(pan, cc2, daxian));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "酉")));

            sb.Append("</tr><tr>");

            sb.Append(FormatCell(datas.First(d => d.zhiStr == "卯")));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "戌")));

            sb.Append("</tr><tr>");

            sb.Append(FormatCell(datas.First(d => d.zhiStr == "寅")));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "丑")));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "子")));
            sb.Append(FormatCell(datas.First(d => d.zhiStr == "亥")));

            sb.Append("</tr></tbody>");
            sb.Append("</table>");
            sb.Append(FormatFoot(pan));

            return(sb.ToString());
        }
コード例 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            //TestAiqingScore();
            //return;
            eg = new Engine(@".\Data\");

            #region 穷举命盘

            //Dictionary<string, int> dic = new Dictionary<string, int>();

            //DateTime dt = DateTime.Now.AddYears(-60);

            //for (int i = 0; i < 260000; i++)
            //{
            //    ChineseCalendar cc = new ChineseCalendar(dt);
            //    var pan = new PaiPan(cc, this.ckMan.Checked);

            //    string key = string.Empty;

            //    var star = pan.MingGong.Stars.Where(s => s.Type == Star.StarType.主星).ToList();
            //    if (star.Count == 0)
            //    {
            //        star = pan.Gongs.First(g => g.Name == "迁移宫").Stars.Where(s => s.Type == Star.StarType.主星).ToList();
            //    }

            //    if (star.Count == 2)
            //    {
            //        key = string.Format("{0}#{1}", star[0].Name, star[1].Name);
            //    }
            //    else
            //    {
            //        key = star[0].Name;
            //    }

            //    if (dic.ContainsKey(key))
            //    {
            //        dic[key]++;
            //    }
            //    else
            //    {
            //        dic.Add(key, 1);
            //    }

            //    dt = dt.AddHours(2);
            //}

            //StringBuilder sb = new StringBuilder();
            //foreach (var item in dic.OrderBy(d => d.Key.Length))
            //{
            //    sb.AppendLine(string.Format("{0}:\t\t{1}", item.Key, item.Value));
            //}

            //this.txtBrithday.Text = sb.ToString();

            #endregion

            #region 流年财运

            //pan.Liu(new ChineseCalendar(DateTime.Now));

            //var dt = new DateTime(1985, 1, 1, 2, 0, 0);
            //var dt2 = new DateTime(2049, 12, 30, 0, 0, 0);

            //var rets = eg.LiuNianAnalyzer.GetLiuNianInfo(pan, GongIndex.财帛宫);
            //var sss= eg.GetStarGuardStone("紫微");
            //dt = new DateTime(1996, 1, 1, 0, 0, 0);

            //for (; dt < dt2; dt = dt.AddYears(1))
            //{
            //    cc = new ChineseCalendar(dt);
            //    pan.Liu(cc);
            //    var score = eg.LiuNianAnalyzer.GetLiuNianCaiboScore(pan);
            //    this.txtBrithday.Text += string.Format("{0}:{1}\n", dt.Year, score);
            //}

            //var dt = new DateTime(1982, 11, 3, 6, 1, 0);
            //ChineseCalendar dtc = new ChineseCalendar(dt);
            //var ppan = new PaiPan(dtc, true);
            //var caiboMing = ppan.Gongs.First(g => g.Name == GongIndex.财帛宫.ToString());
            // var score = eg.LiuNianAnalyzer.CaiboScore(ppan, caiboMing);
            #endregion

            DateTime         dateTime = this.dpBirthDate.Value;
            ChineseCalendar  cc       = new ChineseCalendar(dateTime);
            ChineseCalendar2 cc2      = new ChineseCalendar2(dateTime);
            var pan = new PaiPan(cc, this.ckMan.Checked);



            frmPan f1 = new frmPan();
            f1.htmlText = eg.PaiPanFormat.FormatHtml(pan, 1, cc2);
            f1.Show();
        }
コード例 #3
0
ファイル: PaiPanFormat.cs プロジェクト: snamper/ZW
        private static string FormatCenter(PaiPan pan, ChineseCalendar2 cc2 = null, string daxian = "  ")
        {
            ChineseCalendar tt = new ChineseCalendar(DateTime.Now);
            var             sb = new StringBuilder();

            sb.Append("<td colspan=2 rowspan=2 style='padding:0;margin:0;border: 0;'>");
            sb.Append("<table width=270 border=0 height=200 valign = top style='padding:0;margin:0;border: 0;'><tr>");
            // 天盘
            sb.Append(@"<td height=100 width=22>
                    <table width=45 border=0 cellpadding=0 cellspacing=0 valign = top>
					  <tr><td height=20><font id=titlefont>&nbsp;中</font></td></tr>
					  <tr><td height=20><font id=titlefont>&nbsp;州</font></td></tr>
					  <tr><td height=20><font id=titlefont>&nbsp;派</font></td></tr>
					  <tr><td height=20><font id=titlefont>&nbsp;紫</font></td></tr>
					  <tr><td height=20><font id=titlefont>&nbsp;微</font></td></tr>
					  <tr><td height=20><font id=titlefont>&nbsp;斗</font></td></tr>
					  <tr><td height=20><font id=titlefont>&nbsp;數</font></td></tr>
                      <tr><td><font id=m10>&nbsp;張</font></td></tr>
                      <tr><td><font id=m10>&nbsp;曜</font></td></tr>
                      <tr><td><font id=m10>&nbsp;之</font></td></tr>
                      <tr><td><font id=m10>&nbsp;</font></td></tr>
                      <tr><td><font id=m10>&nbsp;啓</font></td></tr>
                    </table></td>");

            sb.Append(@"<td><table width=22 border=0 cellpadding=0 cellspacing=0>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               </table></td>");

            // 现行 大限
            sb.AppendFormat(@"<td><table width=22 border=0 cellpadding=0 cellspacing=0>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td><font id=m11>現</font></td></tr>
              <tr><td><font id=m11>行</font></td></tr>
              <tr><td><span id=m11>{0}</span></td></tr>
              <tr><td><span id=m11>{1}</span></td></tr>
              <tr><td><font id=m11>大</font></td></tr>
              <tr><td><font id=m11>限</font></td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              </table></td>", daxian.Substring(0, 1), daxian.Substring(1, 1));

            // 年龄
            sb.AppendFormat(@"<td><table width=22 border=0 cellpadding=0 cellspacing=0>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td><font id=m11>{0}</font></td></tr>
              <tr><td><font id=m11>{1}</font></td></tr>
              <tr><td><font id=m11>年</font></td></tr>
              <tr><td><font id=m11>{2}</font></td></tr>
              <tr><td><font id=m11>岁</font></td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              <tr><td>&nbsp;</td></tr>
              </table></td>", tt.GanZhiYearString.Substring(0, 1),
                            tt.GanZhiYearString.Substring(1, 1),
                            tt.ChineseYear - pan.birthday.ChineseYear);

            // 身主
            sb.AppendFormat(@"<td><table width=22 border=0 cellpadding=0 cellspacing=0>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td><font id=m11>身</font></td></tr>
               <tr><td><font id=m11>主</font></td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td><font id=m11>{0}</font></td></tr>
               <tr><td><font id=m11>{1}</font></td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               </table></td>", pan.ShenZhu.Substring(0, 1),
                            pan.ShenZhu.Substring(1, 1));

            // 命主
            sb.AppendFormat(@"<td><table width=22 border=0 cellpadding=0 cellspacing=0 valign=top>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td><font id=m11>命</font></td></tr>
               <tr><td><font id=m11>主</font></td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td><font id=m11>{0}</font></td></tr>
               <tr><td><font id=m11>{1}</font></td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               </table></td>", pan.MingZhu.Substring(0, 1),
                            pan.MingZhu.Substring(1, 1));

            // 五行局
            sb.AppendFormat(@"<td><table width=22 border=0 cellpadding=0 cellspacing=0>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td><font id=m11>{0}</font></td></tr>
               <tr><td><font id=m11>{1}</font></td></tr>
               <tr><td><font id=m11>{2}</font></td></tr>
               </table></td>", pan.WuXingJu.Substring(0, 1),
                            pan.WuXingJu.Substring(1, 1),
                            pan.WuXingJu.Substring(2, 1));

            // 生日
            sb.AppendFormat(@"<td><table width=50 border=0 cellpadding=0 cellspacing=0>
               <tr><td align=center>&nbsp;</td></tr>
               <tr><td><font id=m11></font></td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td align=center><font id=m11>{0}</font></td></tr>
               <tr><td align=center><font id=m11>{1}</font></td></tr>
               <tr><td align=center><font id=m11>年</font></td></tr>
               <tr><td align=center><font id=m11>{6}</font></td></tr>
               <tr><td align=center><font id=m11>{2}</font></td></tr>
               <tr><td align=center><font id=m11>月</font></td></tr>
               <tr><td align=center><font id=m11>{3}</font></td></tr>
               <tr><td align=center><font id=m11>日</font></td></tr>"
                            + ((cc2 != null && cc2.ChineseWanZi)? @"<tr><td align=center><font id=m11>晚</font></td></tr>" : @"")
                            + @"
               <tr><td align=center><font id=m11>{4}</font></td></tr>
               <tr><td align=center><font id=m11>时</font></td></tr>
               </table></td>", cc2 != null ? cc2.GanZhiYearString.Substring(0, 1) : pan.birthday.GanZhiYearString.Substring(0, 1),
                            cc2 != null? cc2.GanZhiYearString.Substring(1, 1) : pan.birthday.GanZhiYearString.Substring(1, 1),
                            cc2 != null ? cc2.ChineseMonth : pan.birthday.ChineseMonth,
                            cc2 != null ? cc2.ChineseDay : pan.birthday.ChineseDay,
                            cc2 != null ? cc2.GanZhiHourString.Substring(1, 1) : pan.birthday.GanZhiHourString.Substring(1, 1),
                            pan.birthday.Date.Year,
                            pan.birthday.IsChineseLeapMonth ? "闰" : "");

            // 性别
            sb.AppendFormat(@"<td ><table width='22' border='0' cellpadding='0' cellspacing='0'>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td><font id=m11>{0}</font></td></tr>
               <tr><td><font id=m11>{1}</font></td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               <tr><td>&nbsp;</td></tr>
               </table></td>", (pan.birthday.ChineseYear % 2 == 0) ? "阳" : "阴",
                            pan.IsMale ? "男" : "女");

            sb.Append("</tr></table>");
            sb.Append("</td>");

            return(sb.ToString());
        }