Тема: Допоможіть розібратись!
Що я тільки не робила, а воно все викидає помилки. Підкажіть, що не так
unit Unit2;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
FMX.Controls.Presentation, FMX.Objects, FMX.Colors, FMX.Gestures, FMX.Platform.Android;
type
TForm2 = class(TForm)
ToolBar1: TToolBar;
Label1: TLabel;
Label2: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Label3: TLabel;
ColorPicker1: TColorPicker;
Button1: TButton;
GestureManager1: TGestureManager;
Rectangle1: TRectangle;
PaintBox1: TPaintBox;
Switch1: TSwitch;
procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo;
var Handled: Boolean);
procedure PaintBox1Paint(Sender: TObject; Canvas: TCanvas);
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
procedure Button1Click(Sender: TObject);
procedure Switch1Switch(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
thickness: integer;
Itsel: integer;
size: integer;
implementation
{$R *.fmx}
{$R *.XLgXhdpiTb.fmx ANDROID}
procedure ExitConfirm;
begin
MessageDlg ( 'Хочете вийти!', System.UITypes.TMsgDlgType.mtInformation,
[
System.UITypes.TMsgDlgBtn.mbYes,
System.UITypes.TMsgDlgBtn.mbNo
], 0,
procedure (const AResult: TModalResult)
begin
case AResult
of
mrYES:
begin
MainActivity.Finish;
end;
mrNo:
begin
end;
end;
end
)
end;
procedure ThicknessInc (var l: Tlabel);
begin
thickness:= thickness + 1;
if thickness> 10 then thickness:= 10;
l.Text:= 'Товщина лінії:' + inttostr (thickness);
end;
procedure ThicknessDec (var l: Tlabel);
begin
thickness:= thickness-1;
if thickness <1 then thickness:= 1;
l.Text:= 'Товщина лінії:' + inttostr (thickness)
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
if Radiobutton1.IsChecked then Itsel:= 1;
if radiobutton2.IsChecked then Itsel:= 2;
if radiobutton3.IsChecked then Itsel:= 3;
Rectangle1.Visible:= false;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
thickness:= 1;
size:= 40;
itsel:= 1;
end;
procedure TForm2.FormGesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
begin
case EventInfo.GestureID of
sgiLeft:
begin
ThicknessInc (Label2);
PaintBox1.Repaint;
end;
sgiRight:
begin
thicknessDec (Label2);
PaintBox1.Repaint;
end;
sgiCircle:
begin
Rectangle1.Visible:= true;
PaintBox1.Repaint;
end;
end;
end;
procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
Begin
if Key = vkVolumeUp then
begin
Key:= 0;
end;
if Key = vkVolumeDown then
begin
Key:= 0;
end;
if Key = vkHardwareBack then
begin
Key:= 0;
end;
end;
procedure TForm2.PaintBox1Paint(Sender: TObject; Canvas: TCanvas);
var p1, p2: tpoint;
x0, y0: integer;
begin
PaintBox1.Canvas.Stroke.Color:= ColorPicker1.Color;
case Itsel of
1: PaintBox1.Canvas.Stroke.Dash:= TStrokeDash.Solid;
2: PaintBox1.Canvas.Stroke.Dash:= TStrokeDash.Dot;
3: PaintBox1.Canvas.Stroke.Dash:= TStrokeDash.Dash;
PaintBox1.Canvas.Stroke.Thickness:= thickness;
PaintBox1.Canvas.BeginScene;
x0:= Round (632 / 2);
y0:= Round (416 / 2);
p1.X:= x0 + size;
p1.Y:= y0 + size;
p2.X:= x0 + size;
p2.Y:= y0-size;
PaintBox1.Canvas.DrawLine (p1, p2,1.0);
p1.X:= x0 + size;
p1.Y:= y0 + size;
p2.X:= x0-size;
p2.Y:= y0 + size;
PaintBox1.Canvas.DrawLine (p1, p2,1.0);
p1.X:= x0-size;
p1.Y:= y0 + size;
p2.X:= x0-size;
p2.Y:= y0-size;
PaintBox1.Canvas.DrawLine (p1, p2 , 1.0);
p1.X:= x0-size;
p1.Y:= y0-size;
p2.X:= x0 + size;
p2.Y:= y0-size;
PaintBox1.Canvas.DrawLine (p1, p2 , 1.0);
p1.X:= x0-size;
p1.Y:= y0-size;
p2.X:= x0 + size;
p2.Y:= y0 + size;
PaintBox1.Canvas.DrawLine (p1, p2,1.0);
p1.X:= x0-size;
p1.Y:= y0 + size;
p2.X:= x0 + size;
p2.Y:= y0-size;
PaintBox1.Canvas.DrawLine (p1, p2,1.0);
PaintBox1.Canvas.EndScene;
end;
end;
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char;
Shift: TShiftState);
begin
if Key = vkVolumeUp then
begin
Key:= 0;
size:= size-5;
if size < 5 then
size:= 5;
PaintBox1.Repaint;
end;
if Key = vkVolumeDown then
begin
Key:= 0;
size:= size + 5;
if size>150 then size:= 150;
PaintBox1.Repaint;
end;
if Key = vkHardwareBack then
begin
Key:= 0;
ExitConfirm;
end;
end;
procedure TForm2.Switch1Switch(Sender: TObject);
begin
if Switch1.IsChecked then
begin
ExitConfirm;
Switch1.IsChecked:= false;
end;
end;
end.