Skip to content

Commit bfbe0d2

Browse files
committed
fix: 起動時のブックと本棚の復元を整備 (#1754)
- 主に FirstLoader.cs の改善 - ブックと本棚の両方の復元が指定されている場合はそれぞれの復元情報を尊重するようにした - 履歴がなくても本棚の状態を復元可能にした - 本棚の並びがシャッフルの場合も復元できるようにした - アプリ終了処理でのハンドルされていない例外のキャッチを解除
1 parent 21a866f commit bfbe0d2

18 files changed

Lines changed: 254 additions & 147 deletions

NeeView/App.Exception.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ private void InitializeUnhandledException()
3737
this.DispatcherUnhandledException += Application_DispatcherUnhandledException;
3838
}
3939

40+
private void TerminateUnhandledException()
41+
{
42+
#if DEBUG
43+
TaskScheduler.UnobservedTaskException -= TaskScheduler_UnobservedTaskException;
44+
#endif
45+
AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException;
46+
this.DispatcherUnhandledException -= Application_DispatcherUnhandledException;
47+
}
48+
4049
/// <summary>
4150
/// TaskScheduler の未処理例外処理
4251
/// </summary>

NeeView/App.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,17 @@ private void Terminate(bool callProcessTerminator)
422422
if (_isTerminated) return;
423423
_isTerminated = true;
424424

