Rapid Design FMX Component
unit MVUnit; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Layouts, FMX.Objects, FMX.Controls.Presentation, FMX.StdCtrls, RDuDigitalNumber, RDuHorzSlideBar, RDuRotaryKnob, RDuAngularGauge, FMX.Media, RDuColorCheckBox, RDuButtonSet; type TForm1 = class(TForm) RDAngularGauge1: TRDAngularGauge; RDRotaryKnob1: TRDRotaryKnob; RDHorzSlideBar1: TRDHorzSlideBar; RDN2: TRDDigitalNumber; RDN3: TRDDigitalNumber; RDN1: TRDDigitalNumber; Timer1: TTimer; Layout1: TLayout; Text1: TText; Layout2: TLayout; Layout3: TLayout; RDButtonSet1: TRDButtonSet; RDColorCheckBox1: TRDColorCheckBox; procedure RDRotaryKnob1DialChange(Sender: TObject); procedure RDHorzSlideBar1Change(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); procedure RDButtonSet1ButtonSetClick(Sender: TObject); procedure FormCreate(Sender: TObject); private procedure One_Vibration; { Private declarations } public { Public declarations } end; var Form1: TForm1; BPM : integer = 60; Count : integer = 0; IsInc : boolean = TRUE; implementation {$IFDEF ANDROID} uses Androidapi.JNI.Os, Androidapi.JNI.GraphicsContentViewText, Androidapi.Helpers, Androidapi.JNIBridge; {$ENDIF} {$R *.fmx} procedure TForm1.FormCreate(Sender: TObject); begin RDAngularGauge1.Value :=0; end; procedure TForm1.Timer1Timer(Sender: TObject); begin One_Vibration(); if Count = 4 then IsInc := FALSE else if Count = 0 then IsInc := TRUE; if IsInc then Inc( Count ) else Dec( Count ); RDAngularGauge1.Value := Count mod 5; end; //-------------------------------------------------- procedure TForm1.One_Vibration(); {$IFDEF ANDROID} Var Vibrator:JVibrator; {$ENDIF} begin {$IFDEF ANDROID} Vibrator:=TJVibrator.Wrap((SharedActivityContext.getSystemService(TJContext.JavaClass.VIBRATOR_SERVICE) as ILocalObject).GetObjectID); Vibrator.vibrate(100); // milliseconds {$ENDIF} {$IFDEF MSwindows} beep; {$ENDIF} end; procedure TForm1.RDRotaryKnob1DialChange(Sender: TObject); var b1 : integer; begin b1 := Round( RDRotaryKnob1.Value ) div 10 + 3 ; BPM := b1 * 10; if b1 < 10 then begin RDN1.Number := '0'; RDN2.Number := b1.ToString end else begin RDN1.Number := '1'; RDN2.Number := (b1 -10).ToString; end; BPM := RDN1.Number.ToInteger*100 + RDN2.Number.ToInteger*10 + RDN3.Number.ToInteger; // BPMText.Text := BPM.ToString; end; procedure TForm1.RDHorzSlideBar1Change(Sender: TObject); var b2 : integer; begin b2 := Round( RDHorzSlideBar1.Value ); RDN3.Number := b2.ToString; BPM := RDN1.Number.ToInteger*100 + RDN2.Number.ToInteger*10 + RDN3.Number.ToInteger; // BPMText.Text := BPM.ToString; end; procedure TForm1.RDButtonSet1ButtonSetClick(Sender: TObject); begin if RDColorCheckBox1.IsChecked = TRUE then begin case RDButtonSet1.ClickIndex of 0 : begin Timer1.Enabled := TRUE; Timer1.Interval := Round( 60 / BPM.ToSingle * 1000 ); //Timer1.Interval := 60 div BPM * 1000; end; 1 : begin Count := 0; IsInc := TRUE; RDAngularGauge1.Value := 0.0; Timer1.Enabled := FALSE; end; 2 : Close; end; end; end; procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState); begin {$IFDEF ANDROID} if Key = vkHardwareBack Then Key := 0 ; // 기본액션인 앱 종료를 방지함. {$ENDIF} end; end. |
댓글 없음:
댓글 쓰기