Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit MainKuKuha;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, ExtCtrls, StdCtrls, Vcl.Buttons, System.Actions, Vcl.ActnList,
- Vcl.PlatformDefaultStyleActnCtrls, Vcl.ActnMan, Vcl.Menus, Winapi.MMSystem,
- Vcl.Imaging.pngimage, Vcl.MPlayer;
- type
- TKukuhaForm = class(TForm)
- Clocks: TImage;
- KuKuHa: TImage;
- MainMenu1: TMainMenu;
- N1: TMenuItem;
- N2: TMenuItem;
- Timer: TTimer;
- PaintBox1: TPaintBox;
- MediaPlayer1: TMediaPlayer;
- ModeLabel: TLabel;
- N3: TMenuItem;
- N4: TMenuItem;
- N5: TMenuItem;
- procedure DrawArrows(DrawColor: TColor);
- procedure AboutClick(Sender: TObject);
- procedure DeveloperInfoClick(Sender: TObject);
- procedure TimerTimer(Sender: TObject);
- procedure PaintBox1Paint(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- procedure Button1Click(Sender: TObject);
- procedure N4Click(Sender: TObject);
- procedure N5Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- KukuhaForm: TKukuhaForm;
- Counter, MaxCount: integer;
- HourArrow,MinArrow, SecArrow: Integer;
- Hour, min, sec, msec: word;
- HourAngle, MinAngle, SecAngle: real;
- implementation
- {$R *.dfm}
- procedure TKukuhaForm.AboutClick(Sender: TObject);
- begin
- application.MessageBox('Данная программа реализует часы с кукушкой, работающие в двух режимах:'#13#10'1. По системеному времени.'#13#10'2. x540 режим (полный оборот минутной стрелки за 80 сек).', 'О программе');
- end;
- procedure TKukuhaForm.Button1Click(Sender: TObject);
- begin
- PlaySound('3KyKy.wav',0, SND_ASYNC);
- end;
- procedure TKukuhaForm.DeveloperInfoClick(Sender: TObject);
- begin
- application.MessageBox('Данная программа написана Вакарём Егором'#13#10'студентом группы 151002.','О разработчике');
- end;
- procedure TKukuhaForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
- var
- WND: HWND;
- lpCaption, lpText: PChar;
- Tip: Integer;
- begin
- WND := KuKuHaForm.Handle;
- lpCaption := 'Выход';
- lpText := 'Вы уверены, что хотите выйти?';
- Tip := MB_YESNO + MB_ICONINFORMATION + MB_DEFBUTTON2;
- case MessageBox(WND, lpText, lpCaption, Tip) Of
- IDYES : CanClose := True;
- IDNO : CanClose := False;
- end
- end;
- procedure TKukuhaForm.FormCreate(Sender: TObject);
- begin
- Counter := 1501;
- DecodeTime(Time,Hour,min,sec,msec);
- HourAngle := Hour;
- MinAngle := Min;
- SecAngle := Sec;
- end;
- procedure TKukuhaForm.N4Click(Sender: TObject);
- begin
- ModeLabel.Caption :='';
- end;
- procedure TKukuhaForm.N5Click(Sender: TObject);
- begin
- ModeLabel.Caption :='1';
- end;
- procedure TKukuhaForm.PaintBox1Paint(Sender: TObject);
- var
- i: byte;
- begin
- PaintBox1.Canvas.Pen.Width:=5;
- PaintBox1.Canvas.MoveTo(PaintBox1.Width div 2,PaintBox1.Height div 2);
- PaintBox1.Canvas.LineTo((PaintBox1.Width div 2)+round(35*sin(2*pi*(HourAngle + MinAngle/60)/12)),(PaintBox1.Height div 2)-round(35*cos(2*pi*(HourAngle + MinAngle/60)/12)));
- PaintBox1.Canvas.Pen.Width:=3;
- PaintBox1.Canvas.MoveTo(PaintBox1.Width div 2,PaintBox1.Height div 2);
- PaintBox1.Canvas.LineTo((PaintBox1.Width div 2)+round(45*sin(2*pi*(MinAngle + SecAngle/60)/60)),(PaintBox1.Height div 2)-round(45*cos(2*pi*(MinAngle + SecAngle/60)/60)));
- PaintBox1.Canvas.Pen.Width:=2;
- PaintBox1.Canvas.MoveTo(PaintBox1.Width div 2,PaintBox1.Height div 2);
- PaintBox1.Canvas.LineTo((PaintBox1.Width div 2)+round(60*sin(SecAngle/60*(2*pi))),(PaintBox1.Height div 2)-round(60*cos(SecAngle/60*(2*pi))));
- end;
- procedure TKukuhaForm.TimerTimer(Sender: TObject);
- begin
- DrawArrows(clWhite);
- if ModeLabel.Caption = '' then
- begin
- DecodeTime(Time,Hour,min,sec,msec);
- HourAngle := Hour;
- MinAngle := Min;
- SecAngle := Sec;
- end
- else
- begin
- SecAngle := SecAngle + 1;
- MinAngle:= MinAngle + 0.08;
- HourAngle := HourAngle + 0.001;
- end;
- DrawArrows(clBlack);
- end;
- procedure TKukuhaForm.DrawArrows(DrawColor: TColor);
- var
- TempHourX, TempHourY: Real;
- begin
- with PaintBox1.Canvas do
- begin
- PaintBox1.Canvas.Pen.Color := DrawColor;
- PaintBox1.Canvas.Pen.Width:=5;
- PaintBox1.Canvas.MoveTo(PaintBox1.Width div 2,PaintBox1.Height div 2);
- TempHourX := 35*sin(2*pi*(HourAngle + MinAngle/60)/12);
- TempHourY := 35*cos(2*pi*(HourAngle + MinAngle/60)/12);
- PaintBox1.Canvas.LineTo((PaintBox1.Width div 2)+round(TempHourX),(PaintBox1.Height div 2)-round(TempHourY));
- PaintBox1.Canvas.Pen.Width:=3;
- PaintBox1.Canvas.MoveTo(PaintBox1.Width div 2,PaintBox1.Height div 2);
- PaintBox1.Canvas.LineTo((PaintBox1.Width div 2)+round(45*sin(2*pi*(MinAngle + SecAngle/60)/60)),(PaintBox1.Height div 2)-round(45*cos(2*pi*(MinAngle + SecAngle/60)/60)));
- PaintBox1.Canvas.Pen.Width:=2;
- PaintBox1.Canvas.MoveTo(PaintBox1.Width div 2,PaintBox1.Height div 2);
- PaintBox1.Canvas.LineTo((PaintBox1.Width div 2)+round(60*sin(SecAngle/60*(2*pi))),(PaintBox1.Height div 2)-round(60*cos(SecAngle/60*(2*pi))));
- end;
- if (Counter > 1500) then
- begin
- if (Abs(TempHourX) < 0.1) then
- begin
- Counter := 0;
- KuKuHa.Visible := True;
- if (Abs(TempHourY + 35) < 0.1) then
- begin
- MaxCount := 1400;
- MediaPlayer1.FileName := '..\..\ku_6.mp3';
- end
- else
- begin
- MaxCount := 840;
- MediaPlayer1.FileName := '..\..\ku_12.mp3'
- end;
- MediaPlayer1.Open;
- MediaPlayer1.Play;
- end;
- if (Abs(TempHourX + 35) < 0.1) then
- begin
- MaxCount := 1230;
- Counter := 0;
- KuKuHa.Visible := True;
- MediaPlayer1.FileName := '..\..\ku_9.mp3';
- MediaPlayer1.Open;
- MediaPlayer1.Play;
- end;
- if (Abs(TempHourX - 35) < 0.1) then
- begin
- MaxCount := 1400;
- Counter := 0;
- KuKuHa.Visible := True;
- MediaPlayer1.FileName := '..\..\ku_3.mp3';
- MediaPlayer1.Open;
- MediaPlayer1.Play;
- end;
- end;
- if counter > MaxCount then
- begin
- KuKuHa.Visible := False;
- end;
- Inc(counter);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement