| 1 |
unit Unit1; |
| 2 |
|
| 3 |
interface |
| 4 |
|
| 5 |
uses |
| 6 |
System.SysUtils, System.Types, System.UITypes, System.Classes, |
| 7 |
System.Variants, System.Math, |
| 8 |
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, |
| 9 |
FMX.Menus, FMX.Layouts, FMX.ListBox, FMX.Printer; |
| 10 |
|
| 11 |
type |
| 12 |
TForm1 = class(TForm) |
| 13 |
ListBox1: TListBox; |
| 14 |
Label1: TLabel; |
| 15 |
Label2: TLabel; |
| 16 |
MainMenu1: TMainMenu; |
| 17 |
ListBox2: TListBox; |
| 18 |
Button2: TButton; |
| 19 |
Label3: TLabel; |
| 20 |
MenuItem1: TMenuItem; |
| 21 |
MenuItem2: TMenuItem; |
| 22 |
MenuItem3: TMenuItem; |
| 23 |
MenuItem4: TMenuItem; |
| 24 |
Label4: TLabel; |
| 25 |
Label5: TLabel; |
| 26 |
Label6: TLabel; |
| 27 |
MenuItem5: TMenuItem; |
| 28 |
MenuItem6: TMenuItem; |
| 29 |
Label7: TLabel; |
| 30 |
MenuItem7: TMenuItem; |
| 31 |
procedure Button2Click(Sender: TObject); |
| 32 |
procedure MenuItem2Click(Sender: TObject); |
| 33 |
procedure MenuItem4Click(Sender: TObject); |
| 34 |
procedure MenuItem6Click(Sender: TObject); |
| 35 |
procedure MenuItem7Click(Sender: TObject); |
| 36 |
procedure FormCreate(Sender: TObject); |
| 37 |
private |
| 38 |
{ private ���� } |
| 39 |
Count: integer; |
| 40 |
prt: TPrinter; |
| 41 |
public |
| 42 |
{ public ���� } |
| 43 |
end; |
| 44 |
|
| 45 |
var |
| 46 |
Form1: TForm1; |
| 47 |
|
| 48 |
const |
| 49 |
max = 30; |
| 50 |
|
| 51 |
implementation |
| 52 |
|
| 53 |
{$R *.fmx} |
| 54 |
|
| 55 |
uses Unit2; |
| 56 |
|
| 57 |
procedure TForm1.Button2Click(Sender: TObject); |
| 58 |
var |
| 59 |
i: integer; |
| 60 |
begin |
| 61 |
if ListBox2.Items.Count = 0 then |
| 62 |
begin |
| 63 |
MenuItem2Click(Sender); |
| 64 |
Exit; |
| 65 |
end; |
| 66 |
inc(Count); |
| 67 |
i := Random(ListBox2.Items.Count); |
| 68 |
ListBox1.Items.Insert(0, Format('%d�����F%s���o������', [Count, ListBox2.Items[i]])); |
| 69 |
Label5.Text := ListBox2.Items[i]; |
| 70 |
ListBox2.Items.Delete(i); |
| 71 |
Label1.Text := '�q�b�g�i���o�[���������������������B'; |
| 72 |
Label3.Text := '�i�i�s�����q�b�g�i���o�[��������������������.�j'; |
| 73 |
if Count mod 10 = 0 then |
| 74 |
begin |
| 75 |
if Count >= max div 5 then |
| 76 |
Label1.Text := Count.ToString + '���������B�����������[�`���r���S���������������H'; |
| 77 |
ListBox1.Items.Insert(0, '----- -----'); |
| 78 |
end; |
| 79 |
ListBox1.ScrollBy(0, ListBox1.Height); |
| 80 |
end; |
| 81 |
|
| 82 |
procedure TForm1.FormCreate(Sender: TObject); |
| 83 |
begin |
| 84 |
Label7.Text := Format(Label7.Text, [max]); |
| 85 |
end; |
| 86 |
|
| 87 |
procedure TForm1.MenuItem2Click(Sender: TObject); |
| 88 |
var |
| 89 |
i: integer; |
| 90 |
begin |
| 91 |
if (ListBox1.Items.Count = 0) or |
| 92 |
(MessageDlg('�������Q�[�����I�����������H', TMsgDlgType.mtConfirmation, mbYesNo, 0, |
| 93 |
TMsgDlgBtn.mbYes) = mrYes) then |
| 94 |
begin |
| 95 |
ListBox1.Items.Clear; |
| 96 |
ListBox2.Items.Clear; |
| 97 |
Count := 0; |
| 98 |
Randomize; |
| 99 |
for i := 1 to max do |
| 100 |
ListBox2.Items.Add(IntToStr(i)); |
| 101 |
Label1.Text := '���������������������H'; |
| 102 |
Label3.Text := |
| 103 |
'�i�V�����J�[�h���z������������. �J�[�h���p���T�C�YA6. �q�b�g�i���o�[�������������M�L�����Q����������������������������.�j'; |
| 104 |
Label5.Text := '�u�v'; |
| 105 |
end |
| 106 |
else |
| 107 |
Label1.Text := '���s�������B'; |
| 108 |
end; |
| 109 |
|
| 110 |
procedure TForm1.MenuItem4Click(Sender: TObject); |
| 111 |
begin |
| 112 |
Close; |
| 113 |
end; |
| 114 |
|
| 115 |
procedure TForm1.MenuItem6Click(Sender: TObject); |
| 116 |
const |
| 117 |
size = 120; |
| 118 |
font = 20; |
| 119 |
var |
| 120 |
k: integer; |
| 121 |
temp: TStringList; |
| 122 |
procedure print; |
| 123 |
var |
| 124 |
i, j, k: integer; |
| 125 |
begin |
| 126 |
temp.Clear; |
| 127 |
for i := 1 to max do |
| 128 |
temp.Add(IntToStr(i)); |
| 129 |
Randomize; |
| 130 |
prt.Canvas.font.size := font; |
| 131 |
for i := 1 to 5 do |
| 132 |
for j := 1 to 5 do |
| 133 |
begin |
| 134 |
k := Random(temp.Count); |
| 135 |
prt.Canvas.FillText(RectF(i * size, j * size, (i + 1) * size, |
| 136 |
(j + 1) * size), temp[k], false, 1, [], TTextAlign.Center); |
| 137 |
temp.Delete(k); |
| 138 |
end; |
| 139 |
prt.Canvas.font.size := Label1.TextSettings.font.size; |
| 140 |
prt.Canvas.FillText(RectF(font, 7 * size, 8 * size, 7 * size), |
| 141 |
'�����������������������������������B', false, 1, [], TTextAlign.Leading); |
| 142 |
end; |
| 143 |
|
| 144 |
begin |
| 145 |
if Form2.ShowModal = mrOK then |
| 146 |
begin |
| 147 |
{ |
| 148 |
if (prt is TPrinter)and(prt.Printing = true) then |
| 149 |
begin |
| 150 |
Showmessage('�����������B���������������B'); |
| 151 |
Exit; |
| 152 |
end; |
| 153 |
} |
| 154 |
temp := TStringList.Create; |
| 155 |
try |
| 156 |
prt := Printer; |
| 157 |
prt.ActivePrinter.SelectDPI(300, 300); |
| 158 |
prt.Orientation := TPrinterOrientation.poPortrait; |
| 159 |
prt.Canvas.SetSize(Floor(4.13 * prt.ActivePrinter.ActiveDPI.X), |
| 160 |
Floor(5.83 * prt.ActivePrinter.ActiveDPI.Y)); |
| 161 |
k := 1; |
| 162 |
prt.BeginDoc; |
| 163 |
while True do |
| 164 |
begin |
| 165 |
print; |
| 166 |
if StrToInt(Form2.SpinBox1.Text) > k then |
| 167 |
prt.NewPage |
| 168 |
else |
| 169 |
break; |
| 170 |
inc(k); |
| 171 |
end; |
| 172 |
prt.EndDoc; |
| 173 |
finally |
| 174 |
temp.Free; |
| 175 |
end; |
| 176 |
end; |
| 177 |
end; |
| 178 |
|
| 179 |
procedure TForm1.MenuItem7Click(Sender: TObject); |
| 180 |
begin |
| 181 |
Button2Click(Sender); |
| 182 |
end; |
| 183 |
|
| 184 |
end. |