📄 gsmctrfr.pas
字号:
begin
if (Key = VK_RETURN) and (Shift = []) then
begin
AdjustPicture;
Key:= 0;
end;
end;
procedure TGSMCentralForm.PictureMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
X:= X div CellSize;
Y:= Y div CellSize;
with fPictureBitmap.Canvas do
if Pixels[X, Y] = clWhite then
Pixels[X, Y]:= clBlack
else
Pixels[X, Y]:= clWhite;
Picture.Repaint;
end;
procedure TGSMCentralForm.BlinkClick(Sender: TObject);
begin
with Message do
Text:= Copy(Text, 1, SelStart)+smBlinkOn+Copy(Text, SelStart+1, SelLength)+smBlinkOff+Copy(Text, SelStart+SelLength+1, Length(Text));
end;
procedure TGSMCentralForm.Button2Click(Sender: TObject);
begin
if OpenPictureDialog.Execute then
begin
fPictureBitmap.LoadFromFile(OpenPictureDialog.FileName);
SavePictureDialog.FileName:= OpenPictureDialog.FileName;
AdjustPicture;
end;
end;
procedure TGSMCentralForm.Button3Click(Sender: TObject);
begin
if SavePictureDialog.Execute then
begin
fPictureBitmap.SaveToFile(SavePictureDialog.FileName);
end;
end;
procedure TGSMCentralForm.SendButtonClick(Sender: TObject);
var
I: Integer;
B: Byte;
F: Boolean;
NBS: TSMSProtocol;
SM, SM2: TSmartMessage;
EMS: TEMS;
EMSObj: TEMSObject;
S: string;
St: TStream;
begin
ShowModemLog;
try
NBS:= nil;
try
if FSmartMessage <> nil then
begin
if FSmartMessage.InheritsFrom(TSMMIMEDirectory) then
NBS:= TNBS.Create
else
NBS:= TUDHProtocol.Create;
TSMSProtocol2(NBS).Options:= [smspoAddressing, smspoReference];
SM:= FSmartMessage.Create;
try
if SM is TSMvCard then
begin
TSMSProtocol2(NBS).DestinationAddress:= smPortMIMEvCard;
SM:= TSMvCard.Create;
with TSMvCard(SM) do
begin
Records.Values['N']:= vCardName.Text;
Records.Values['TEL']:= vCardPhone.Text;
end;
end
else if SM is TSMOTABitmap then
begin
with TSMOTABitmap(SM) do
begin
AnimatedImageCount:= StrToIntDef(PictureNumAnimations.Text, 0);
Width:= StrToIntDef(PictureWidth.Text, 0);
Height:= StrToIntDef(PictureHeight.Text, 0);
for I:= 0 to AnimatedImageCount do
begin
Images[I].Width:= Width;
Images[I].Height:= Height;
end;
ImportFromImage(fPictureBitmap);
end;
if SM is TSMCLIIcon then
TSMSProtocol2(NBS).DestinationAddress:= smPortCLILogo
else if SM is TSMOperatorLogo then
begin
TSMSProtocol2(NBS).DestinationAddress:= smPortOperatorLogo;
with TSMOperatorLogo(SM) do
begin
I:= StrToIntDef(Copy(PictureOperator.Text, 1, Pos(',', PictureOperator.Text+',')-1), 0);
MCC:= I div 100;
MNC:= I mod 100;
end;
end;
end
else if SM is TSMRingingTone then
begin
TSMSProtocol2(NBS).DestinationAddress:= smPortRingingTone;
SMRingingToneFromGrid(TSMRingingTone(SM));
end;
if (FSmartMessage = TSMOTABitmap) or (FSmartMessage = TSMScreenSaver) then
begin
TSMSProtocol2(NBS).DestinationAddress:= smPortMultiPart;
SM2:= SM;
SM:= TSMMultipartMessage.Create;
with TSMMultipartMessage(SM) do
begin
Multiparts.Add(SM2);
if Message.Text <> '' then
begin
SM2:= TSMTextISO.Create;
TSMTextISO(SM2).Text:= Message.Text;
Multiparts.Insert(0, SM2);
end;
end;
end;
NBS.Data:= SM.Data;
finally
SM.Free;
end;
end
else if fEMS <> nil then
begin
NBS:= TUDHProtocol.Create;
TSMSProtocol2(NBS).Options:= [smspoReference];
EMS:= TEMS.Create;
EMS.Text:= Message.Text;
EMSObj:= fEMS.Create;
if EMSObj is TEMSPicture then
begin
with TEMSPicture(EMSObj) do
begin
Width:= StrToIntDef(PictureWidth.Text, 0);
Height:= StrToIntDef(PictureHeight.Text, 0);
ImportFromImage(fPictureBitmap);
end;
end
else if EMSObj is TEMSAnimation then
begin
with TEMSAnimation(EMSObj) do
begin
Width:= StrToIntDef(PictureWidth.Text, 0);
Height:= StrToIntDef(PictureHeight.Text, 0);
ImportFromImage(fPictureBitmap);
end
end
else if EMSObj is TEMSSoundUserDef then
begin
with TEMSSoundUserDef(EMSObj) do
begin
Records.Values['NAME']:= MelodyName.Text;
if MelodyGrid.RowCount > 2 then
begin
Records.Values['STYLE']:= 'S'+IntToStr(Integer(MelodyGrid.Objects[5, 1]));
Records.Values['BEAT']:= IntToStr(TSMRTTempo.DecodeBeatsPerMin(I2B(Integer(MelodyGrid.Objects[4, 1]))));
end;
S:= '';
for I:= 1 to MelodyGrid.RowCount-2 do
begin
B:= I2B(Integer(MelodyGrid.Objects[6, I])); // note: in row 0 are defaults
if B <> Integer(MelodyGrid.Objects[6, I-1]) then
S:= S+'V'+IntToStr(B);
if Integer(MelodyGrid.Objects[1, I]) = 0 then
S:= S+'r'
else
begin
B:= I2B(Integer(MelodyGrid.Objects[0, I])); // note: in row 0 are defaults
if B <> Integer(MelodyGrid.Objects[0, I-1]) then
S:= S+'*'+IntToStr(B+3);
case Integer(MelodyGrid.Objects[1, I]) of
smrtiNoteC: S:= S+'c';
smrtiNoteCis: S:= S+'#c';
smrtiNoteD: S:= S+'d';
smrtiNoteDis: S:= S+'#d';
smrtiNoteE: S:= S+'e';
smrtiNoteF: S:= S+'f';
smrtiNoteFis: S:= S+'#f';
smrtiNoteG: S:= S+'g';
smrtiNoteGis: S:= S+'#g';
smrtiNoteA: S:= S+'a';
smrtiNoteAis: S:= S+'#a';
smrtiNoteH: S:= S+'b';
end;
end;
S:= S+IntToStr(Integer(MelodyGrid.Objects[2, I]));
B:= I2B(Integer(MelodyGrid.Objects[3, I])); // note: in row 0 are defaults
case B of
1: S:= S+'.';
2: S:= S+':';
3: S:= S+';';
end;
end;
Records.Values['MELODY']:= S;
end;
end;
EMS.Objects.Add(EMSObj);
EMS.WriteTo(NBS as TUDHProtocol);
end
else if SMSKind.ItemIndex = 3 then // SEO
begin
NBS:= TSiemensOTA.Create;
with TSiemensOTA(NBS) do
begin
ObjectName:= SEOName.Text;
if SMSKind2.ItemIndex = 0 then
begin
ObjectType:= 'bmp';
St:= TMemoryStream.Create;
try
SEOPicture.Picture.Bitmap.SaveToStream(St);
St.Position:= 0;
NBS.Data:= StreamToString(St);
finally
St.Free;
end;
end
else
begin
ObjectType:= 'mid';
SEOMidi.Close; // file sharing lock
St:= TFileStream.Create(SEOMidi.FileName, fmOpenRead);
try
NBS.Data:= StreamToString(St);
finally
St.Free;
end;
try
SEOMidi.Open;
except
end;
end;
end;
end
else
begin
// text msg.
end;
if NBS <> nil then
begin
if NBS is TSMSProtocol2 then
begin
TSMSProtocol2(NBS).SourceAddress:= TSMSProtocol2(NBS).DestinationAddress;
end;
TSMSProtocol2(NBS).Reference:= fReference mod 256;
Inc(fReference);
if NBS is TNBS then
B:= 0
else
B:= $F4+DCS.ItemIndex;
for I:= 1 to NBS.FragmentCount do
begin
SendSmsPhn(DA.Text, NBS.Fragments[I], DeliveryNotification.Checked, B, NBS is TUDHProtocol, True, False);
end;
end
else
begin
B:= $F0+DCS.ItemIndex;
S:= Message.Text;
F:= Pos(smBlinkOn, S) <> 0;
if F then
begin
S:= #1+S;
B:= $18; // ??? does not work, no idea how display blinking messages, other ME?
end;
SendSmsPhn(DA.Text, S, DeliveryNotification.Checked, B, False, F, F);
end;
finally
NBS.Free;
end;
finally
HideModemLog;
end;
end;
procedure TGSMCentralForm.MelodyKeyboardPaint(Sender: TObject);
var
I, J: Integer;
R: TRect;
Keyis: Boolean;
begin
with (Sender as TPaintBox).Canvas do
begin
Brush.Style:= bsSolid;
Brush.Color:= clWhite;
Pen.Width:= 1;
Pen.Style:= psClear;
for I:= 0 to MelodyScale.Items.Count-1 do
for J:= 1 to MelodyNote.Items.Count-1 do
begin
if fMelodyKeyPressed = I*256 + J then
Pen.Mode:= pmXor
else
Pen.Mode:= pmCopy;
GetKeyRect(I, J, R, Keyis);
if not Keyis then
Rectangle(R.Left, R.Top, R.Right, R.Bottom);
end;
Pen.Style:= psClear;
for I:= 0 to MelodyScale.Items.Count-1 do
for J:= 1 to MelodyNote.Items.Count-1 do
begin
if fMelodyKeyPressed = I*256 + J then
begin
Pen.Mode:= pmXor;
Brush.Color:= clSilver;
end
else
begin
Brush.Color:= clBlack;
Pen.Mode:= pmCopy;
end;
GetKeyRect(I, J, R, Keyis);
if Keyis then
Rectangle(R.Left, R.Top, R.Right, R.Bottom);
end;
end;
end;
procedure TGSMCentralForm.GetKeyRect;
var
I, N, Sc, Kpos: Integer;
begin
N:= 0;
Keyis:= False;
Kpos:= 0;
for I:= 1 to MelodyNote.Items.Count-1 do
begin
if Pos('is', MelodyNote.Items[I]) = 0 then
begin
Inc(N);
if I < aNote then
Inc(Kpos);
end
else
begin
if aNote = I then
Keyis:= True;
end;
end;
Sc:= MelodyScale.Items.Count;
R.Top:= 0;
R.Bottom:= MelodyKeyboard.Height;
R.Left:= 0;
R.Right:= MelodyKeyboard.Width div (N * Sc);
if Keyis then
begin
R.Bottom:= R.Bottom div 2;
Dec(R.Left, R.Right div 3);
end;
Inc(R.Left, Kpos * R.Right);
Inc(R.Left, N * aScale * R.Right);
if Keyis then
R.Right:= 2*R.Right div 3 + R.Left
else
R.Right:= R.Right + R.Left;
end;
procedure TGSMCentralForm.MelodyKeyboardMouseDown(Sender: TObject;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -