Skip to content

Commit

Permalink
Merge branch 'release/v1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
tor4kichi committed Nov 20, 2021
2 parents 601405c + 9bd7af7 commit c27ba3b
Show file tree
Hide file tree
Showing 61 changed files with 3,509 additions and 1,269 deletions.
27 changes: 25 additions & 2 deletions TsubameViewer/TsubameViewer.Shared/App.xaml
Expand Up @@ -12,7 +12,9 @@
xmlns:uwpControls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:uwpConv="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:folderListup="using:TsubameViewer.Presentation.Views.FolderListup"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls">
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:myFlyouts="using:TsubameViewer.Presentation.Views.Flyouts"
>

<prism:PrismApplication.Resources>
<ResourceDictionary>
Expand All @@ -34,7 +36,10 @@
</ResourceDictionary.ThemeDictionaries>

<x:Boolean x:Key="DebugTVMode">False</x:Boolean>



<myFlyouts:StorageItemMenuFlyout x:Key="StorageItemMenuFlyout" />

<locale:LocalizeConverter x:Key="LocalizeConverter" />
<locale:LocaleToDisplayNameConverter x:Key="LocaleToDisplayNameConverter" />

Expand All @@ -53,6 +58,24 @@
</uwpConv:EmptyCollectionToObjectConverter.NotEmptyValue>
</uwpConv:EmptyCollectionToObjectConverter>

<uwpConv:EmptyStringToObjectConverter x:Key="StringNotEmptyToBooleanConverter">
<uwpConv:EmptyStringToObjectConverter.EmptyValue>
<x:Boolean>False</x:Boolean>
</uwpConv:EmptyStringToObjectConverter.EmptyValue>
<uwpConv:EmptyStringToObjectConverter.NotEmptyValue>
<x:Boolean>True</x:Boolean>
</uwpConv:EmptyStringToObjectConverter.NotEmptyValue>
</uwpConv:EmptyStringToObjectConverter>

<uwpConv:EmptyStringToObjectConverter x:Key="StringEmptyToBooleanConverter">
<uwpConv:EmptyStringToObjectConverter.EmptyValue>
<x:Boolean>True</x:Boolean>
</uwpConv:EmptyStringToObjectConverter.EmptyValue>
<uwpConv:EmptyStringToObjectConverter.NotEmptyValue>
<x:Boolean>False</x:Boolean>
</uwpConv:EmptyStringToObjectConverter.NotEmptyValue>
</uwpConv:EmptyStringToObjectConverter>

<myConv:ColorToBrush x:Key="ColorToBrush" />
<myConv:NotTransparentColorToBooleanConverter x:Key="NotTransparentColorToBooleanConverter" />
<myConv:NullableColorConverter x:Key="NullableColorConverter" />
Expand Down
14 changes: 13 additions & 1 deletion TsubameViewer/TsubameViewer.Shared/App.xaml.cs
@@ -1,6 +1,7 @@
using LiteDB;
using Microsoft.Extensions.Logging;
using Microsoft.IO;
using Microsoft.Toolkit.Mvvm.Messaging;
using Prism;
using Prism.Ioc;
using Prism.Mvvm;
Expand All @@ -13,11 +14,13 @@
using System.IO;
using System.Linq;
using System.Reactive.Concurrency;
using System.Threading;
using System.Threading.Tasks;
using TsubameViewer.Models.Domain;
using TsubameViewer.Models.Domain.FolderItemListing;
using TsubameViewer.Models.Domain.SourceFolders;
using TsubameViewer.Presentation.Services.UWP;
using TsubameViewer.Presentation.ViewModels;
using TsubameViewer.Presentation.ViewModels.PageNavigation;
using TsubameViewer.Presentation.Views;
using Unity;
Expand Down Expand Up @@ -122,6 +125,7 @@ protected override void RegisterRequiredTypes(IContainerRegistry container)

public override void RegisterTypes(IContainerRegistry container)
{
container.RegisterInstance<IMessenger>(WeakReferenceMessenger.Default);
container.RegisterSingleton<Models.Domain.ImageViewer.ImageViewerSettings>();
container.RegisterSingleton<Models.Domain.FolderItemListing.FolderListingSettings>();

Expand All @@ -131,6 +135,13 @@ public override void RegisterTypes(IContainerRegistry container)
container.RegisterSingleton<Models.UseCase.PathReferenceCountUpdateWhenSourceManagementChanged>();
container.RegisterInstance(new RecyclableMemoryStreamManager());

container.RegisterSingleton<SourceStorageItemsPageViewModel>();
container.RegisterSingleton<ImageListupPageViewModel>();
container.RegisterSingleton<FolderListupPageViewModel>();
container.RegisterSingleton<ImageViewerPageViewModel>();
container.RegisterSingleton<EBookReaderPageViewModel>();
container.RegisterSingleton<SearchResultPageViewModel>();

container.RegisterForNavigation<SourceStorageItemsPage>();
container.RegisterForNavigation<ImageListupPage>();
container.RegisterForNavigation<FolderListupPage>();
Expand Down Expand Up @@ -261,6 +272,7 @@ public override async void OnInitialized()
var ns = shell.GetNavigationService();
var unityContainer = Container.GetContainer();
unityContainer.RegisterInstance<INavigationService>("PrimaryWindowNavigationService", ns);
unityContainer.RegisterInstance<INavigationService>(ns);

Window.Current.Content = shell;
Window.Current.Activate();
Expand Down Expand Up @@ -421,7 +433,7 @@ async Task<INavigationResult> NavigateAsync(PageNavigationInfo info)
if (item is StorageFolder itemFolder)
{
var containerTypeManager = Container.Resolve<FolderContainerTypeManager>();
if (await containerTypeManager.GetFolderContainerTypeWithCacheAsync(itemFolder) == FolderContainerType.OnlyImages)
if (await containerTypeManager.GetFolderContainerTypeWithCacheAsync(itemFolder, CancellationToken.None) == FolderContainerType.OnlyImages)
{
return await navigationService.NavigateAsync(nameof(Presentation.Views.ImageViewerPage), parameters, new SuppressNavigationTransitionInfo());
}
Expand Down
6 changes: 6 additions & 0 deletions TsubameViewer/TsubameViewer.Shared/IsExternalInit.cs
@@ -0,0 +1,6 @@

namespace System.Runtime.CompilerServices
{
internal class IsExternalInit { }
}

19 changes: 15 additions & 4 deletions TsubameViewer/TsubameViewer.Shared/Locales/en-US.txt
Expand Up @@ -73,18 +73,28 @@ ChangeViewToImageListupPage = Switch to image list view


FileSortTitle = Sorting
FileSortType.TitleAscending = File name (ascending order)
FileSortType.TitleDecending = File name (descending order)
FileSortType.UpdateTimeAscending = Recent first
FileSortType.UpdateTimeDecending = Latest first
FileSortType.UpdateTimeDescThenTitleAsc = Latest & Title Asc
FileSortType.TitleAscending = Title Asc
FileSortType.TitleDecending = Title Desc
FileSortType.UpdateTimeAscending = Recent
FileSortType.UpdateTimeDecending = Latest

Sort_InheritancePath = Sort inheritance source
Sort_Unselected = Unspecified
Sort_DefaultChildItemSort = Sorting images in child folders
TitleDigitCompletion = Title digit completion


OpenImageViewer = Open in reader
OpenFolderListup = List files
OpenWithExplorer = Open in explorer
OpenWithExternalApplication = Open with

AddSecondaryTile = Pin to start
RemoveSecondaryTile = Unpin the start

SetThumbnailImage = Set as thumbnail image

FolderItemMenuNoActionSuggested = No action available

#### ImageViewerPage
Expand All @@ -96,6 +106,7 @@ IsEnableSpreadDisplay = Spread display
IsLeftBindingView = Left binding display

SwitchFullScreen = Full screen switching
DoubleViewCorrectPaging = Correct the page shift of the spread


#### EBookReaderPage
Expand Down
17 changes: 14 additions & 3 deletions TsubameViewer/TsubameViewer.Shared/Locales/ja-JP.txt
Expand Up @@ -72,19 +72,29 @@ ChangeViewToImageListupPage = 画像一覧ビューに切替



FileSortTitle = 並べ替え
FileSortType.TitleAscending = ファイル名(昇順)
FileSortType.TitleDecending = ファイル名(降順)
FileSortTitle = 並び替え
FileSortType.UpdateTimeDescThenTitleAsc = 新しい順&タイトル昇順
FileSortType.TitleAscending = タイトル昇順
FileSortType.TitleDecending = タイトル降順
FileSortType.UpdateTimeAscending = 古い順
FileSortType.UpdateTimeDecending = 新しい順

Sort_InheritancePath = 並び替え継承元
Sort_Unselected = 未指定
Sort_DefaultChildItemSort = 子フォルダの画像並び替え
TitleDigitCompletion = タイトルの桁数補完


OpenImageViewer = リーダーで開く
OpenFolderListup = ファイルを一覧表示
OpenWithExplorer = エクスプローラーで開く
OpenWithExternalApplication = 別アプリで開く

AddSecondaryTile = スタートにピン留めする
RemoveSecondaryTile = スタートのピン留めを解除

SetThumbnailImage = サムネイル画像に設定

FolderItemMenuNoActionSuggested = 選択可能なアクションはありません

#### ImageViewerPage
Expand All @@ -96,6 +106,7 @@ IsEnableSpreadDisplay = 見開き表示
IsLeftBindingView = 左綴じ表示

SwitchFullScreen = 全画面切替
DoubleViewCorrectPaging = 見開きのページズレを補正する


#### EBookReaderPage
Expand Down
11 changes: 11 additions & 0 deletions TsubameViewer/TsubameViewer.Shared/Locales/zh-CHS.txt
Expand Up @@ -73,18 +73,28 @@ ChangeViewToImageListupPage = 切换到图像列表视图


FileSortTitle = 排序
FileSortType.UpdateTimeDescThenTitleAsc = 新订单和标题升序
FileSortType.TitleAscending = 文件名(升序)
FileSortType.TitleDecending = 文件名(降序)
FileSortType.UpdateTimeAscending = 最旧的优先
FileSortType.UpdateTimeDecending = 新命令

Sort_InheritancePath = 排序继承源
Sort_Unselected = 未指定
Sort_DefaultChildItemSort = 对子文件夹中的图像进行排序
TitleDigitCompletion = 标题数字完成


OpenImageViewer = 在阅读器中打开
OpenFolderListup = 列出档案
OpenWithExplorer = 在资源管理器中打开
OpenWithExternalApplication = 在另一个应用程序中打开

AddSecondaryTile = 固定即可开始
RemoveSecondaryTile = 取消开始

SetThumbnailImage = 设置为缩略图

FolderItemMenuNoActionSuggested = 没有可用的动作

#### ImageViewerPage
Expand All @@ -96,6 +106,7 @@ IsEnableSpreadDisplay = 点差显示
IsLeftBindingView = 左绑定显示

SwitchFullScreen = 全屏切换
DoubleViewCorrectPaging = 纠正传播的页面偏移


#### EBookReaderPage
Expand Down
@@ -0,0 +1,146 @@
using LiteDB;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using TsubameViewer.Models.Infrastructure;

namespace TsubameViewer.Models.Domain.FolderItemListing
{
public record FolderAndArchiveDisplaySettingEntry
{
[BsonId]
public string Path { get; init; }

public FileSortType Sort { get; init; }

public bool IsTitleDigitInterpolation { get; init; }
}

public record FolderAndArchiveChildFileDisplaySettingEntry
{
[BsonId]
public string Path { get; init; }

public FileSortType? ChildItemDefaultSort { get; init; }
}

public record FileDisplaySettingEntry
{
[BsonId]
public string Path { get; init; }


public FileSortType Sort { get; init; }

public bool IsTitleDigitInterpolation { get; init; }
}

public sealed class DisplaySettingsByPathRepository
{
public sealed class InternalFolderAndArchiveDisplaySettingsByPathRepository : LiteDBServiceBase<FolderAndArchiveDisplaySettingEntry>
{
public InternalFolderAndArchiveDisplaySettingsByPathRepository(ILiteDatabase liteDatabase) : base(liteDatabase)
{
}

public FolderAndArchiveDisplaySettingEntry FindById(string path)
{
return _collection.FindById(path);
}

public int DeleteUnderPath(string path)
{
return _collection.DeleteMany(x => x.Path.StartsWith(path));
}
}

public sealed class InternalFolderAndArchiveChildFileDisplaySettingsByPathRepository : LiteDBServiceBase<FolderAndArchiveChildFileDisplaySettingEntry>
{
public InternalFolderAndArchiveChildFileDisplaySettingsByPathRepository(ILiteDatabase liteDatabase) : base(liteDatabase)
{
}

public FolderAndArchiveChildFileDisplaySettingEntry FindById(string path)
{
return _collection.FindById(path);
}

public int DeleteUnderPath(string path)
{
return _collection.DeleteMany(x => x.Path.StartsWith(path));
}
}


private readonly InternalFolderAndArchiveDisplaySettingsByPathRepository _internalFolderAndArchiveRepository;
private readonly InternalFolderAndArchiveChildFileDisplaySettingsByPathRepository _internalChildFileRepository;

public DisplaySettingsByPathRepository(
InternalFolderAndArchiveDisplaySettingsByPathRepository folderAndArchiveRepository,
InternalFolderAndArchiveChildFileDisplaySettingsByPathRepository childFileRepository
)
{
_internalFolderAndArchiveRepository = folderAndArchiveRepository;
_internalChildFileRepository = childFileRepository;
}

public FolderAndArchiveDisplaySettingEntry GetFolderAndArchiveSettings(string path)
{
return _internalFolderAndArchiveRepository.FindById(path);
}

public void SetFolderAndArchiveSettings(string path, FileSortType sortType, bool withTitleDigitInterpolation)
{
_internalFolderAndArchiveRepository.UpdateItem(new FolderAndArchiveDisplaySettingEntry()
{
Path = path,
Sort = sortType,
IsTitleDigitInterpolation = withTitleDigitInterpolation
});
}

public void ClearFolderAndArchiveSettings(string path)
{
_internalFolderAndArchiveRepository.DeleteUnderPath(path);
}


public FileSortType? GetFileParentSettings(string path)
{
return _internalChildFileRepository.FindById(path)?.ChildItemDefaultSort;
}

public FolderAndArchiveChildFileDisplaySettingEntry GetFileParentSettingsUpStreamToRoot(string path)
{
while (!string.IsNullOrEmpty(path))
{
if (_internalChildFileRepository.FindById(path) is not null and var entry)
{
return entry;
}

path = Path.GetDirectoryName(path);
}

return null;
}


public void SetFileParentSettings(string path, FileSortType? sort)
{
_internalChildFileRepository.UpdateItem(new FolderAndArchiveChildFileDisplaySettingEntry()
{
Path = path,
ChildItemDefaultSort = sort,
});
}


public void DeleteUnderPath(string path)
{
_internalFolderAndArchiveRepository.DeleteUnderPath(path);
_internalChildFileRepository.DeleteUnderPath(path);
}
}
}
Expand Up @@ -6,6 +6,7 @@ namespace TsubameViewer.Models.Domain.FolderItemListing
{
public enum FileSortType
{
UpdateTimeDescThenTitleAsc,
TitleAscending,
TitleDecending,
UpdateTimeAscending,
Expand Down

0 comments on commit c27ba3b

Please sign in to comment.