?? 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
//讀入書簽設(shè)置
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;
//設(shè)置參數(shù)
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;
//關(guān)閉文件
CloseFile(FpLibFile);
//關(guān)閉顯示信息
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; //寫標志:處于編輯狀態(tài)
//屏蔽原系統(tǒng)的部分功能
FormMain.PopupMenu := MenuEdit;
FormMain.KeyPreview := False;
ImagePagePrev.Enabled := False;
ImagePageNext.Enabled := False;
ImageUnderLine.Visible := False;
TimeAutoPageMove.Enabled := False;
TimeAutoUnderLine.Enabled := False;
//調(diào)整編輯框1
with FMemoPageEdit[1] do
begin
Left := FnPage1Left;
Top := FnPageTop - 3;
Width := FnPageWidth;
Height := FnPageHeight + 3;
Font := g_PageFont;
Visible := True;
end;
//調(diào)整編輯框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); //打開菜單文件(僅把文件寫入菜單)
//若正確打開文件,則打開參數(shù)文件中第一個文件
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;
//檢測剩余書簽數(shù)量
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;
//調(diào)整書簽菜單
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]);
//調(diào)整書簽設(shè)置
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
//調(diào)整書簽信息
FstrLabelString[i] := EditLabelInput.Text;
ItemLabelInput.Items[i].Caption := FstrLabelString[i];
//將書簽信息添加入注冊表
RegWriteStr(c_strRegLabelPath,
IntToStr(FnOpenNewIndex) + c_strRegLabelString + IntToStr(i),
FstrLabelString[i]);
//調(diào)整書簽按鈕設(shè)置
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 + -