protected void Calendar01_SelectionChanged(object sender, EventArgs e) { using DataTable dtDate = new CglData().GetDateData(Calendar01.SelectedDate.Date); DataRow drDAte = dtDate.NewRow(); // 找農曆 TaiwanLunisolarCalendar tlc = new TaiwanLunisolarCalendar(); int leapMouth = tlc.GetLeapMonth(tlc.GetYear(Calendar01.SelectedDate.Date)); int LuniMouth = tlc.GetMonth(Calendar01.SelectedDate.Date); if (leapMouth > 0) { if (LuniMouth == leapMouth) { LuniMouth = leapMouth - 1; } else if (LuniMouth > leapMouth) { LuniMouth -= 1; } } drDAte["lngDateSN"] = string.Format(InvariantCulture, "{0}{1:d2}{2:d2}", Calendar01.SelectedDate.Year, Calendar01.SelectedDate.Month, Calendar01.SelectedDate.Day); drDAte["lngCDateSN"] = string.Format(InvariantCulture, "{0}{1:d2}{2:d2}", tlc.GetYear(Calendar01.SelectedDate.Date), LuniMouth, tlc.GetDayOfMonth(Calendar01.SelectedDate.Date)); //找紫微 StuPurple stuTemp = new StuPurple { StrWYear = Calendar01.SelectedDate.Year.ToString(InvariantCulture), StrWMonth = Calendar01.SelectedDate.Month.ToString("d2", InvariantCulture), StrWDay = Calendar01.SelectedDate.Day.ToString("d2", InvariantCulture), StrWHour = "YY11", IntGender = CglPurple.Gender.MalePlus }; stuTemp.Init(); foreach (KeyValuePair <string, string> KeyPair in stuTemp.DicUpdateData) { if (KeyPair.Key != "lngDateSN") { if (KeyPair.Value.Length >= 4) { drDAte[KeyPair.Key] = KeyPair.Value.Substring(0, 4); } else { drDAte[KeyPair.Key] = KeyPair.Value; } } } // dtDate.Rows.Add(drDAte); GridView gvDate = new GalaxyApp().CreatGridView("gvDate", " gltabel ", dtDate, true, true); gvDate.DataBind(); pnlCalendar.Controls.Add(gvDate); // 一些使用的範例程式 //StringBuilder stringBuilder = new StringBuilder(0,8000); //for (int i = 2007; i <= 2050; i++) //{ // CNDate cd1 = new CNDate(new DateTime(i, Calendar01.SelectedDate.Date.Month, Calendar01.SelectedDate.Date.Day)); // stringBuilder.AppendLine("計算 " + i + "年隔年農曆過年的國曆日期:" + cd1.GetNextLunarNewYearDate().ToLongDateString() + "<br/>"); //} //CNDate cd = new CNDate(Calendar01.SelectedDate); //stringBuilder.AppendLine("今年農曆天數:" + cd.LunarYearDays(2007).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 01 月農曆天數:" + cd.LunarMonthDays(2007, 1).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 02 月農曆天數:" + cd.LunarMonthDays(2007, 2).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 03 月農曆天數:" + cd.LunarMonthDays(2007, 3).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 04 月農曆天數:" + cd.LunarMonthDays(2007, 4).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 05 月農曆天數:" + cd.LunarMonthDays(2007, 5).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 06 月農曆天數:" + cd.LunarMonthDays(2007, 6).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 07 月農曆天數:" + cd.LunarMonthDays(2007, 7).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 08 月農曆天數:" + cd.LunarMonthDays(2007, 8).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 09 月農曆天數:" + cd.LunarMonthDays(2007, 9).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 10 月農曆天數:" + cd.LunarMonthDays(2007, 10).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 11 月農曆天數:" + cd.LunarMonthDays(2007, 11).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今年 12 月農曆天數:" + cd.LunarMonthDays(2007, 12).ToString(InvariantCulture) + "<br/>"); //stringBuilder.AppendLine("今天的農曆日期:" + cd.GetLunarHolDay() + "<br/>"); //stringBuilder.AppendLine("今年的農曆潤月月份:" + cd.GetLeapMonth(2007) + "<br/>"); //stringBuilder.AppendLine("計算國曆當天對應的節氣:" + cd.LGetLunarHolDay() + "<br/>"); //stringBuilder.AppendLine("計算今年農曆過年的國曆日期:" + cd.GetLunarNewYearDate().ToLongDateString() + "<br/>"); //lblCC.Text = stringBuilder.ToString(); }
private void BtnCreate_Click(object sender, RoutedEventArgs e) { stuOptionPurple.Init(); if (sp00.Children.Count > 0) { sp00.Children.Clear(); } StackPanel sp000; Label lblsp00; #region 顯示四柱 干支 foreach (var KeyValue in stuOptionPurple.Dic12LocationShow["00"]) { sp000 = new StackPanel() { Orientation = Orientation.Horizontal }; lblsp00 = new Label() { Name = KeyValue.Key, Width = 380, FontSize = 11, Content = KeyValue.Value }; sp000.Children.Add(lblsp00); sp00.Children.Add(sp000); } #endregion 顯示四柱 干支 #region 顯示十二宮 Dictionary <string, WrapPanel> dic12StackPanel = new Dictionary <string, WrapPanel>(); if (wp01.Children.Count > 0) { wp01.Children.Clear(); } dic12StackPanel.Add("01", wp01); if (wp02.Children.Count > 0) { wp02.Children.Clear(); } dic12StackPanel.Add("02", wp02); if (wp03.Children.Count > 0) { wp03.Children.Clear(); } dic12StackPanel.Add("03", wp03); if (wp04.Children.Count > 0) { wp04.Children.Clear(); } dic12StackPanel.Add("04", wp04); if (wp05.Children.Count > 0) { wp05.Children.Clear(); } dic12StackPanel.Add("05", wp05); if (wp06.Children.Count > 0) { wp06.Children.Clear(); } dic12StackPanel.Add("06", wp06); if (wp07.Children.Count > 0) { wp07.Children.Clear(); } dic12StackPanel.Add("07", wp07); if (wp08.Children.Count > 0) { wp08.Children.Clear(); } dic12StackPanel.Add("08", wp08); if (wp09.Children.Count > 0) { wp09.Children.Clear(); } dic12StackPanel.Add("09", wp09); if (wp10.Children.Count > 0) { wp10.Children.Clear(); } dic12StackPanel.Add("10", wp10); if (wp11.Children.Count > 0) { wp11.Children.Clear(); } dic12StackPanel.Add("11", wp11); if (wp12.Children.Count > 0) { wp12.Children.Clear(); } dic12StackPanel.Add("12", wp12); for (int i = 1; i <= 12; i++) { string strLocation = string.Format("{0}", i.ToString("D2")); int intColor = 0; foreach (var KeyValue in stuOptionPurple.Dic12LocationShow[strLocation]) { intColor += 13; Label lblLabel = new Label() { Name = KeyValue.Key, FontSize = 11, Width = 90 }; if (stuOptionPurple.DicStar.ContainsKey(KeyValue.Key)) { lblLabel.Background = stuOptionPurple.DicStar[KeyValue.Key].BrushColor; } else { lblLabel.Background = Brushes.White; } lblLabel.Padding = new Thickness(0); lblLabel.Content = KeyValue.Value; dic12StackPanel[strLocation].Children.Add(lblLabel); } } #endregion 顯示十二宮 }