425+
TerminateUnhandledException();
426+
425427
try
426428
{
427429
// 現在のブックを履歴に保存
428430
PageFrameBoxPresenter.Current.ForceSaveBookMemento();
429431
PageFrameBoxPresenter.Current.SaveLastBookMemento();
430432

433+
// 現在の本棚の場所を保存
434+
BookshelfFolderList.Current.SaveLastFolderPath();
435+
431436
// 各種Dispose
432437
ApplicationDisposer.Current.Dispose();
433438

@@ -455,6 +460,7 @@ private void Terminate(bool callProcessTerminator)
455460
{
456461
Debug.Assert(false, "Application Terminate failed!!");
457462
Trace.Fail($"App.Terminate: {DateTime.Now}: {ex.ToStackString()}");
463+
throw;
458464
}
459465

460466
if (callProcessTerminator)

NeeView/Config/StartUpConfig.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using NeeLaboratory.ComponentModel;
22
using NeeView.Windows.Property;
3+
using System;
34
using System.Runtime.Serialization;
45
using System.Text.Json.Serialization;
56

@@ -8,8 +9,9 @@ namespace NeeView
89
public class StartUpConfig : BindableBase
910
{
1011
private string? _lastBookPath;
11-
private BookMemento? _lastBookMement;
1212
private string? _lastFolderPath;
13+
private BookMemento? _lastBook;
14+
private BookshelfFolderMemento? _lastFolder;
1315
private bool _isSplashScreenEnabled = true;
1416
private bool _isMultiBootEnabled;
1517
private bool _isRestoreWindowPlacement = true;
@@ -89,26 +91,34 @@ public bool IsAutoPlaySlideShow
8991

9092
#region HiddenParameters
9193

92-
[PropertyMapIgnore]
94+
[Obsolete, PropertyMapIgnore]
9395
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
9496
public string? LastBookPath
9597
{
9698
get { return IsOpenLastBook ? _lastBookPath : null; }
9799
set { SetProperty(ref _lastBookPath, value); }
98100
}
99101

102+
[Obsolete, PropertyMapIgnore]
103+
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
104+
public string? LastFolderPath
105+
{
106+
get { return IsOpenLastFolder ? _lastFolderPath : null; }
107+
set { SetProperty(ref _lastFolderPath, value); }
108+
}
109+
100110
[PropertyMapIgnore]
101-
public BookMemento? LastBookMemento
111+
public BookMemento? LastBook
102112
{
103-
get { return _lastBookMement; }
104-
set { SetProperty(ref _lastBookMement, value); }
113+
get { return _lastBook; }
114+
set { SetProperty(ref _lastBook, value); }
105115
}
106116

107117
[PropertyMapIgnore]
108-
public string? LastFolderPath
118+
public BookshelfFolderMemento? LastFolder
109119
{
110-
get { return IsOpenLastFolder ? _lastFolderPath : null; }
111-
set { SetProperty(ref _lastFolderPath, value); }
120+
get { return _lastFolder; }
121+
set { SetProperty(ref _lastFolder, value); }
112122
}
113123

114124
#endregion HiddenParameters

NeeView/Languages/en.restext

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,6 @@ StartUpConfig.IsAutoPlaySlideShow=Start playing slideshow
19061906
StartUpConfig.IsMultiBootEnabled=Allow multiple activations
19071907
StartUpConfig.IsOpenLastBook=Restore an open book
19081908
StartUpConfig.IsOpenLastFolder=Restore bookshelf location
1909-
StartUpConfig.IsOpenLastFolder.Remarks=The location of the bookshelf if you do not open the book at startup.
19101909
StartUpConfig.IsRestoreFullScreen=Restore full screen state
19111910
StartUpConfig.IsRestoreSecondWindowPlacement=Restore the second window coordinates
19121911
StartUpConfig.IsRestoreSecondWindowPlacement.Remarks=Restores window coordinates even after duplicate launches. If turned off, the window will be displayed with the initial coordinates.

NeeView/Languages/it-IT.restext

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,6 @@ StartUpConfig.IsAutoPlaySlideShow=Inizia esecuzione presentazione
19121912
StartUpConfig.IsMultiBootEnabled=Permetti attivazioni multiple
19131913
StartUpConfig.IsOpenLastBook=Ripristina un libro aperto
19141914
StartUpConfig.IsOpenLastFolder=Ripristina posizione libreria
1915-
StartUpConfig.IsOpenLastFolder.Remarks=La posizione della libreria se non si apre il libro all'avvio.
19161915
StartUpConfig.IsRestoreFullScreen=Ripristina lo stato di schermo intero
19171916
StartUpConfig.IsRestoreSecondWindowPlacement=Ripristina coordinate seconda finestra
19181917
StartUpConfig.IsRestoreSecondWindowPlacement.Remarks=Ripristina le coordinate della finestra anche quando vengono lanciati i duplicati. Se disattivato, la finestra è mostrata con le coordinate iniziali.

NeeView/Languages/ja.restext

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,6 @@ StartUpConfig.IsAutoPlaySlideShow=スライドショーの再生を開始する
18981898
StartUpConfig.IsMultiBootEnabled=多重起動を許可する
18991899
StartUpConfig.IsOpenLastBook=開いていたブックを復元する
19001900
StartUpConfig.IsOpenLastFolder=本棚の場所を復元する
1901-
StartUpConfig.IsOpenLastFolder.Remarks=起動時に本を開かない場合の本棚の場所です。
19021901
StartUpConfig.IsRestoreFullScreen=フルスクリーン状態を復元する
19031902
StartUpConfig.IsRestoreSecondWindowPlacement=2 つめのウィンドウ座標の復元
19041903
StartUpConfig.IsRestoreSecondWindowPlacement.Remarks=重複起動した場合もウィンドウ座標を復元します。オフにすると初期座標で表示されます。

NeeView/Languages/ko.restext

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,6 @@ StartUpConfig.IsAutoPlaySlideShow=슬라이드쇼 재생 시작
18981898
StartUpConfig.IsMultiBootEnabled=다중 실행 허용
18991899
StartUpConfig.IsOpenLastBook=마지막으로 열었던 책 기억
19001900
StartUpConfig.IsOpenLastFolder=서랍 경로 기억
1901-
StartUpConfig.IsOpenLastFolder.Remarks=책을 열지 않고 실행 시 서랍 경로
19021901
StartUpConfig.IsRestoreFullScreen=전체 화면 상태 기억
19031902
StartUpConfig.IsRestoreSecondWindowPlacement=2개째의 창 위치 기억
19041903
StartUpConfig.IsRestoreSecondWindowPlacement.Remarks=중복 실행 시에도 창 위치를 복원합니다. 이 항목을 끄면 초기 위치에 표시됩니다.

NeeView/Languages/pt-BR.restext

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,6 @@ StartUpConfig.IsAutoPlaySlideShow=Comece a reproduzir o slideshow
19061906
StartUpConfig.IsMultiBootEnabled=Permitir múltiplas instâncias
19071907
StartUpConfig.IsOpenLastBook=Restaurar um livro aberto
19081908
StartUpConfig.IsOpenLastFolder=Restaurar localização da estante
1909-
StartUpConfig.IsOpenLastFolder.Remarks=A localização da estante se você não abrir o livro na inicialização.
19101909
StartUpConfig.IsRestoreFullScreen=Restaurar o estado de tela cheia
19111910
StartUpConfig.IsRestoreSecondWindowPlacement=Restaure as coordenadas da segunda janela
19121911
StartUpConfig.IsRestoreSecondWindowPlacement.Remarks=Restaure também as coordenadas da janela quando as duplicatas forem ativadas. Quando definido como DESLIGADO, é exibido nas coordenadas iniciais.

NeeView/Languages/ru.restext

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,6 @@ StartUpConfig.IsAutoPlaySlideShow=Начать воспроизведение с
19061906
StartUpConfig.IsMultiBootEnabled=Разрешить несколько запусков
19071907
StartUpConfig.IsOpenLastBook=Восстановить открытую книгу
19081908
StartUpConfig.IsOpenLastFolder=Восстановить расположение книжной полки
1909-
StartUpConfig.IsOpenLastFolder.Remarks=Расположение книжной полки, если вы не открываете книгу при запуске.
19101909
StartUpConfig.IsRestoreFullScreen=Восстановить полноэкранное состояние
19111910
StartUpConfig.IsRestoreSecondWindowPlacement=Восстановить координаты второго окна
19121911
StartUpConfig.IsRestoreSecondWindowPlacement.Remarks=Восстанавливает координаты окна даже после повторных запусков. Если выключено, окно будет отображаться с начальными координатами.

NeeView/Languages/zh-Hans.restext

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,6 @@ StartUpConfig.IsAutoPlaySlideShow=启动幻灯片播放
18981898
StartUpConfig.IsMultiBootEnabled=允许多重启动
18991899
StartUpConfig.IsOpenLastBook=恢复打开的书籍
19001900
StartUpConfig.IsOpenLastFolder=恢复书架位置
1901-
StartUpConfig.IsOpenLastFolder.Remarks=启动时如果未打开书籍的书架位置。
19021901
StartUpConfig.IsRestoreFullScreen=恢复全屏状态
19031902
StartUpConfig.IsRestoreSecondWindowPlacement=恢复第二窗口坐标
19041903
StartUpConfig.IsRestoreSecondWindowPlacement.Remarks=即使在重复启动后也恢复窗口坐标。如果关闭,窗口将以初始坐标显示。

0 commit comments

Comments
 (0)