unit dateDetails; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, CategoryButtons; type TdateDetailsFrm = class(TForm) GroupBox1: TGroupBox; jDateLbl: TLabel; gDateLbl: TLabel; hDateLbl: TLabel; Label1: TLabel; Label3: TLabel; Label4: TLabel; GroupBox2: TGroupBox; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; asrLbl: TLabel; ishaLbl: TLabel; dohrLbl: TLabel; sunriseLbl: TLabel; fajrLbl: TLabel; maghribLbl: TLabel; sunsetLbl: TLabel; GroupBox3: TGroupBox; Image2: TImage; Image1: TImage; Image3: TImage; Image6: TImage; Image5: TImage; SpeedButton1: TSpeedButton; Image7: TImage; Image8: TImage; Image4: TImage; Label21: TLabel; EventsDsp: TCategoryButtons; holidayLbl: TCategoryButtons; procedure FormShow(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); private { Private declarations } public { Public declarations } procedure eventClick(Sender: TObject); end; var dateDetailsFrm: TdateDetailsFrm; implementation uses caFace, JalaliLib, HijriLib, prayTimeLib, main, XMLDoc, XMLIntf, xmldom; {$R *.dfm} procedure TdateDetailsFrm.eventClick(Sender: TObject); begin MessageBox(Handle, pchar((Sender as TCategoryButtons).FocusedItem.Hint), 'شرح رویداد', MB_OK); end; procedure TdateDetailsFrm.FormShow(Sender: TObject); var gdate, hdate, jdate : datePack; todayPrTimes : prTimesStr; isHoliday : Boolean; tmpTxt : TStringList; EventsXML : TXMLDocument; CurNode : IXMLNode; i,j, k: Word; newBut : TButtonItem; begin jdate.Year := mainFrm.jClickedDate.Year; jdate.Month := mainFrm.jClickedDate.Month; jdate.Day := mainFrm.jClickedDate.Day; jDateLbl.Caption := IntToStr(jdate.Day) + ' ' + get_jmonth_name(jdate.Month) + ' ' + IntToStr(jdate.Year); gdate := jalali_to_gregorian(jdate.Year, jdate.Month, jdate.Day); gDateLbl.Caption := IntToStr(gdate.Day) + ' ' + ShortMonthNames[gDate.Month] + ' ' + IntToStr(gdate.Year); hdate := gregorian_to_hijri(gdate); hDateLbl.Caption := IntToStr(hdate.Day) + ' ' + get_hmonth_name(hdate.Month) + ' ' + IntToStr(hdate.Year); todayPrTimes := getDatePrayerTimes(gdate.Year, gdate.Month, gdate.Day, mainFrm.lat, mainFrm.lng, mainFrm.tZone); fajrLbl.Caption := todayPrTimes.Fajr; sunriseLbl.Caption := todayPrTimes.Sunrise; dohrLbl.Caption := todayPrTimes.Dhuhr; asrLbl.Caption := todayPrTimes.Asr; sunsetLbl.Caption := todayPrTimes.Sunset; maghribLbl.Caption := todayPrTimes.Maghrib; ishaLbl.Caption := todayPrTimes.Isha; holidayLbl.Visible := False; isHoliday := False; //Parse events XML EventsXML := TXMLDocument.Create(Self); EventsXML.DOMVendor := DOMVendors.Find('OXMLDOM'); EventsXML.XML.Text := mainFrm.getDayEvents(jdate, gdate, hdate); EventsXML.Active := True; //TODO : loop here for hij, jal and gre events and add them to buttons if EventsXML.DocumentElement.ChildNodes.Count > 0 then begin for i := 0 to EventsXML.DocumentElement.ChildNodes.Count - 1 do begin if LowerCase(EventsXML.DocumentElement.ChildNodes.Get(i).NodeName) = 'jal' then j := 0 else if LowerCase(EventsXML.DocumentElement.ChildNodes.Get(i).NodeName) = 'hij' then j := 1 else if LowerCase(EventsXML.DocumentElement.ChildNodes.Get(i).NodeName) = 'gre' then j := 2 else Continue; EventsDsp.Categories[j].Items.Clear; if EventsXML.DocumentElement.ChildNodes.Get(i).ChildNodes.Count > 0 then for k := 0 to EventsXML.DocumentElement.ChildNodes.Get(i).ChildNodes.Count - 1 do begin CurNode := EventsXML.DocumentElement.ChildNodes.Get(i).ChildNodes.Get(k); isHoliday := CurNode.Attributes['holiday'] or isHoliday; newBut := EventsDsp.Categories[j].Items.Add; newBut.Caption := CurNode.Attributes['name']; newBut.OnClick := eventClick; newBut.Hint := CurNode.Text; end; end; end; holidayLbl.Visible := isHoliday; end; procedure TdateDetailsFrm.SpeedButton1Click(Sender: TObject); begin ModalResult := mrOk; end; end.