69 SetRenderer(make_unique<BufferedRenderer>()),
80 lblProgress.SetRenderer(make_unique<BufferedRenderer>()),
87 ReaderBox::InitializeProgress()
97 const auto ts(reader.GetTextSize());
101 const auto tp(reader.GetTopPosition());
104 std::sprintf(str,
"%2u%%", tp * 100 / ts);
106 lblProgress.ForeColor = reader.GetBottomPosition() == ts
112 InitializeProgress();
115 InitializeProgress();
122 : DialogBox({32, 32, 200, 108}),
135 DialogBox::Refresh(std::move(e));
138 e.ClipArea = Rect(e.Location,
GetSizeOf(*
this));
175 const shared_ptr<Desktop>& h_dsk_up,
const shared_ptr<Desktop>& h_dsk_dn)
176 :
ShlDS(h_dsk_up, h_dsk_dn),
177 CurrentPath(pth), fBackgroundTask(), bExit()
189 const auto h_up(GetDesktopUpHandle());
192 PostMessage<SM_TASK>(0xF8, [=]{
209 group) +
'"')),
static_cast<int(&)(
int)
>(std::isspace),
210 [&](string::iterator b, string::iterator e){
214 catch(std::exception& e)
216 return std::move(bookmarks);
225 .GetNode(
"YReader")).GetNode(
"ReaderSetting").GetContainer());
227 catch(std::exception& e)
235 PostMessage<SM_PAINT>(0xE0,
nullptr);
249 for(
const auto& pos : bookmarks)
254 return std::move(str);
257 catch(std::exception& e)
271 catch(std::exception& e)
285 auto& shl(GetShell());
287 shl.reader.SetVisible(
true),
288 shl.boxReader.UpdateData(shl.reader),
289 shl.boxTextInfo.UpdateData(shl.reader),
297 auto& dsk_up(shl.GetDesktopUp());
298 auto& dsk_dn(shl.GetDesktopDown());
306 = dsk_dn.Background.target<SolidBrush>()->Color,
326 auto& shl(GetShell());
329 shl.pnlSetting.lblAreaUp, shl.pnlSetting.lblAreaDown);
342 const shared_ptr<Desktop>& h_dsk_up,
const shared_ptr<Desktop>& h_dsk_dn)
353 const auto exit_session([
this](TouchEventArgs&&){
362 reader.ViewChanged = [
this]{
364 boxReader.UpdateData(reader);
368 mhMain.Roots[&boxReader.btnMenu] = 1U,
369 FetchEvent<Click>(boxReader.btnMenu) += [
this](TouchEventArgs&&){
377 ShowMenu(1U,
Point(pt.X, pt.Y -
mhMain[1U].GetHeight()));
380 FetchEvent<Click>(boxReader.btnSetting) += [
this](TouchEventArgs&&){
383 FetchEvent<Click>(boxReader.btnInfo) += [
this](TouchEventArgs&&){
386 FetchEvent<Click>(boxReader.btnBookmark) += [
this](TouchEventArgs&&){
389 FetchEvent<Click>(boxReader.btnReturn) += [
this](TouchEventArgs&&){
392 FetchEvent<Click>(boxReader.btnPrev) += [
this](TouchEventArgs&&){
393 UpdateReadingList(
true);
395 FetchEvent<Click>(boxReader.btnNext) += [
this](TouchEventArgs&&){
396 UpdateReadingList(
false);
398 FetchEvent<TouchDown>(boxReader.pbReader) += [
this](TouchEventArgs&& e){
399 const auto s(reader.GetTextSize());
402 Locate(e.X * s / boxReader.pbReader.GetWidth());
404 FetchEvent<Paint>(boxReader.pbReader) += [
this](PaintEventArgs&& e){
405 auto& pb(boxReader.pbReader);
406 const auto mval(pb.GetMaxValue());
407 const auto w(pb.GetWidth() - 2);
408 auto& pt(e.Location);
410 FillRect(e.Target,
Point(pt.X + 1 + round(pb.GetValue() *
w / mval),
411 pt.Y + 1), Size(round((reader.GetBottomPosition()
412 - GetReaderPosition()) *
w / mval), pb.GetHeight() - 2),
415 FetchEvent<Click>(
pnlSetting.btnClose) += exit_session,
416 FetchEvent<Click>(
pnlSetting.btnOK) += [&,
this](TouchEventArgs&&){
418 tmrScroll.SetInterval(CurrentSetting.GetTimerSetting());
420 reader.SetColor(CurrentSetting.FontColor),
421 reader.SetFont(CurrentSetting.Font);
424 GetDesktopDown().Background =
pnlSetting.lblAreaDown.Background
427 for(
auto pr(boxReader.GetChildren()); pr.first != pr.second;
429 if(dynamic_cast<BufferedRenderer*>(
430 &pr.first->GetRenderer()))
433 FetchEvent<Click>(
pnlSetting.btnOK) += exit_session,
434 FetchEvent<Click>(
pnlBookmark.btnClose) += exit_session,
435 FetchEvent<Click>(
pnlBookmark.btnOK) += [
this](TouchEventArgs&&){
438 boxReader.UpdateData(reader);
440 FetchEvent<Click>(
pnlBookmark.btnOK) += exit_session
443 Menu& mnu(*(
ynew Menu({}, shared_ptr<Menu::ListType>(
new
444 Menu::ListType{
"返回",
"设置...",
"文件信息...",
"书签...",
445 "向上一行",
"向下一行",
"向上一屏",
"向下一屏"}), 1u)));
454 auto& dsk_up(GetDesktopUp());
455 auto& dsk_dn(GetDesktopDown());
457 reader.SetColor(CurrentSetting.FontColor),
458 reader.SetFont(CurrentSetting.Font),
460 dsk_up.Background = SolidBrush(CurrentSetting.UpColor),
461 dsk_dn.Background = SolidBrush(CurrentSetting.DownColor),
464 FetchEvent<KeyHeld>(dsk_dn) += OnEvent_Call<KeyDown>
466 reader.Attach(dsk_up, dsk_dn),
469 LastRead.DropSubsequent();
473 OnClick(TouchEventArgs(dsk_dn, 0));
531 const auto text_size(
reader.GetTextSize());
534 return pos >= text_size;
541 const auto s(
reader.GetTextSize());
545 const auto old_pos(GetReaderPosition());
548 if(
YB_LIKELY(old_pos != GetReaderPosition()))
565 if(CurrentSetting.SmoothScroll)
583 mnu.SetItemEnabled(MR_LineUp, !
reader.IsTextTop());
584 mnu.SetItemEnabled(MR_LineDown, !
reader.IsTextBottom());
585 mnu.SetItemEnabled(MR_ScreenUp, !
reader.IsTextTop());
586 mnu.SetItemEnabled(MR_ScreenDown, !
reader.IsTextBottom());
621 if(
reader.IsBufferReady())
643 if(e.Keys[VK_RBUTTON])
649 if(tmrScroll.IsActive())
663 reader.Stretch(boxReader.GetHeight());
670 using namespace Timers;
671 using namespace KeyCodes;
673 if(e.Strategy != RoutedEventArgs::Tunnel && !
mhMain.IsShowing(1u)
677 const auto ntick(HighResolutionClock::now());
686 const auto& k(e.GetKeys());
707 auto size(
reader.GetFont().GetSize());
717 else if(
YB_LIKELY(size < Font::MaximalSize))
742 tmrInput.Delay(HighResolutionClock::now() - ntick);
749 const shared_ptr<Desktop>& h_dsk_up,
const shared_ptr<Desktop>& h_dsk_dn)
753 HexArea.SetRenderer(make_unique<BufferedRenderer>(
true));
755 FetchEvent<KeyDown>(HexArea) += [
this](KeyEventArgs&& e){
761 + String(
to_string(HexArea.GetModel().GetPosition())
762 +
" / " +
to_string(HexArea.GetModel().GetSize()));
767 auto& dsk_up(GetDesktopUp());
768 auto& dsk_dn(GetDesktopDown());
769 const auto& path_str(pth.GetNativeString());
773 struct ::stat file_stat;
776 ::stat(path_str.c_str(), &file_stat);
782 HexArea.Load(path_str.c_str());
783 HexArea.UpdateData(0);