?? gsmctrfr.pas
字號:
procedure TGSMCentralForm.SetConfiguration;
begin
with GSMDataModule,GSM do
begin
Equipment := TGSMEquipment(ModemComboBox.ItemIndex);
SCA := SCAEdit.Text;
PIN := PINEdit.Text;
SMSFormat:= Self.SMSFormat.ItemIndex;
UnsolicitedIndication:= [];
if CatchSMSMT.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindSMSDeliver];
if CatchSMSCB.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindCellBroadcast];
if CatchSMSDS.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindSMSStatusReport];
if OnlyIndication.Checked then
UnsolicitedIndication:= UnsolicitedIndication+[uindOnlyIndication];
ComDevice.DeviceName := DeviceNameEdit.Text;
if SMSLogCheckBox.Checked then
SMSLogFile := SMSLogSaveDialog.FileName
else
SMSLogFile := NO_LOG_FILE;
if GSMLogCheckBox.Checked then
GSMLogFile := GSMLogSaveDialog.FileName
else
GSMLogFile := NO_LOG_FILE;
self.Caption:= Format(CaptionStr, [GSMEquipmentLongName[Equipment]]);
end;
end;
procedure TGSMCentralForm.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
// SetConfiguration;
end;
procedure TGSMCentralForm.SMSLOGCheckBoxClick(Sender: TObject);
begin
SMSLogButton.Enabled := SMSLogCheckBox.Checked
end;
procedure TGSMCentralForm.GSMLOGCheckBoxClick(Sender: TObject);
begin
GSMLogButton.Enabled := GSMLogCheckBox.Checked
end;
procedure TGSMCentralForm.SMSLogButtonClick(Sender: TObject);
begin
if SMSLogCheckBox.Checked then
with SMSLogSaveDialog,GSMDataModule do
if Execute
then
SMSLogFile := FileName
else
FileName := SMSLogFile;
end;
procedure TGSMCentralForm.GSMLogButtonClick(Sender: TObject);
begin
if GSMLogCheckBox.Checked then
with GSMLogSaveDialog,GSMDataModule do
if Execute
then
GSMLogFile := FileName
else
FileName := GSMLogFile;
end;
procedure TGSMCentralForm.SMSKindChange(Sender: TObject);
begin
AdjustSMSKind;
end;
procedure TGSMCentralForm.AdjustSMSKind;
begin
if fSMSKindLock <> 0 then
Exit;
Inc(fSMSKindLock);
try
if SMSKind.ItemIndex <> FLastSMSKind then
begin
SMSKind2.Enabled:= SMSKind.ItemIndex > 0;
if SMSKind.ItemIndex = 1 then
SMSKind2.Items.Text:= 'Picture'#13#10'vCard'#13#10'Logo'#13#10'CLI'#13#10'Melody'
else if SMSKind.ItemIndex = 2 then
SMSKind2.Items.Text:= 'Picture (small)'#13#10'Picture (large)'#13#10'Picture (variable)'#13#10'Animation (small)'#13#10'Animation (large)'#13#10'Melody'
else
SMSKind2.Items.Text:= #13#10;
FLastSMSKind:= SMSKind.ItemIndex;
SMSKind2.ItemIndex:= 0;
DCS.Enabled:= SMSKind.ItemIndex = 0;
DeliveryNotification.Enabled:= DCS.Enabled;
FLastSMSKind2:= -MaxInt;
end;
if SMSKind2.ItemIndex <> FLastSMSKind2 then
begin
case SMSKind.ItemIndex of
0:
begin
FSmartMessage:= nil;
FEMS:= nil;
PictureGB.Visible:= False;
vCardGB.Visible:= False;
MelodyGB.Visible:= False;
Message.Enabled:= True;
end;
1:
begin
FEMS:= nil;
case SMSKind2.ItemIndex of
0: FSmartMessage:= TSMOTABitmap;
1: FSmartMessage:= TSMvCard;
2: FSmartMessage:= TSMOperatorLogo;
3: FSmartMessage:= TSMCLIIcon;
4: FSmartMessage:= TSMRingingTone;
end;
PictureGB.Visible:= (FSmartMessage = TSMMultipartMessage) or (FSmartMessage.InheritsFrom(TSMOTABitmap));
PictureOperator.Enabled:= FSmartMessage = TSMOperatorLogo;
vCardGB.Visible:= FSmartMessage = TSMvCard;
PictureNumAnimations.Enabled:= False;
PictureNumAnimations.Text:= '0';
PictureHeight.Enabled:= True;
PictureWidth.Enabled:= PictureHeight.Enabled;
MelodyGB.Visible:= FSmartMessage.InheritsFrom(TSMRingingTone);
Message.Enabled:= fSmartMessage = TSMOTABitmap;
end;
2:
begin
FSmartMessage:= nil;
case SMSKind2.ItemIndex of
0: FEMS:= TEMSPictureSmall;
1: FEMS:= TEMSPictureLarge;
2: FEMS:= TEMSPictureVariable;
3: FEMS:= TEMSAnimationSmall;
4: FEMS:= TEMSAnimationLarge;
5: FEMS:= TEMSSoundUserDef;
end;
PictureGB.Visible:= FEMS.InheritsFrom(TEMSPicture) or FEMS.InheritsFrom(TEMSAnimation);
vCardGB.Visible:= False;
PictureNumAnimations.Enabled:= False;
PictureHeight.Enabled:= FEMS = TEMSPictureVariable;
PictureWidth.Enabled:= PictureHeight.Enabled;
PictureOperator.Enabled:= False;
MelodyGB.Visible:= FEMS.InheritsFrom(TEMSSoundUserDef);
Message.Enabled:= True;
if FEMS.InheritsFrom(TEMSPicture) then
begin
with FEMS.Create as TEMSPicture do
try
PictureHeight.Text:= IntToStr(Height);
PictureWidth.Text:= IntToStr(Width);
PictureNumAnimations.Text:= '1';
finally
Free;
end;
end
else if FEMS.InheritsFrom(TEMSAnimation) then
begin
with FEMS.Create as TEMSAnimation do
try
PictureHeight.Text:= IntToStr(Height);
PictureWidth.Text:= IntToStr(Width);
PictureNumAnimations.Text:= '4';
finally
Free;
end;
end
end;
end;
AdjustPicture;
end;
Blink.Enabled:= Message.Enabled;
finally
Dec(fSMSKindLock);
end;
end;
const
CellSize = 5;
procedure TGSMCentralForm.AdjustPicture;
begin
Picture.Width:= CellSize*(StrToIntDef(PictureNumAnimations.Text, 0)+Byte(SMSKind.ItemIndex=1))*StrToIntDef(PictureWidth.Text, 0);
Picture.Height:= CellSize*StrToIntDef(PictureHeight.Text, 0);
Picture.Repaint;
fPictureBitmap.Width:= Max(Picture.Width, fPictureBitmap.Width);
fPictureBitmap.Height:= Max(Picture.Height, fPictureBitmap.Height);
end;
procedure TGSMCentralForm.FormDestroy(Sender: TObject);
begin
fPictureBitmap.Free;
end;
procedure TGSMCentralForm.PicturePaint(Sender: TObject);
var
A, X, Y, X1: Integer;
const
BackColor: array[Boolean] of TColor = ($00FFFF80, $0080FF00);
begin
with Picture.Canvas do
begin
X1:= 0;
for A:= 1 to StrToIntDef(PictureNumAnimations.Text, 0)+Byte(SMSKind.ItemIndex=1) do
begin
Pen.Mode:= pmCopy;
Brush.Color:= BackColor[A and 1 <> 0];
Brush.Style:= bsSolid;
Pen.Style:= psClear;
Rectangle(X1*CellSize, 0, (X1+StrToIntDef(PictureWidth.Text, 0))*CellSize, Picture.Height);
Brush.Color:= clBlack;
for X:= 0 to StrToIntDef(PictureWidth.Text, 0)-1 do
begin
for Y:= 0 to StrToIntDef(PictureHeight.Text, 0)-1 do
begin
if not fPictureBitmap.Empty and (fPictureBitmap.Canvas.Pixels[X1, Y] <> clWhite) then
Rectangle(X1*CellSize, Y*CellSize, (X1+1)*CellSize, (Y+1)*CellSize);
end;
Inc(X1);
end;
end;
Pen.Style:= psSolid;
Pen.Color:= clWhite;
Pen.Width:= 1;
Y:= 0;
while Y <= Picture.Height do
begin
MoveTo(0, Y);
LineTo(Picture.Width, Y);
Inc(Y, CellSize);
end;
X:= 0;
while X <= Picture.Width do
begin
MoveTo(X, 0);
LineTo(X, Picture.Height);
Inc(X, CellSize);
end;
end;
end;
procedure TGSMCentralForm.PictureWidthExit(Sender: TObject);
begin
AdjustPicture;
end;
procedure TGSMCentralForm.PictureWidthKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (Key = Key_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.BitBtn1Click(Sender: TObject);
var
I: Integer;
B: Byte;
F: Boolean;
NBS: TSMSProtocol2;
SM, SM2: TSmartMessage;
EMS: TEMS;
EMSObj: TEMSObject;
S: string;
begin
ShowModemLog;
try
NBS:= nil;
try
if FSmartMessage <> nil then
begin
if FSmartMessage.InheritsFrom(TSMMIMEDirectory) then
NBS:= TNBS.Create
else
NBS:= TUDHProtocol.Create;
NBS.Options:= [smspoAddressing, smspoReference];
SM:= FSmartMessage.Create;
try
if SM is TSMvCard then
begin
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
NBS.DestinationAddress:= smPortCLILogo
else if SM is TSMOperatorLogo then
begin
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
NBS.DestinationAddress:= smPortRingingTone;
SMRingingToneFromGrid(TSMRingingTone(SM));
end;
if (FSmartMessage = TSMOTABitmap) or (FSmartMessage = TSMScreenSaver) then
begin
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;
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(Integer(MelodyGrid.Objects[4, 1])));
end;
S:= '';
for I:= 1 to MelodyGrid.RowCount-2 do
begin
B:= 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:= 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:= Integer(MelodyGrid.Objects[3, I]); // note: in row 0 are defaults
case B of
1: S:= S+'.';
2: S:= S+':';
3: S:= S+';';
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -