📄 main.pas
字号:
(LowerCase(ExtractFileExt(strFilename)) = '.html') then
g_boolHtml := True;
//初始化书签变量
ItemLabelInput.Clear;
nCurrentLabel := RegReadInt(c_strRegFilePath,
c_strRegFilenameSort + IntToStr(FnOpenNewIndex),
-1);
if (nCurrentLabel >= 0) then
begin
for nCountLabel := 0 to c_nRegLabelCount - 1 do
begin
//读入书签设置
FnLabelIndex[nCountLabel] := RegReadInt(c_strRegLabelPath,
IntToStr(nCurrentLabel) + c_strRegLabel + IntToStr(nCountLabel),
0);
FstrLabelString[nCountLabel] := RegReadStr(c_strRegLabelPath,
IntToStr(nCurrentLabel) + c_strRegLabelString + IntToStr(nCountLabel),
'');
if FnLabelIndex[nCountLabel] <= 0 then
Break;
//增加指定书签菜单
FItemAddLabel := TMenuItem.Create(Self);
FItemAddLabel.Caption := FstrLabelString[nCountLabel];
FItemAddLabel.OnClick := OnLabelInputClick;
ItemLabelInput.Add(FItemAddLabel);
end;
end;
//写标志:正确打开文件
FboolOpenFileFlag := True;
//处理
Init_Text;
Init_Page_Do;
Init_Page;
//翻到第1页
ChangeYe(1);
//刷新主窗口
UpdateMainForm;
end;
begin
//没有最新文件则退出
if FstrNewFileList.Count <= 0 then Exit;
//得到文件名,判断该文件是否存在
strFilename := GetIndexFilename(TMenuItem(Sender).MenuIndex);
if not isFileExist(strFilename, True) then Exit;
//---打开文件---
//判断是否是ZIP子文件
if isZipSubFile(strFilename) then
begin
//得到ZIP子文件名
GetZipFilename(strFilename, strZipFilename, strZipSubFilename);
strZipSubFilename := g_strZipPassDir + '\' + strZipSubFilename;
//判断是否改变最新文件菜单顺序
if g_boolChangeItem then
begin
if not OpenItemFile(strFilename) then Exit;
Sender := ItemNew.Items[0];
end;
//打开文件
if OpenFile(strZipSubFilename) then
InitOpenFile;
//退出
Exit;
end;
//判断是否改变最新文件菜单顺序
if g_boolChangeItem then
begin
if not OpenItemFile(strFilename) then Exit;
Sender := ItemNew.Items[0];
end;
//判断是否是ZIP文件
if LowerCase(ExtractFileExt(strFilename)) = '.zip' then
begin //打开ZIP文件,选择需要解压的文件
//建立用于传送解压文件的文件列表
strZipFileList := TStringList.Create;
strZipFileList.Clear;
//浏览需要解压的文件
if ShowSelZipFile(strFilename, strZipFileList) then
begin
//刷新主窗口
UpdateMainForm;
//设置参数
FboolOpenFileFlag := False; //写标志:没有正确打开文件
i := 0;
//打开文件
while (i <= strZipFileList.Count - 1) do
begin
OpenItemFile(strZipFileList.Strings[i]);
inc(i);
end;
//若成功解压文件,则打开第一个文件(解压出来的文件)
if FboolOpenFileFlag then
OnItemNewFileClick(ItemNew.Items[0]);
end;
//释放用于传送解压文件的文件列表
strZipFileList.Free;
//退出
Exit;
end;
//打开一般文件
if OpenFile(strFilename) then
InitOpenFile;
end;
//---保存书库文件菜单---
procedure TFormMain.ItemLibClick(Sender: TObject);
var i : integer;
s : string;
begin
//显示主窗口
ShowMainForm;
//没有最新文件则退出
if FstrNewFileList.Count <= 0 then Exit;
//打开对话框,错误则退出
with FDlgSaveLibFile do
begin
if isZipSubFile(g_strFilename) then
InitialDir := ExtractFilePath(Copy(g_strFilename, 1, pos(c_strZipSpilt, g_strFilename) - 1))
else
InitialDir := ExtractFilePath(g_strFilename);
if not Execute then
Exit;
end;
//获得文件名
s := FDlgSaveLibFile.Filename;
//保存书库文件
try
AssignFile(FpLibFile, s);
Rewrite(FpLibFile);
//初始化显示信息
InitShowMess(0, FstrNewFileList.Count, '生成书库文件');
for i := FstrNewFileList.Count - 1 downto 0 do
begin
//显示完成度信息
ShowMessPos(FstrNewFileList.Count - i);
//写文件
Writeln(FpLibFile, GetIndexFilename(i)); //保存菜单文件名
end;
except
Alert('生成书库文件 ' + s + ' 失败!' + c_strReturn + '请检查磁盘是否错误。');
end;
//关闭文件
CloseFile(FpLibFile);
//关闭显示信息
CloseShowMess;
end;
//---文件处理菜单---
procedure TFormMain.ItemBIG5Click(Sender: TObject);
var s : string;
begin
s := TMenuItem(Sender).Name;
if s = 'ItemUnMimeCode' then
begin
g_boolUnMimeCode := not g_boolUnMimeCode;
g_boolUnQPCode := False;
g_boolUnHZCode := False;
end;
if s = 'ItemUnQPCode' then
begin
g_boolUnMimeCode := False;
g_boolUnQPCode := not g_boolUnQPCode;
g_boolUnHZCode := False;
end;
if s = 'ItemUnHZCode' then
begin
g_boolUnMimeCode := False;
g_boolUnQPCode := False;
g_boolUnHZCode := not g_boolUnHZCode;
end;
if s = 'ItemBIG5' then g_boolBIG5 := not g_boolBIG5;
if s = 'ItemGB' then g_boolGB := not g_boolGB;
if s = 'ItemHtml' then g_boolHtml := not g_boolHtml;
if s = 'ItemChap' then g_boolChap := not g_boolChap;
if s = 'ItemHangD' then g_boolHangD := not g_boolHangD;
if s = 'ItemUnderLine' then g_boolUnderLine := not g_boolUnderLine;
ImageUnderLine.Visible := g_boolUnderLine;
if s = 'ItemUnderLine' then
Exit;
if s <> 'ItemHangD' then
Init_Page_Do; //处理页面
//初始化
Init_Page; //初始化页面
ChangeYe(g_nYeCurrent); //翻到指定页
end;
//---编辑菜单---
procedure TFormMain.ItemEditClick(Sender: TObject);
begin
//显示主窗口
ShowMainForm;
FboolEdit := True; //写标志:处于编辑状态
//屏蔽原系统的部分功能
FormMain.PopupMenu := MenuEdit;
FormMain.KeyPreview := False;
ImagePagePrev.Enabled := False;
ImagePageNext.Enabled := False;
ImageUnderLine.Visible := False;
TimeAutoPageMove.Enabled := False;
TimeAutoUnderLine.Enabled := False;
//调整编辑框1
with FMemoPageEdit[1] do
begin
Left := FnPage1Left;
Top := FnPageTop - 3;
Width := FnPageWidth;
Height := FnPageHeight + 3;
Font := g_PageFont;
Visible := True;
end;
//调整编辑框2
with FMemoPageEdit[2] do
begin
Left := FnPage2Left;
Top := FnPageTop - 3;
Width := FnPageWidth;
Height := FnPageHeight + 3;
Font := g_PageFont;
Visible := True;
end;
//复制文字到编辑框
Init_Page_String;
if FMemoPageEdit[1].Visible then
FMemoPageEdit[1].SetFocus
else if FMemoPageEdit[2].Visible then
FMemoPageEdit[2].SetFocus;
end;
//---刷新显示菜单---
procedure TFormMain.ItemRefreshClick(Sender: TObject);
begin
//刷新文件
if (g_strFilename = '') or (g_strFilename = '剪贴板') then
begin //刷新说明文件
Init_Page;
end
else if FnOpenNewIndex >= 0 then
begin //刷新小说文件
OnItemNewFileClick(ItemNew.Items[FnOpenNewIndex])
end
else
begin //重新打开文件
FboolOpenFileFlag := False; //写标志:没有正确打开文件
OpenItemFile(g_strFilename); //打开菜单文件(仅把文件写入菜单)
//若正确打开文件,则打开参数文件中第一个文件
if FboolOpenFileFlag then
begin
OnItemNewFileClick(ItemNew.Items[0]);
end;
end;
//翻到当前页码
ChangeYe(g_nYeCurrent);
end;
//---查找菜单---
procedure TFormMain.ItemSearchClick(Sender: TObject);
begin
//显示主窗口
ShowMainForm;
if (FormSearch.ShowModal = mrOk) and (FormSearch.EditFindText.Text <> '') then
DoSearch(FormSearch.EditFindText.Text, FormSearch.CheckBoxCaps.Checked);
end;
//---再查找菜单---
procedure TFormMain.ItemSearchNextClick(Sender: TObject);
begin
//显示主窗口
ShowMainForm;
if FormSearch.EditFindText.Text = '' then
ItemSearch.Click
else
DoSearch(FormSearch.EditFindText.Text, FormSearch.CheckBoxCaps.Checked);
end;
//---添加书签菜单---
procedure TFormMain.ItemAddLabelClick(Sender: TObject);
var i, j : integer;
begin
//显示主窗口
ShowMainForm;
//当前是说明文件或有书签的话,就退出
if (g_strFilename = '') or (g_strFilename = '剪贴板') or (FboolCurrentLabel) then Exit;
//检测剩余书签数量
j := ItemLabelInput.Count;
if j >= c_nRegLabelCount then
begin
Prompt('没有空余书签可供添加,请删除部分书签。');
Exit;
end;
with TFormLabelInput.Create(Self) do
begin
Caption := '添加书签';
EditLabelInput.Text := '第' + IntToStr(g_nYeCurrent + FnYeOffset) + '页';
if ShowModal = mrOk then
begin
//初始化书签信息
FnLabelIndex[j] := g_nYeCurrent + FnYeOffset;
FstrLabelString[j] := EditLabelInput.Text;
//建立书签子菜单
FItemAddLabel := TMenuItem.Create(Self);
FItemAddLabel.Caption := FstrLabelString[j];
FItemAddLabel.OnClick := OnLabelInputClick;
//调整书签菜单
ItemLabelInput.Add(FItemAddLabel); //添加书签菜单
//将书签信息添加入注册表
//获得最新文件索引
i := RegReadInt(c_strRegFilePath, c_strRegFilenameSort + IntToStr(FnOpenNewIndex), -1);
//写入书签信息
RegWriteInt(c_strRegLabelPath, IntToStr(i) + c_strRegLabel + IntToStr(j), FnLabelIndex[j]);
RegWriteStr(c_strRegLabelPath, IntToStr(i) + c_strRegLabelString + IntToStr(j), FstrLabelString[j]);
//调整书签设置
PanelLabel.Hint := FstrLabelString[j];
ImageLabel.Hint := FstrLabelString[j];
FboolCurrentLabel := True;
PanelLabel.Visible := FboolCurrentLabel;
end;
Free;
end;
end;
//---修改书签菜单---
procedure TFormMain.ItemEditLabelClick(Sender: TObject);
var i : integer;
begin
//显示主窗口
ShowMainForm;
//当前没有书签的话,就退出
if not FboolCurrentLabel then Exit;
//检测书签
for i := 0 to ItemLabelInput.Count - 1 do
begin
if ((g_boolSinglePage and (g_nYeCurrent + FnYeOffset = FnLabelIndex[i])) or
((not g_boolSinglePage) and ((g_nYeCurrent = FnLabelIndex[i]) or (g_nYeCurrent + 1 = FnLabelIndex[i])))) then
begin //修改书签
with TFormLabelInput.Create(Self) do
begin
Caption := '修改书签';
EditLabelInput.Text := FstrLabelString[i];
if ShowModal = mrOk then
begin
//调整书签信息
FstrLabelString[i] := EditLabelInput.Text;
ItemLabelInput.Items[i].Caption := FstrLabelString[i];
//将书签信息添加入注册表
RegWriteStr(c_strRegLabelPath,
IntToStr(FnOpenNewIndex) + c_strRegLabelString + IntToStr(i),
FstrLabelString[i]);
//调整书签按钮设置
PanelLabel.Hint := FstrLabelString[i];
ImageLabel.Hint := FstrLabelString[i];
end;
Free;
end;
end;
end;
end;
//---删除书签菜单---
procedure TFormMain.ItemDeleteLabelClick(Sender: TObject);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -