Exemplo n.º 1
0
        private static void ExpandLocationData()
        {
            XElement foundNode;
            Regex    regexToTrim = new Regex(@"(^\s*)|(\s*$)"); // C#: 匹配任何前后端的空白字符

            char[] lineFlags = new char[] { '\r', '\n' };


            // 读取并解开各地经纬度表
            foundNode = LunarHelper.GetXmlNode("JWdata_JWv");
            if (foundNode != null)
            {
                string[] strJWv = regexToTrim.Replace(foundNode.Value, "").Split(lineFlags, StringSplitOptions.RemoveEmptyEntries);
                foreach (string line in strJWv)
                {
                    var items = regexToTrim.Replace(line, "").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    Land land = new Land(items[0]);
                    Land.landes.Add(land);
                    for (int i = 1; i < items.Count(); i++)
                    {
                        string code = items[i].Substring(0, 4);
                        string name = items[i].Substring(4);
                        land.cities.Add(new City(name: name, code: code));
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void label12_Click(object sender, EventArgs e)
 {
     MessageBox.Show("_" + LunarHelper.SUBSTRING("1", 0, 2) + "_" + "\r" +
                     "_" + LunarHelper.SUBSTRING("1", -1, 2) + "_" + "\r" +
                     "_" + LunarHelper.SUBSTRING("1", 0, -1) + "_" + "\r" +
                     "_" + LunarHelper.SUBSTRING("abc", 1, 2) + "_", "返回结果(注意前后均增加了下划线):");
 }
Exemplo n.º 3
0
        private void getlunar()
        {
            // double By = LunarHelper.year2Ayear<string>(this.Cal_y.Text);
            //// C#: 注: 使用上句也可以, 如果在调用泛型方法时, 不指定类型, C# 编译器将自动推断其类型
            double By = LunarHelper.year2Ayear(this.Cal_y.Text);    // 自动推断类型为: string
            double Bm = int.Parse(this.Cal_m.Text);

            lun.yueLiHTML((int)By, (int)Bm, this.curJD);
            this.txtPg0_Text.Text = lun.pg0_text;
            this.txtPg1_Text.Text = lun.pg1_text;
            this.txtPg2_Text.Text = lun.pg2_text;

            this.showMessD(-2);

            this.StrToFile("<html><META http-equiv=Content-Type content='text/html; charset=utf-8'>" + lun.pg0 +
                           "<p></p>" + lun.pg1 + "<p></p>" + lun.pg2 +
                           "\r\n <script language='javascript'>" +
                           "\r\n function changeBackcolor(oTdOfDay, setBackcolor) {" +
                           "\r\n if(oTdOfDay == null) return;" +
                           "\r\n if(setBackcolor)   {    oTdOfDay.style.background = 'background-color: #99FFCC';    }" +
                           "\r\n else    {" +
                           "\r\n oTdOfDay.style.background = '';    }" +
                           "\r\n }" +
                           "\r\n </script></html>", this.TempPath + "ls.htm");

            this.webBrowserMonth.Navigate(this.TempPath + "ls.htm");
        }
Exemplo n.º 4
0
 private void label9_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.rad2rrad(0) + "\r" + LunarHelper.rad2rrad(-Math.PI / 2) + "\r" +
                     LunarHelper.rad2rrad(Math.PI) + "\r" + LunarHelper.rad2rrad(-Math.PI) + "\r" +
                     LunarHelper.rad2rrad(Math.PI * 2) + "\r" + LunarHelper.rad2rrad(-Math.PI * 2) + "\r" +
                     LunarHelper.rad2rrad(-Math.PI * 3), "返回结果:");
 }
Exemplo n.º 5
0
        private void frmMainTest_Load(object sender, EventArgs e)
        {
            this.TempPath = this.AddBS(Environment.GetEnvironmentVariable("Temp"));
            this.cmbBaziTypeS.SelectedIndex = 0;

            DateTime nowDT = DateTime.Now;

            this.curTZ = TimeZone.CurrentTimeZone.GetUtcOffset(nowDT).Negate().TotalHours;                  // 中国: 东 8 区
            this.curJD = LunarHelper.NowUTCmsSince19700101(nowDT) / 86400000d - 10957.5 - this.curTZ / 24d; //J2000起算的儒略日数(当前本地时间)
            JD.setFromJD(this.curJD + LunarHelper.J2000);

            this.Caly_y.Text = JD.Y.ToString();

            this.Cml_y.Text   = JD.Y.ToString();
            this.Cml_m.Text   = JD.M.ToString();
            this.Cml_d.Text   = JD.D.ToString();
            this.Cml_his.Text = JD.h + ":" + JD.m + ":" + JD.s.ToString("F0").PadLeft(2, '0');

            this.Cal_y.Text = JD.Y.ToString();
            this.Cal_m.Text = JD.M.ToString();
            this.curJD      = LunarHelper.int2(this.curJD + 0.5);

            this.InitComboBoxes();

            this.ML_calc(BaZiType.ZtyBaZi);
            this.getlunar();

            this.timerTick.Enabled = true;
            this.showClockAndSunMoonInfo();
        }
Exemplo n.º 6
0
        private void ML_calc(BaZiType type)
        {
            OB ob = new OB();

            this.txtBazi.Text = LunarHelper.ML_calc <string>(ob, type, this.curTZ, this.Cml_y.Text, this.Cml_m.Text,
                                                             this.Cml_d.Text, this.Cml_his.Text, this.txtLongitude.Text,
                                                             (BaZiTypeS)this.cmbBaziTypeS.SelectedIndex);
        }
Exemplo n.º 7
0
        private void ActiveElement_Click(object sender, HtmlElementEventArgs e)
        {
            int day = (int)LunarHelper.VAL(this.webBrowserMonth.Document.ActiveElement.InnerText);

            if (day > 0)
            {
                this.showMessD(day - 1);
            }
        }
Exemplo n.º 8
0
 private void label15_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.VAL("001.88") + "\r" +
                     LunarHelper.VAL("001.88", 1) + "\r" +
                     LunarHelper.VAL("001.88", 1L) + "\r" +
                     LunarHelper.VAL(".22") + "\r" +
                     LunarHelper.VAL(".88.22") + "\r" +
                     LunarHelper.VAL(".22E2") + "\r" +
                     LunarHelper.VAL("  2") + "\r" +
                     LunarHelper.VAL("$  2") + "\r", "返回结果:");
 }
Exemplo n.º 9
0
 private void label14_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.VAL("¥+1") + "\r" +
                     LunarHelper.VAL("¥+-1") + "\r" +
                     LunarHelper.VAL("¥-1.2") + "\r" +
                     LunarHelper.VAL("¥$") + "\r" +
                     LunarHelper.VAL("¥-.E-%") + "\r" +
                     LunarHelper.VAL("¥-12.3%") + "\r" +
                     LunarHelper.VAL("A100") + "\r" +
                     LunarHelper.VAL("1.2") + "\r", "返回结果:");
 }
Exemplo n.º 10
0
        private void Sel_Region_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.Sel_Region.Tag = JWdata.JWv[this.Sel_Province.SelectedIndex][this.Sel_Region.SelectedIndex + 1].Substring(0, 4);
            JWdata.JWdecode((string)this.Sel_Region.Tag);
            string strJ = LunarHelper.rad2str2(JWdata.J);

            this.Cal_zdzb.Text = "经度(向西为正) " + strJ +
                                 " 纬度 " + LunarHelper.rad2str2(JWdata.W);
            this.txtLongitude.Text = strJ;
            this.showMessD(-2);
        }
Exemplo n.º 11
0
 private void label16_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.VAL("") + "\r" +
                     LunarHelper.VAL("E3") + "\r" +
                     LunarHelper.VAL("3E") + "\r" +
                     LunarHelper.VAL("3E+") + "\r" +
                     LunarHelper.VAL("3E-") + "\r" +
                     LunarHelper.VAL("3E2") + "\r" +
                     LunarHelper.VAL("3E.2") + "\r" +
                     LunarHelper.VAL(".E2") + "\r" +
                     LunarHelper.VAL("+1") + "\r", "返回结果:");
 }
Exemplo n.º 12
0
 private void label13_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.VAL("1") + "\r" +
                     LunarHelper.VAL("$1") + "\r" +
                     LunarHelper.VAL("$-1") + "\r" +
                     LunarHelper.VAL("-1E3") + "\r" +
                     LunarHelper.VAL("$1E-3") + "\r" +
                     LunarHelper.VAL("-123%") + "\r" +
                     LunarHelper.VAL("ABC") + "\r" +
                     LunarHelper.VAL("123D") + "\r" +
                     LunarHelper.VAL("$+.E+%"), "返回结果:");
 }
Exemplo n.º 13
0
        private void showClockAndSunMoonInfo()
        {
            if (this.Cal_pause.Checked)
            {
                return;
            }
//this.timerTick.Enabled = false;   // C#: Debug
//this.Cal_pause.Checked = true;   // C#: Debug

            DateTime nowDT = DateTime.Now;

            // 显示太阳月亮坐标
            double jd = LunarHelper.NowUTCmsSince19700101(nowDT) / 86400000d - 10957.5; //J2000起算的儒略日数

//jd = 3391.31877640;   // C#: Debug
            jd += JD.deltatT2(jd);
            this.smc.calc(jd, JWdata.J, JWdata.W, 0); //传入力学时间(J2000.0起算)
            this.Cal_zb.Text = smc.toText(1);


            // 显示实时时间
            this.lblLocalClock.Text = nowDT.ToLocalTime().ToString();
            string rg = "";
            double h  = JWdata.SQTimeDifference;
            string v  = JWdata.DaylightInfo;

            jd = LunarHelper.NowUTCmsSince19700101(nowDT) / 86400000d - 10957.5 + h / 24;
            if (v.Length > 0)
            {
                double y1 = JD.Y, y2 = y1; //该时所在年份
                double m1 = double.Parse(v.Substring(0, 2)), m2 = double.Parse(v.Substring(5, 2));
                if (m2 < m1)
                {
                    y2++;
                }
                //nnweek(y,m,n,w)求y年m月第n个星期w的jd
                double J1 = JD.nnweek(y1, m1, double.Parse(v.Substring(2, 1)), double.Parse(v.Substring(3, 1))) - 0.5 - LunarHelper.J2000 + (v[4] - 97) / 24d;
                double J2 = JD.nnweek(y2, m2, double.Parse(v.Substring(7, 1)), double.Parse(v.Substring(8, 1))) - 0.5 - LunarHelper.J2000 + (v[9] - 97) / 24d;
                if (jd >= J1 && jd < J2)
                {
                    jd += 1 / 24d; rg = "¤";
                }                                                      //夏令时
            }
            JD.setFromJD(jd + LunarHelper.J2000);
            this.lblSQClock.Text = JD.D + "日 " + JD.h + ":" + JD.m + ":" + LunarHelper.int2(JD.s) + rg; //与了与clock1同步,秒数取整而不四舍五入
        }
Exemplo n.º 14
0
        private static void Main(string[] args)
        {
            Program  p = new Program();
            Lunar    lun = new Lunar();
            double   curJD, curTZ;
            sun_moon smc = new sun_moon();

            DateTime nowDT = DateTime.Now;

            curTZ = -8;                                                                           //TimeZone.CurrentTimeZone.GetUtcOffset(nowDT).Negate().TotalHours;     // 中国: 东 8 区
            curJD = LunarHelper.NowUTCmsSince19700101(nowDT) / 86400000d - 10957.5 - curTZ / 24d; //J2000起算的儒略日数(当前本地时间)
            JD.setFromJD(curJD + LunarHelper.J2000);
            string Cal_y = JD.Y.ToString();
            string Cal_m = JD.M.ToString();

            curJD = LunarHelper.int2(curJD + 0.5);

            // double By = LunarHelper.year2Ayear<string>(this.Cal_y.Text);
            //// C#: 注: 使用上句也可以, 如果在调用泛型方法时, 不指定类型, C# 编译器将自动推断其类型
            double By = LunarHelper.year2Ayear(Cal_y);    // 自动推断类型为: string
            double Bm = int.Parse(Cal_m);

            lun.yueLiHTML((int)By, (int)Bm, curJD, nowDT.Day);//html月历生成,结果返回在lun中,curJD为当前日期(用于设置今日标识)
            //显示n指定的日期信息
            OB ob = lun.lun[nowDT.Day - 1];
            // double vJ = JWdata.J, vW = JWdata.W;
            double        vJ = -1.9768762660922441, vW = 0.40346194541935582; //广州
            string        thisDaySunMoonInfo = p.RTS1(ob.d0, vJ, vW, curTZ);  // p.RTS1(ob.d0, vJ, vW, curTZ);    // 计算并显示指定日期的日月升降信息
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(LunarHelper.Ayear2year(ob.y) + "年" + ob.m + "月" + ob.d + "日");                            //公历日期
            sb.AppendLine(ob.Lyear3 + "年 星期" + JD.Weeks[(int)(ob.week)] + " " + ob.XiZ);                            // 丁酉年 星期日 狮子座
            sb.AppendLine(ob.Lyear4 + "年 " + ob.Lleap + ob.Lmc + "月" + (ob.Ldn > 29 ? "大 " : "小 ") + ob.Ldc + "日"); // 4715年 润六月大 初八日
            sb.AppendLine(ob.Lyear2 + "年 " + ob.Lmonth2 + "月 " + ob.Lday2 + "日");                                   // 丁酉年 丁未月 戊午日
            sb.AppendLine("回历[" + ob.Hyear + "年" + ob.Hmonth + "月" + ob.Hday + "日]");                               //回历[1438年11月6日]

            Console.WriteLine(thisDaySunMoonInfo);
            Console.WriteLine(sb.ToString());
            Console.ReadLine();
        }
Exemplo n.º 15
0
        private void getNianLi(int dy)
        {
            double y = LunarHelper.year2Ayear(this.Caly_y.Text);

            if (y == -10000)
            {
                return;
            }
            y += dy;
            this.Caly_y.Text = LunarHelper.Ayear2year(y);
            if (y < -4712)
            {
                MessageBox.Show("到底了"); return;
            }

            this.StrToFile("<html><META http-equiv=Content-Type content='text/html; charset=utf-8'><body>\r\n" +
                           "<span style='font-family: 宋体; font-size: 12px; line-height: 18px;'>" +
                           lun.nianLiHTML(y) + "<p></p> \r\n" +
                           lun.nianLi2HTML(y) + "\r\n </span></small></body></html>", this.TempPath + "ls2.htm");

            this.webBrowserYearCal.Navigate(this.TempPath + "ls2.htm");
        }
Exemplo n.º 16
0
        private void getlun(DateTime dt)
        {
            Lunar    lun = new Lunar();
            double   curJD, curTZ;
            sun_moon smc = new sun_moon();

            //DateTime nowDT = DateTime.Now;
            curTZ = -8;                                                                        //TimeZone.CurrentTimeZone.GetUtcOffset(nowDT).Negate().TotalHours;     // 中国: 东 8 区
            curJD = LunarHelper.NowUTCmsSince19700101(dt) / 86400000d - 10957.5 - curTZ / 24d; //J2000起算的儒略日数(当前本地时间)
            JD.setFromJD(curJD + LunarHelper.J2000);
            string Cal_y = JD.Y.ToString();
            string Cal_m = JD.M.ToString();

            curJD = LunarHelper.int2(curJD + 0.5);

            // double By = LunarHelper.year2Ayear<string>(this.Cal_y.Text);
            //// C#: 注: 使用上句也可以, 如果在调用泛型方法时, 不指定类型, C# 编译器将自动推断其类型
            double By = LunarHelper.year2Ayear(Cal_y);    // 自动推断类型为: string
            double Bm = int.Parse(Cal_m);

            lun.yueLiHTML((int)By, (int)Bm, curJD, dt.Day); //html月历生成,结果返回在lun中,curJD为当前日期(用于设置今日标识)
                                                            //显示n指定的日期信息
            ob = lun.lun[dt.Day - 1];
        }
Exemplo n.º 17
0
 private void label1_Click(object sender, EventArgs e)
 {
     MessageBox.Show("*" + LunarHelper.trim("\t 123 \r") + "*", "返回结果:");
 }
Exemplo n.º 18
0
 private void label2_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.year2Ayear(-1) + "\r" + LunarHelper.year2Ayear("B2009") + "\r" +
                     LunarHelper.year2Ayear(10000) + "\r" + LunarHelper.year2Ayear("-4713") + "\r" +
                     LunarHelper.year2Ayear("B0"), "返回结果:");
 }
Exemplo n.º 19
0
        private void showMessD(int n)
        { //显时本月第n日的摘要信息。调用前应先执月历页面生成,产生有效的lun对象
            this.Cal_pan.Text = "";
            if (this.lun.dn == 0 || n >= this.lun.dn)
            {
                return;
            }
            double vJ = JWdata.J, vW = JWdata.W;


            if (n == -1)
            { //鼠标移出日期上方
                this.Cal_pan.Text = "";
                this.Cal5.Tag     = this.Cal5.Text;
            }
            if (n == -2)
            {
                this.Cal5.Text = this.RTS1(this.curJD, vJ, vW, this.curTZ);    // 计算并显示当前日期的日月升降信息
            }
            if (n < 0)
            {
                return;
            }
            //显示n指定的日期信息
            OB     ob = this.lun.lun[n];
            string thisDaySunMoonInfo = this.RTS1(ob.d0, vJ, vW, this.curTZ);    // 计算并显示指定日期的日月升降信息

            StringBuilder sb = new StringBuilder();

            if (true)
            { //鼠标移过日期上方
                sb.AppendLine(LunarHelper.Ayear2year(ob.y) + "年" + ob.m + "月" + ob.d + "日");
                sb.AppendLine(ob.Lyear3 + "年 星期" + JD.Weeks[(int)(ob.week)] + " " + ob.XiZ);
                sb.AppendLine(ob.Lyear4 + "年 " + ob.Lleap + ob.Lmc + "月" + (ob.Ldn > 29 ? "大 " : "小 ") + ob.Ldc + "日");
                sb.AppendLine(ob.Lyear2 + "年 " + ob.Lmonth2 + "月 " + ob.Lday2 + "日");
                sb.AppendLine("回历[" + ob.Hyear + "年" + ob.Hmonth + "月" + ob.Hday + "日]");
                if (ob.yxmc.Length > 0)
                {
                    sb.Append(ob.yxmc + " " + ob.yxsj + " ");
                }
                if (ob.jqmc.Length > 0)
                {
                    sb.AppendLine("定" + ob.jqmc + " " + ob.jqsj);
                }
                else
                {
                    if (ob.Ljq.Length > 0)
                    {
                        sb.AppendLine(ob.Ljq);
                    }
                }
                if (ob.A.Length > 0)
                {
                    sb.Append(ob.A + " ");
                }
                if (ob.B.Length > 0)
                {
                    sb.Append(ob.B + " ");
                }
                if (ob.C.Length > 0)
                {
                    sb.Append(ob.C);
                }

                sb.AppendLine();
                sb.Append("日十二建: " + ob.Ri12Jian);
                this.Cal_pan.Text = sb.ToString() + "\r\n\r\n" + thisDaySunMoonInfo;
            }
        }
Exemplo n.º 20
0
 private void label10_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.mod2(1, 2) + "\r" + LunarHelper.mod2(1.2, 2.2) + "\r" +
                     LunarHelper.mod2(2, 1) + "\r" + LunarHelper.mod2(2.2, 1.2), "返回结果:");
 }
Exemplo n.º 21
0
 private void label11_Click(object sender, EventArgs e)
 {
     JWdata.JWdecode("P3Tg昆明");
     MessageBox.Show("经: " + LunarHelper.rad2str2(JWdata.J) + "\r纬: " + LunarHelper.rad2str2(JWdata.W), "返回结果:");
 }
Exemplo n.º 22
0
 private void label3_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.Ayear2year("-1") + "\r" + LunarHelper.Ayear2year("0") + "\r" +
                     LunarHelper.Ayear2year(2009), "返回结果:");
 }
Exemplo n.º 23
0
 private void label7_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.m2fm(121, 2, 0) + "\r" + LunarHelper.m2fm(121, 0, 1), "返回结果:");
 }
Exemplo n.º 24
0
 private void label6_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.rad2str2(3.14) + "\r" + LunarHelper.rad2str2(-3.14), "返回结果:");
 }
Exemplo n.º 25
0
 private void label5_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.rad2str(3.14, 0) + "\r" + LunarHelper.rad2str(-3.14, 1) +
                     "\r\r " + LunarHelper.str2rad("+179°54'31.49\"") +
                     "\r" + LunarHelper.str2rad("-179°54'31.49\""), "返回结果:");
 }
Exemplo n.º 26
0
 private void label4_Click(object sender, EventArgs e)
 {
     MessageBox.Show(LunarHelper.timeStr2hour("12") + "\r" + LunarHelper.timeStr2hour("12:30") + "\r" +
                     LunarHelper.timeStr2hour("12:30:36"), "返回结果:");
 }