unit caFace; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, DateUtils, JalaliLib, ExtCtrls, MNSpeedButton, HijriLib, Menus; type TcaFaceFrm = class(TForm) Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; monthLbl: TLabel; PreMon: TSpeedButton; NextMon: TSpeedButton; DaysPanel: TPanel; yearLbl: TLabel; PreYear: TSpeedButton; NextYear: TSpeedButton; BotD17: TMNSpeedButton; BotD16: TMNSpeedButton; BotD15: TMNSpeedButton; BotD12: TMNSpeedButton; BotD13: TMNSpeedButton; BotD14: TMNSpeedButton; BotD11: TMNSpeedButton; BotD21: TMNSpeedButton; BotD22: TMNSpeedButton; BotD23: TMNSpeedButton; BotD24: TMNSpeedButton; BotD25: TMNSpeedButton; BotD26: TMNSpeedButton; BotD27: TMNSpeedButton; BotD31: TMNSpeedButton; BotD32: TMNSpeedButton; BotD33: TMNSpeedButton; BotD34: TMNSpeedButton; BotD35: TMNSpeedButton; BotD36: TMNSpeedButton; BotD37: TMNSpeedButton; BotD41: TMNSpeedButton; BotD42: TMNSpeedButton; BotD43: TMNSpeedButton; BotD44: TMNSpeedButton; BotD45: TMNSpeedButton; BotD46: TMNSpeedButton; BotD47: TMNSpeedButton; BotD51: TMNSpeedButton; BotD52: TMNSpeedButton; BotD53: TMNSpeedButton; BotD54: TMNSpeedButton; BotD55: TMNSpeedButton; BotD56: TMNSpeedButton; BotD57: TMNSpeedButton; BotD61: TMNSpeedButton; BotD62: TMNSpeedButton; BotD63: TMNSpeedButton; BotD64: TMNSpeedButton; BotD65: TMNSpeedButton; BotD66: TMNSpeedButton; BotD67: TMNSpeedButton; DayPopup: TPopupMenu; N1: TMenuItem; Image1: TImage; Image2: TImage; Image3: TImage; Image4: TImage; Image5: TImage; Image6: TImage; Image7: TImage; Image8: TImage; SpeedButton1: TSpeedButton; procedure FormShow(Sender: TObject); procedure PreMonClick(Sender: TObject); procedure NextMonClic(Sender: TObject); procedure FormCreate(Sender: TObject); procedure PreYearClick(Sender: TObject); procedure NextYearClick(Sender: TObject); procedure Panel1Click(Sender: TObject); procedure FormMouseEnter(Sender: TObject); procedure FormMouseLeave(Sender: TObject); procedure BotD11Click(Sender: TObject); procedure N1Click(Sender: TObject); procedure SpeedButton1Click(Sender: TObject); private { Private declarations } public { Public declarations } jCurrDate: datePack; procedure ArrangeButtons(jShowDate: datePack; MarkCurrentDay: Boolean = true); procedure PutFrmOnCordinates(tgForm : TForm); procedure CaFadeOut(); end; var caFaceFrm: TcaFaceFrm; implementation uses dateDetails, main; {$R *.dfm} procedure TcaFaceFrm.ArrangeButtons(jShowDate: datePack; MarkCurrentDay: Boolean = true); var MonStDayOfWeek : Word; i, j, jd : Word; gDate, hDate : datePack; begin DaysPanel.Visible := False; if (jShowDate.Day = 0) or (jShowDate.Year = 0) or (jShowDate.Month = 0) then jShowDate := jNow; MonStDayOfWeek := month_first_day_of_week(jShowDate.Year, jShowDate.Month); monthLbl.Caption := get_jmonth_name(jShowDate.Month); yearLbl.Caption := IntToStr(jShowDate.Year); //Hide unnessecary bottons from starting for i := 1 to MonStDayOfWeek-1 do (FindComponent('BotD1'+IntToStr(i)) as TMNSpeedButton).Visible := False; //number the bottons to the end of mounth i := MonStDayOfWeek; j := 1; for jd := 1 to month_day_count(jShowDate.Year, jShowDate.Month) do begin if (i mod 8) = 0 then begin j := j + 1; i := 1; end; gDate := jalali_to_gregorian(jShowDate.Year, jShowDate.Month, jd); hDate := gregorian_to_hijri(gDate.Year, gDate.Month, gDate.Day); (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).JalDay := IntToStr(jd); (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).GregDay := IntToStr(gDate.Day); (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).HijDay := IntToStr(hDate.Day); (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).Hint := IntToStr(jd) +' '+ get_jmonth_name(jShowDate.Month) +' '+ IntToStr(jShowDate.Year)+#13+ IntToStr(hDate.Day)+' '+ get_hmonth_name(hDate.Month) +' '+ IntToStr(hDate.Year)+#13+ IntToStr(gDate.Day)+' '+ ShortMonthNames[gdate.Month] +' '+ IntToStr(gDate.Year); (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).Tag := jd; (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).Visible := True; if (jShowDate.Day = jd) and (MarkCurrentDay) then (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).JalFont.Style := [fsBold] else (FindComponent('BotD'+ IntToStr(j) + IntToStr(i)) as TMNSpeedButton).JalFont.Style := []; i := i + 1; end; //Hide unnessecary bottons from end if any if (i <= 7) then for i := i to 7 do (FindComponent('BotD'+IntToStr(j)+IntToStr(i)) as TMNSpeedButton).Visible := False; if (j < 6) then begin for i := 1 to 7 do (FindComponent('BotD6'+IntToStr(i)) as TMNSpeedButton).Visible := False; end; DaysPanel.Visible := True; end; procedure TcaFaceFrm.BotD11Click(Sender: TObject); begin mainFrm.jClickedDate.Year := jCurrDate.Year; mainFrm.jClickedDate.Month := jCurrDate.Month; mainFrm.jClickedDate.Day := (Sender as TMNSpeedButton).Tag; DayPopup.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y); end; procedure TcaFaceFrm.CaFadeOut; begin while caFaceFrm.AlphaBlendValue > 50 do begin caFaceFrm.AlphaBlendValue := caFaceFrm.AlphaBlendValue - 3; end; caFaceFrm.Hide; end; procedure TcaFaceFrm.FormCreate(Sender: TObject); begin jCurrDate := jNow; end; procedure TcaFaceFrm.FormMouseEnter(Sender: TObject); begin { while AlphaBlendValue < 255 do begin AlphaBlendValue := AlphaBlendValue + 1; Sleep(8); end; } AlphaBlendValue := 255; end; procedure TcaFaceFrm.FormMouseLeave(Sender: TObject); begin if (ScreenToClient(Mouse.CursorPos).X >=0) and (ScreenToClient(Mouse.CursorPos).Y >= 0) then Exit; while AlphaBlendValue > 150 do begin AlphaBlendValue := AlphaBlendValue - 1; Sleep(8); end; end; procedure TcaFaceFrm.FormShow(Sender: TObject); begin ArrangeButtons(jCurrDate); PutFrmOnCordinates(Self); AlphaBlendValue := 150; end; procedure TcaFaceFrm.Panel1Click(Sender: TObject); begin ShowMessage('sdafsd'); end; procedure TcaFaceFrm.PreMonClick(Sender: TObject); begin if jCurrDate.Month > 1 then jCurrDate.Month := jCurrDate.Month - 1 else begin jCurrDate.Month := 12; jCurrDate.Year := jCurrDate.Year - 1; end; ArrangeButtons(jCurrDate, (jCurrDate.Year = jNow.Year) and (jCurrDate.Month = jNow.Month) and (jCurrDate.Day = jNow.Day)); end; procedure TcaFaceFrm.PreYearClick(Sender: TObject); begin jCurrDate.Year := jCurrDate.Year - 1; ArrangeButtons(jCurrDate, (jCurrDate.Year = jNow.Year) and (jCurrDate.Month = jNow.Month) and (jCurrDate.Day = jNow.Day)); end; procedure TcaFaceFrm.PutFrmOnCordinates(tgForm : TForm); var hTaskBar : HWND; taRect : TRect; begin hTaskBar := FindWindow('Shell_TrayWnd', nil); if hTaskbar <> 0 then begin GetWindowRect(hTaskBar, taRect); if (taRect.Bottom = Screen.Height) and (taRect.Left = 0) and (taRect.Right = Screen.Width) then begin tgForm.Left := Screen.Width - tgForm.Width; tgForm.Top := taRect.Top - tgForm.Height; end else if (taRect.Right = Screen.Width) and (taRect.Top = 0) and (taRect.Bottom = Screen.Height) then begin tgForm.Left := taRect.Left - tgForm.Width; tgForm.Top := Screen.Height - tgForm.Height; end else if (taRect.Left = 0) and (taRect.Top = 0) and (taRect.Right = Screen.Width) then begin tgForm.Left := Screen.Width - tgForm.Width; tgForm.Top := taRect.Bottom; end else if (taRect.Top = 0) and (taRect.Left = 0) and (taRect.Bottom = Screen.Height) then begin tgForm.Left := taRect.Right; tgForm.Top := Screen.Height - tgForm.Height; end; end else begin tgForm.Left := Screen.Width - tgForm.Width; tgForm.Top := Screen.Height - tgForm.Height; end; end; procedure TcaFaceFrm.SpeedButton1Click(Sender: TObject); begin CaFadeOut; end; procedure TcaFaceFrm.N1Click(Sender: TObject); begin { if dateDetailsFrm.Showing then begin ShowMessage('شما در حال مشاهده جزئیات تاریخ دیگری هستید.'+ #13 + 'لطفا ابتدا آن پنجره را ببندید.'); Exit; end;} with TdateDetailsFrm.Create(nil) do try ShowModal; finally Free; end; end; procedure TcaFaceFrm.NextMonClic(Sender: TObject); begin if jCurrDate.Month < 12 then jCurrDate.Month := jCurrDate.Month + 1 else begin jCurrDate.Month := 1; jCurrDate.Year := jCurrDate.Year + 1; end; ArrangeButtons(jCurrDate, (jCurrDate.Year = jNow.Year) and (jCurrDate.Month = jNow.Month) and (jCurrDate.Day = jNow.Day)); end; procedure TcaFaceFrm.NextYearClick(Sender: TObject); begin jCurrDate.Year := jCurrDate.Year + 1; ArrangeButtons(jCurrDate, (jCurrDate.Year = jNow.Year) and (jCurrDate.Month = jNow.Month) and (jCurrDate.Day = jNow.Day)); end; end.