注意:伪代码,提供思路,仅供参考 procedure TForm1.GestureManager1Gesture(Sender: TObject; const EventInfo: TGestureEventInfo; var Handled: Boolean); begin case EventInfo.GestureID of //根据手势ID判断滑动方向,并执行相应的翻页操作 sgiLeft: NextPage; sgiRight: PrevPage; end; end;
procedure TForm1.SplitPages; var I, J, K, L: Integer; Line, PageText: string; begin SetLength(PageList, 0); //清空原有的页面 I := 0; //当前的文本行索引 J := 0; //当前的页面索引 while I < TextList.Count do //遍历所有的文本行 begin PageText := ''; //初始化当前页面的字符串为空 K := 0; //当前页面的文本行数 while (I < TextList.Count) and (K < PageLines) do //如果没有达到文本行数限制或者文本结束,则继续添加文本行到当前页面 begin Line := TextList[I]; //获取当前的文本行 if Line = '' then //如果是空行,则直接换页 begin Inc(I); Break; end; L := Length(Line); //获取当前文本行的字符数 if L <= PageChars then //如果当前文本行的字符数小于等于每一页的字符数限制,则直接添加到当前页面,并换行 begin PageText := PageText + Line + sLineBreak; Inc(I); Inc(K); end else //如果当前文本行的字符数大于每一页的字符数限制,则分割成多个子串,并添加到当前页面,并换行 begin while L > PageChars do begin PageText := PageText + Copy(Line, 1, PageChars) + sLineBreak; Delete(Line, 1, PageChars); Dec(L, PageChars); Inc(K); if K >= PageLines then //如果达到了文本行数限制,则换页,并退出循环 begin Inc(I); Break; end; end; if L > 0 then //如果还有剩余的字符,则添加到当前页面,并换行 begin PageText := PageText + Line + sLineBreak; Inc(I); Inc(K); end; end; end; SetLength(PageList, J + 1); //增加一个页面到TStringList数组中 PageList[J] := TStringList.Create; //创建一个TStringList对象,用于存储当前页面的字符串 PageList[J].Text := PageText; //将当前页面的字符串赋值给TStringList对象 Inc(J); //增加当前页面的索引 end; end;
----------------------------------------------
《Z-Gantt战石智慧时间管理进度计划甘特图软件》:WWW.Z-SHi.NET