📄 unitformenglishvoice.pas
字号:
end;
46: SymbolDelete(SymbolSize, True, False);
65: begin
if IsLowerCase(Shift) then
btnTag := 00
else
btnTag := 27;
end;
66: begin
if IsLowerCase(Shift) then
btnTag := 01
else
btnTag := 26;
end;
67: begin
if not (ssCtrl in Shift) then
begin
if IsLowerCase(Shift) then
begin
btnTag := 02
end
else
btnTag := 28;
end
else
begin
if ScrollBox1.ComponentCount > 0 then
Clipboard.Assign(Image1.Picture);
end;
end;
68:begin
if not (ssCtrl in Shift) then
btnTag := 03
else
SymbolDelete(SymbolSize, True, True);
end;
69: begin
if IsLowerCase(Shift) then
btnTag := 04
else
btnTag := 29;
end;
70: begin
if IsLowerCase(Shift) then
btnTag := 05
else
btnTag := 30;
end;
71: btnTag := 06;
72: btnTag := 07;
73: btnTag := 08;
74: begin
if IsLowerCase(Shift) then
btnTag := 09
else
btnTag := 20;
end;
75: btnTag := 10;
76: begin
if IsLowerCase(Shift) then
btnTag := 11
else
btnTag := 29;
end;
77: btnTag := 12;
78: begin
if IsLowerCase(Shift) then
btnTag := 13
else
btnTag := 36;
end;
79: btnTag := 14;
80: btnTag := 15;
81: begin
if IsLowerCase(Shift) then
btnTag := 16
else
btnTag := 35;
end;
82: btnTag := 17;
83: btnTag := 18;
84: begin
if IsLowerCase(Shift) then
btnTag := 19
else
btnTag := 33;
end;
85: btnTag := 20;
86: begin
if not (ssCtrl in Shift) then
begin
if IsLowerCase(Shift) then
begin
btnTag := 21
end
else
btnTag := 32;
end;
end;
87: begin
if IsLowerCase(Shift) then
btnTag := 22
else
btnTag := 34;
end;
88: begin
if not (ssCtrl in Shift) then
begin
btnTag := 23;
end;
end;
89: btnTag := 24;
90: begin
if IsLowerCase(Shift) then
btnTag := 25
else
btnTag := 31;
end;
57: begin
if ssShift in Shift then
btnTag := 40;
end;
48: begin
if ssShift in Shift then
btnTag := 41;
end;
53: begin
if not (ssShift in Shift) then
btnTag := 38;
end;
55: begin
if not (ssShift in Shift) then
btnTag := 39;
end;
101:btnTag := 38;
103:btnTag := 39;
186:begin
if ssShift in Shift then
btnTag := 37;
end;
end;
editVoiceText.Text := '';
if btnTag <> - 1 then
SymbolImage(SymbolSize, Image1.Picture.Bitmap, btnTag);
end;
procedure TFormEnglishVoice.editVoiceTextChange(Sender: TObject);
var
Index, btnTag: Integer;
FSymbolChars: array [0..255] of Char;
begin
if Length(Trim(editVoiceText.Text)) <= 1 then Exit;
SymbolFree;
lstrcpy(FSymbolChars, PChar(editVoiceText.Text));
for Index := 0 to lstrlen(FSymbolChars) - 1 do
begin
btnTag := -1;
case Ord(FSymbolChars[Index]) of
40: btnTag := 40;
41: btnTag := 41;
53: btnTag := 38;
55: btnTag := 39;
57: btnTag := 39;
58: btnTag := 37;
65: btnTag := 27;
66: btnTag := 26;
67: btnTag := 28;
69: btnTag := 29;
70: btnTag := 30;
73: btnTag := Ord(FSymbolChars[Index]) - 65;
74: btnTag := 20;
76: btnTag := 29;
78: btnTag := 36;
81: btnTag := 35;
84: btnTag := 33;
86: btnTag := 32;
87: btnTag := 34;
90: btnTag := 31;
94: btnTag := 71 - 65;
96: btnTag := 38;
97..122:
btnTag := Ord(FSymbolChars[Index]) - 97;
else
begin
//showmessage(IntToStr(Ord(FSymbolChars[Index])));
end;
end;
if btnTag <> -1 then
SymbolImage(SymbolSize, Image1.Picture.Bitmap, btnTag);
end;
end;
procedure TFormEnglishVoice.BtnCopyClick(Sender: TObject);
begin
Clipboard.Assign(Image1.Picture);
end;
procedure TFormEnglishVoice.cbMostTopClick(Sender: TObject);
begin
if cbMostTop.Checked then
SetWindowPos(Handle, HWND_TOPMOST, Left, Top, Width, Height, SWP_NOACTIVATE)
else
SetWindowPos(Handle, HWND_NOTOPMOST, Left, Top, Width, Height, SWP_NOACTIVATE);
editVoiceText.SetFocus;
end;
function TFormEnglishVoice.SymbolCharacter: Char;
function GetSymbolbyIndex(Index: Integer): Char;
begin
Result := #0;
case Index of
00
..
25: Result := Chr(Index + ord('a'));
26: Result := 'B';
27: Result := 'A';
28: Result := 'C';
29: Result := 'E';
30: Result := 'F';
31: Result := 'Z';
32: Result := 'V';
33: Result := 'T';
34: Result := 'W';
35: Result := 'Q';
36: Result := 'N';
37: Result := ':';
38: Result := '5';
39: Result := '7';
40: Result := '(';
41: Result := ')';
end;
end;
begin
if FSymbolIndex = -1 then
begin
Result := GetSymbolbyIndex(GetIndex(FImageInfo[ScrollBox1.ComponentCount - 1]));
end
else
begin
Result := GetSymbolbyIndex(GetIndex(FImageInfo[FSymbolIndex]));
end;
end;
procedure TFormEnglishVoice.SymbolDelete(Size: Integer; Auto: Boolean; Ahead: Boolean);
var
Index, OffSet: Integer;
begin
if (FSymbolIndex <> - 1) then
begin
TImage(ScrollBox1.Components[FSymbolIndex]).Free;
FImageInfo.Delete(FSymbolIndex);
OffSet := (Size + 2) * 2 + 1;
for Index := 0 to ScrollBox1.ComponentCount - 1 do
begin
if ScrollBox1.Components[Index] is TImage then
begin
(ScrollBox1.Components[Index] as TImage).Tag := Index;
(ScrollBox1.Components[Index] as TImage).Left := (Index) mod (ScrollBox1.Width div OffSet) * OffSet;
(ScrollBox1.Components[Index] as TImage).Top := (Index) div (ScrollBox1.Width div OffSet) * OffSet;
end;
end;
if Ahead then
SymbolIndex := SymbolIndex - 1;
if FSymbolIndex = ScrollBox1.ComponentCount then
SymbolIndex := ScrollBox1.ComponentCount - 1;
if FSymbolIndex <> -1 then
SymbolOnClick(ScrollBox1.Components[FSymbolIndex]);
DrawVoice(Size, Image1.Picture.Bitmap);
Exit;
end;
if Auto and (FSymbolIndex = -1) then
begin
SymbolIndex := ScrollBox1.ComponentCount - 1;
if FSymbolIndex <> -1 then
begin
TImage(ScrollBox1.Components[FSymbolIndex]).Free;
FImageInfo.Delete(FSymbolIndex);
SymbolIndex := ScrollBox1.ComponentCount - 1;
if FSymbolIndex <> -1 then
SymbolOnClick(ScrollBox1.Components[FSymbolIndex]);
end;
DrawVoice(Size, Image1.Picture.Bitmap);
end;
end;
function Get000(eNum,Count:Integer):String;
begin
Result := format ('%0.*d', [Count,eNum]);
end;
procedure TFormEnglishVoice.SymbolLoad(Size: Integer);
var
Index: Integer;
ResID_Left, ResID_Width, iOffSet, iDefault: Integer;
Buffer: string;
begin
if FSymbolBitmap = nil then Exit;
FSymbolBitmap.FreeImage;
ResID_Left := 101;
ResID_Width := 102;
FSymbolBitmap.LoadFromResourceName(hInstance, 'BITMAP_SYMBOL_' + Get000(Size, 2));
ResID_Left := Size * 10 + 1;
ResID_Width := Size * 10 + 2;
Buffer := LoadResourceString(ResID_Left);
if Length(Buffer) = 44 * 4 - 1 then
begin
Index := 0;
while Index < 44 do
begin
Symbols[Index].Left := StrToIntDef(Copy(Buffer,Index * 4 + 1, 3), 0);
Inc(Index);
end;
end;
Buffer := LoadResourceString(ResID_Width);
if Length(Buffer) = 44 * 3 - 1 then
begin
Index := 0;
while Index < 44 do
begin
Symbols[Index].Width := StrToIntDef(Copy(Buffer,Index * 3 + 1, 2), 0);
Inc(Index);
end;
end;
for Index := 0 to FImageInfo.Count - 1 do
begin
FImageInfo[Index] :=IntToStr(Symbols[GetIndex(FImageInfo[Index])].Width) + ';' + IntToStr(GetIndex(FImageInfo[Index]));
end;
iOffSet := (Size + 2) * 2 + 1;
iDefault := (Size + 2) * 2;
for Index := 0 to ScrollBox1.ComponentCount - 1 do
begin
with TImage(ScrollBox1.Components[Index]) do
begin
Left := Index mod (ScrollBox1.Width div iOffSet) * iOffSet;
Top := Index div (ScrollBox1.Width div iOffSet) * iOffSet;
Width := iDefault;
Height := iDefault;
Picture.Bitmap.Canvas.FillRect(Rect(0, 0, iDefault, iDefault));
Center := True;
Stretch := False;
Transparent := True;
Picture.Bitmap.Width := iDefault;
Picture.Bitmap.Height := iDefault;
Picture.Bitmap.Canvas.CopyRect(Rect((iDefault - Symbols[GetIndex(FImageInfo[Index])].Width) div 2,
(iDefault - FSymbolBitmap.Height) div 2,
(iDefault - Symbols[GetIndex(FImageInfo[Index])].Width) div 2 + Symbols[GetIndex(FImageInfo[Index])].Width,
(iDefault - FSymbolBitmap.Height) div 2 + FSymbolBitmap.Height),
FSymbolBitmap.Canvas,
Rect(Symbols[GetIndex(FImageInfo[Index])].Left,
0,
Symbols[GetIndex(FImageInfo[Index])].Left + Symbols[GetIndex(FImageInfo[Index])].Width,
FSymbolBitmap.Height));
end;
end;
DrawVoice(Size, Image1.Picture.Bitmap);
end;
function TFormEnglishVoice.GetSymbolSize: Integer;
begin
case cbbImageSize.ItemIndex of
0: Result := 08;
1: Result := 10;
2: Result := 12;
3: Result := 14;
4: Result := 16;
5: Result := 18;
6: Result := 20;
7: Result := 22;
8: Result := 24;
else
Result := 10;
end;
end;
procedure TFormEnglishVoice.cbbImageSizeChange(Sender: TObject);
begin
SymbolLoad(GetSymbolSize);
SymbolIndex := -1;
editVoiceText.SetFocus;
end;
procedure TFormEnglishVoice.cbCopyToClipboardClick(Sender: TObject);
begin
if cbCopyToClipboard.Checked then
Clipboard.Assign(Image1.Picture);
editVoiceText.SetFocus;
end;
procedure TFormEnglishVoice.cbNoBlankLineClick(Sender: TObject);
begin
DrawVoice(GetSymbolSize, Image1.Picture.Bitmap);
editVoiceText.SetFocus;
end;
procedure TFormEnglishVoice.SymbolMove(Index: Integer);
var
SImageInfo: String;
FBitmap: TBitmap;
begin
if (FSymbolIndex > - 1) and (Index > -1) and (FSymbolIndex <> Index)
and(FSymbolIndex < ScrollBox1.ComponentCount) and (Index < ScrollBox1.ComponentCount) then
begin
FBitmap := TBitmap.Create;
try
FBitmap.Assign(TImage(ScrollBox1.Components[FSymbolIndex]).Picture.Bitmap);
TImage(ScrollBox1.Components[FSymbolIndex]).Picture.Bitmap.Assign(TImage(ScrollBox1.Components[Index]).Picture.Bitmap);
TImage(ScrollBox1.Components[Index]).Picture.Bitmap.Assign(FBitmap);
SImageInfo := FImageInfo[FSymbolIndex];
FImageInfo[FSymbolIndex] := FImageInfo[Index];
FImageInfo[Index] := SImageInfo;
SymbolIndex := Index;
finally
FreeAndNil(FBitmap);
end;
DrawVoice(SymbolSize, Image1.Picture.Bitmap);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -