Files
ttw_fmx_v10/fCommands.pas
T

158 lines
4.1 KiB
ObjectPascal

unit fCommands;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
System.Rtti, FMX.Grid.Style, FMX.Memo.Types, FMX.Grid, FMX.Layouts, uRecords,
FMX.ListBox, FMX.Memo, FMX.Edit, FMX.Controls.Presentation, FMX.ScrollBox;
type
TfrCommands = class(TFrame)
sgCommands: TStringGrid;
scCommand: TStringColumn;
scResponse: TStringColumn;
GroupBox1: TGroupBox;
Label12: TLabel;
edtCommand: TEdit;
mResponse: TMemo;
Label14: TLabel;
GroupBox7: TGroupBox;
btnAddUserName: TButton;
btnGetDateFollow: TButton;
btnGetAgeAccaunt: TButton;
btnCounterAddtoText: TButton;
cbCounterName: TComboBox;
btnGPT: TButton;
btnRandomUserName: TButton;
btnGetChannelStat: TButton;
btnAIPic: TButton;
btnAddCommand: TButton;
btnEditCommand: TButton;
btnRmCommand: TButton;
cbTextToSpeech: TCheckBox;
GroupBox9: TGroupBox;
lbRandomGroup: TListBox;
lbRandomRespons: TListBox;
edtRandomGroup: TEdit;
edtRandomRespons: TEdit;
btnRandomAdd: TButton;
btnRandomDel: TButton;
btnRmGroup: TButton;
Label4: TLabel;
Label5: TLabel;
GroupBox8: TGroupBox;
edtRandomName: TEdit;
edtOt: TEdit;
edtTo: TEdit;
btnRandAdd: TButton;
btnRandDel: TButton;
sgRandomInt: TStringGrid;
scRIntName: TStringColumn;
IntegerColumn1: TIntegerColumn;
scRIntTo: TIntegerColumn;
GroupBox11: TGroupBox;
btnSoundAdd: TButton;
btnSoundDel: TButton;
edtSoundName: TEdit;
edtSoundFileName: TEdit;
btnSoundOpen: TButton;
tbSoundVolume: TTrackBar;
btnSoundTest: TButton;
sgSAFiles: TStringGrid;
sgSAName: TStringColumn;
sgSAFile: TStringColumn;
GroupBox24: TGroupBox;
btnTextAdd: TButton;
btnTextDel: TButton;
edtTextName: TEdit;
edtTextFileName: TEdit;
btnTextOpen: TButton;
sgTFiles: TStringGrid;
scTFileName: TStringColumn;
scTFileFile: TStringColumn;
OpenDialog1: TOpenDialog;
GroupBox2: TGroupBox;
sgAIGen: TStringGrid;
StringColumn1: TStringColumn;
StringColumn2: TStringColumn;
edtAIGenName: TEdit;
edtAIGenRequest: TEdit;
btnAIGenAdd: TButton;
btnAIGenDel: TButton;
btnAIGetTextUser: TButton;
procedure btnRandAddClick(Sender: TObject);
procedure btnRandDelClick(Sender: TObject);
private
{ Private declarations }
procedure UpdateGridFromArray;
public
{ Public declarations }
RandomCounters: TArray<TRandomCounters>;
end;
implementation
{$R *.fmx}
uses uGeneral;
procedure TfrCommands.btnRandDelClick(Sender: TObject);
var
i, RowIndex: Integer;
begin
RowIndex := sgRandomInt.Row;
if (RowIndex < 0) or (RowIndex > High(RandomCounters)) then Exit;
// Ñäâèãàåì ýëåìåíòû ìàññèâà
for i := RowIndex to High(RandomCounters)-1 do
RandomCounters[i] := RandomCounters[i+1];
SetLength(RandomCounters, Length(RandomCounters) - 1);
UpdateGridFromArray;
DB.SaveGridToTable('sgRandomInt', sgRandomInt);
end;
procedure TfrCommands.UpdateGridFromArray;
var
i: Integer;
begin
sgRandomInt.BeginUpdate;
try
sgRandomInt.RowCount := 1; // Ñáðàñûâàåì ñòðîêè (îñòàâëÿåì òîëüêî çàãîëîâêè)
for i := 0 to High(RandomCounters) do
begin
sgRandomInt.RowCount := i + 1;
sgRandomInt.Cells[0, i] := RandomCounters[i].Name;
sgRandomInt.Cells[1, i] := IntToStr(RandomCounters[i].Ot);
sgRandomInt.Cells[2, i] := IntToStr(RandomCounters[i].ToValue);
end;
finally
sgRandomInt.EndUpdate;
end;
end;
procedure TfrCommands.btnRandAddClick(Sender: TObject);
var
NewRec: TRandomCounters;
begin
NewRec.Name := edtRandomName.Text;
NewRec.Ot := StrToIntDef(edtOt.Text, 0);
NewRec.ToValue := StrToIntDef(edtTo.Text, 100);
SetLength(RandomCounters, Length(RandomCounters) + 1);
RandomCounters[High(RandomCounters)] := NewRec;
UpdateGridFromArray;
// DB.SaveGridToTable('sgRandomInt', sgRandomInt);
DB.SaveRecordArray<TRandomCounters>('RandomCounters', RandomCounters);
edtRandomName.Text := '';
edtOt.Text := '0';
edtTo.Text := '100';
end;
end.