-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnit5.cpp
138 lines (96 loc) · 3.71 KB
/
Unit5.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit5.h"
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm5 *Form5;
// Òàéìåð âêëþ÷¸í?
int iHours; // Òåêóùèé ÷àñ.
int iMinutes; // Òåêóùàÿ ìèíóòà.
int iAlarmHours; // ×àñ îïîâåùåíèÿ.
int iAlarmMinutes; // Ìèíóòà îïîâåùåíèÿ.
//---------------------------------------------------------------------------
__fastcall TForm5::TForm5(TComponent* Owner)
: TForm(Owner)
{
}
//×ÀÑÛ-------------------------------------------------------------------------
void __fastcall TForm5::Timer1Timer(TObject *Sender)
{
StaticText1->Caption=Now().TimeString();
}
//ÑÒÀÐÒ-------------------------------------------------------------------------
void __fastcall TForm5::AlarmBttnClick(TObject *Sender)
{
Hide();
iAlarmHours=StrToInt(FormatDateTime("h", TimePicker->Time));
iAlarmMinutes=StrToInt(FormatDateTime("n", TimePicker->Time));
Form1->TrayIcon1->Hint="Alarm set to : "+IntToStr(iAlarmHours)+" : "+IntToStr(iAlarmMinutes);
Form1->Label46->Caption="Alarm set to:";
Form1->Label50->Caption=IntToStr(iAlarmHours)+" : "+IntToStr(iAlarmMinutes);
bIsTimerOn=true; // Òàéìåð áóäèëüíèêà çàïóùåí.
Timer2->Enabled=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm5::Timer2Timer(TObject *Sender)
{
StaticText1->Caption=TimeToStr(Time());
if(bIsTimerOn)
{
iHours=StrToInt(FormatDateTime("h", Time()));
iMinutes=StrToInt(FormatDateTime("n", Time())); // …ïîëó÷èì òåêóùåå âðåìÿ…
if(((iHours==iAlarmHours) && (iMinutes>=iAlarmMinutes))|| iHours>iAlarmHours) // …è åñëè îíî ñîâïàëî ñ çàäàííûì ïîëüçîâàòåëåì…
{
String q="\n";
String cap=Memo1->Lines->Text+q+q+"Name :"+Edit1->Text+" Address: "+Edit4->Text+q+"Phone : "+Edit2->Text+q+"E-mail: "+Edit3->Text+q+"Price: "+Edit5->Text+q+"Storey: "+Edit6->Text+" Storeys: "+Edit7->Text+" Rooms: "+Edit8->Text;
wchar_t *temp=new wchar_t[cap.Length()+1];
StringToWideChar(cap,temp,cap.Length()+1);
MediaPlayer->Play();
Timer2->Enabled=false;
while(Application->MessageBox(temp, L"Planner", MB_OK+MB_ICONWARNING)!=idOK)
{
// if(MediaPlayer->Mode==mpStopped){MediaPlayer->Stop(); MediaPlayer->Play();}
}
bIsTimerOn=false;
if(MediaPlayer->Mode==mpPlaying) MediaPlayer->Stop();
TimePicker->Time=StrToTime("0:00:00"); // Ñáðîñ íà íîëü.
Form1->TrayIcon1->Hint="Job done!";
Form1->Label46->Caption="Job";
Form1->Label50->Caption="DONE";
Form1->plan=false;
Free();
}
}
}
//ÑÒÎÏ-------------------------------------------------------------------------
void __fastcall TForm5::FormActivate(TObject *Sender)
{
bIsTimerOn=false; // Áóäèëüíèê âûêëþ÷åí
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm5::Image6Click(TObject *Sender)
{
if(AlarmOpenDialog->Execute())
{
MediaPlayer->Close();
if(AlarmOpenDialog->FileName!="")
MediaPlayer->FileName=AlarmOpenDialog->FileName;
MediaPlayer->Open();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm5::FormClose(TObject *Sender, TCloseAction &Action)
{
Form1->plan=false;
Free();
}
//---------------------------------------------------------------------------
void __fastcall TForm5::CancelAlarmBttnClick(TObject *Sender)
{
Form1->plan=false;
}
//---------------------------------------------------------------------------