Skip to content

Commit

Permalink
Opening book details from the scan results
Browse files Browse the repository at this point in the history
  • Loading branch information
libgenapps committed May 24, 2018
1 parent 37ba310 commit 3b35b27
Show file tree
Hide file tree
Showing 19 changed files with 486 additions and 34 deletions.
4 changes: 2 additions & 2 deletions LibgenDesktop.Setup/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
internal static class Constants
{
public const string CURRENT_VERSION = "1.1.4";
public const string TITLE_VERSION = "1.1.4";
public const string CURRENT_VERSION = "1.1.5";
public const string TITLE_VERSION = "1.1.5";
public const string PRODUCT_TITLE_FORMAT = "Libgen Desktop " + TITLE_VERSION + " ({0}-bit)";
public const string SHORTCUT_TITLE_FORMAT = "Libgen Desktop ({0}-bit)";
public const string PRODUCT_COMPANY = "Libgen Apps";
Expand Down
6 changes: 3 additions & 3 deletions LibgenDesktop/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace LibgenDesktop.Common
{
internal static class Constants
{
public const string CURRENT_VERSION = "1.1.4";
public const string CURRENT_GITHUB_RELEASE_NAME = "1.1.4";
public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2018, 5, 23);
public const string CURRENT_VERSION = "1.1.5";
public const string CURRENT_GITHUB_RELEASE_NAME = "1.1.5";
public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2018, 5, 24);
public const string CURRENT_DATABASE_VERSION = "1.0";

public const string APP_SETTINGS_FILE_NAME = "libgen.config";
Expand Down
1 change: 0 additions & 1 deletion LibgenDesktop/Infrastructure/RegisteredWindows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ static RegisteredWindows()
RegisterWindow(WindowKey.CREATE_DATABASE_WINDOW, typeof(CreateDatabaseWindow), typeof(CreateDatabaseWindowViewModel));
RegisterWindow(WindowKey.SETTINGS_WINDOW, typeof(SettingsWindow), typeof(SettingsWindowViewModel));
RegisterWindow(WindowKey.SYNCHRONIZATION_WINDOW, typeof(SynchronizationWindow), typeof(SynchronizationWindowViewModel));
RegisterWindow(WindowKey.LIBRARY_WINDOW, typeof(LibraryWindow), typeof(LibraryWindowViewModel));
RegisterWindow(WindowKey.APPLICATION_UPDATE_WINDOW, typeof(ApplicationUpdateWindow), typeof(ApplicationUpdateWindowViewModel));
RegisterWindow(WindowKey.DATABASE_WINDOW, typeof(DatabaseWindow), typeof(DatabaseWindowViewModel));
RegisterWindow(WindowKey.ABOUT_WINDOW, typeof(AboutWindow), typeof(AboutWindowViewModel));
Expand Down
12 changes: 6 additions & 6 deletions LibgenDesktop/LibgenDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
<Compile Include="Models\Localization\Localizators\ApplicationUpdateLocalizator.cs" />
<Compile Include="Models\Localization\Localizators\CommonDetailsTabLocalizator.cs" />
<Compile Include="Models\Localization\Localizators\AboutWindowLocalizator.cs" />
<Compile Include="Models\Localization\Localizators\LibraryWindowLocalizator.cs" />
<Compile Include="Models\Localization\Localizators\LibraryTabLocalizator.cs" />
<Compile Include="Models\Localization\Localizators\DatabaseWindowLocalizator.cs" />
<Compile Include="Models\Localization\Localizators\CreateDatabaseWindowLocalizator.cs" />
<Compile Include="Models\Localization\Localizators\DetailsTabLocalizator.cs" />
Expand Down Expand Up @@ -244,7 +244,7 @@
<Compile Include="ViewModels\Windows\ApplicationUpdateWindowViewModel.cs" />
<Compile Include="ViewModels\Tabs\DetailsTabViewModel.cs" />
<Compile Include="ViewModels\Windows\AboutWindowViewModel.cs" />
<Compile Include="ViewModels\Windows\LibraryWindowViewModel.cs" />
<Compile Include="ViewModels\Tabs\LibraryTabViewModel.cs" />
<Compile Include="ViewModels\Windows\DatabaseWindowViewModel.cs" />
<Compile Include="ViewModels\Windows\DetailsWindowViewModel.cs" />
<Compile Include="ViewModels\EventArguments\OpenFictionDetailsEventArgs.cs" />
Expand Down Expand Up @@ -301,8 +301,8 @@
<Compile Include="Views\Windows\AboutWindow.xaml.cs">
<DependentUpon>AboutWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Windows\LibraryWindow.xaml.cs">
<DependentUpon>LibraryWindow.xaml</DependentUpon>
<Compile Include="Views\Tabs\LibraryTab.xaml.cs">
<DependentUpon>LibraryTab.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Windows\DatabaseWindow.xaml.cs">
<DependentUpon>DatabaseWindow.xaml</DependentUpon>
Expand Down Expand Up @@ -385,7 +385,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Styles\LibraryWindowStyles.xaml">
<Page Include="Views\Styles\LibraryTabStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
Expand Down Expand Up @@ -421,7 +421,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\Windows\LibraryWindow.xaml">
<Page Include="Views\Tabs\LibraryTab.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
Expand Down
4 changes: 2 additions & 2 deletions LibgenDesktop/Models/Localization/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class Language
private SynchronizationLocalizator synchronization;
private DownloadManagerLocalizator downloadManager;
private ApplicationUpdateLocalizator applicationUpdate;
private LibraryWindowLocalizator library;
private LibraryTabLocalizator library;
private DatabaseWindowLocalizator database;
private SettingsWindowLocalizator settings;
private AboutWindowLocalizator about;
Expand Down Expand Up @@ -128,7 +128,7 @@ public Language(List<Translation> prioritizedTranslationList)
public ApplicationUpdateLocalizator ApplicationUpdate =>
applicationUpdate ?? (applicationUpdate = new ApplicationUpdateLocalizator(translations, Formatter));

public LibraryWindowLocalizator Library => library ?? (library = new LibraryWindowLocalizator(translations, Formatter));
public LibraryTabLocalizator Library => library ?? (library = new LibraryTabLocalizator(translations, Formatter));

public DatabaseWindowLocalizator Database => database ?? (database = new DatabaseWindowLocalizator(translations, Formatter));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;

namespace LibgenDesktop.Models.Localization.Localizators
{
internal class LibraryTabLocalizator : Localizator
{
public LibraryTabLocalizator(List<Translation> prioritizedTranslationList, LanguageFormatter formatter)
: base(prioritizedTranslationList, formatter)
{
TabTitle = Format(translation => translation?.TabTitle);
Scan = Format(translation => translation?.Scan);
BrowseDirectoryDialogTitle = Format(translation => translation?.BrowseDirectoryDialogTitle);
CreatingIndexes = Format(translation => translation?.CreatingIndexes);
ScanLog = Format(translation => translation?.ScanLog);
Error = Format(translation => translation?.Error);
ColumnsFile = Format(translation => translation?.File);
ColumnsAuthors = Format(translation => translation?.Authors);
ColumnsTitle = Format(translation => translation?.Title);
}

public string TabTitle { get; }
public string Scan { get; }
public string BrowseDirectoryDialogTitle { get; }
public string CreatingIndexes { get; }
public string ScanLog { get; }
public string Error { get; }
public string ColumnsFile { get; }
public string ColumnsAuthors { get; }
public string ColumnsTitle { get; }

public string GetScanStartedString(string directory) => Format(translation => translation?.ScanStarted, new { directory });
public string GetFoundString(int count) => Format(translation => translation?.Found, new { count });
public string GetNotFoundString(int count) => Format(translation => translation?.NotFound, new { count });
public string GetScanCompleteString(int found, int notFound, int errors) => Format(translation => translation?.ScanComplete,
new { found = Formatter.ToFormattedString(found), notFound = Formatter.ToFormattedString(notFound),
errors = Formatter.ToFormattedString(errors) });

private string Format(Func<Translation.LibraryTranslation, string> field, object templateArguments = null)
{
return Format(translation => field(translation?.Library), templateArguments);
}

private string Format(Func<Translation.LibraryColumnsTranslation, string> field, object templateArguments = null)
{
return Format(translation => field(translation?.Library?.Columns), templateArguments);
}
}
}
2 changes: 1 addition & 1 deletion LibgenDesktop/Models/Localization/Translation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ internal class LibraryColumnsTranslation

internal class LibraryTranslation
{
public string WindowTitle { get; set; }
public string TabTitle { get; set; }
public string Scan { get; set; }
public string BrowseDirectoryDialogTitle { get; set; }
public string ScanStarted { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion LibgenDesktop/Models/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ private void ScanDirectory(string rootScanDirectory, string scanDirectory, IProg
NonFictionBook book = localDatabase.GetNonFictionBookByMd5Hash(md5Hash);
if (book != null)
{
progressHandler.Report(new ScanProgress(relativeFilePath, book.Authors, book.Title));
progressHandler.Report(new ScanProgress(relativeFilePath, book.Authors, book.Title, book));
found++;
}
else
Expand Down
9 changes: 7 additions & 2 deletions LibgenDesktop/Models/ProgressArgs/ScanProgress.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace LibgenDesktop.Models.ProgressArgs
using LibgenDesktop.Models.Entities;

namespace LibgenDesktop.Models.ProgressArgs
{
internal class ScanProgress
{
Expand All @@ -9,21 +11,24 @@ public ScanProgress(string relativeFilePath, bool error = false)
Error = error;
Authors = null;
Title = null;
LibgenObject = null;
}

public ScanProgress(string relativeFilePath, string authors, string title)
public ScanProgress(string relativeFilePath, string authors, string title, NonFictionBook libgenObject)
{
RelativeFilePath = relativeFilePath;
Found = true;
Error = false;
Authors = authors;
Title = title;
LibgenObject = libgenObject;
}

public string RelativeFilePath { get; }
public bool Found { get; }
public bool Error { get; }
public string Authors { get; }
public string Title { get; }
public NonFictionBook LibgenObject { get; }
}
}
4 changes: 2 additions & 2 deletions LibgenDesktop/Resources/Languages/English.lng
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"Update": "Update...",
"Import": "Import...",
"Synchronize": "Synchronization...",
"Library": "Library...",
"Library": "Library",
"Database": "Database...",
"Settings": "Settings",
"About": "About"
Expand Down Expand Up @@ -502,7 +502,7 @@
},
"Library":
{
"WindowTitle": "Local library",
"TabTitle": "Library",
"Scan": "SCAN FOR NON-FICTION BOOKS...",
"BrowseDirectoryDialogTitle": "Scan for non-fiction books in...",
"ScanStarted": "Scan started in {directory}",
Expand Down
4 changes: 2 additions & 2 deletions LibgenDesktop/Resources/Languages/Russian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"Update": "Обновление...",
"Import": "Импорт...",
"Synchronize": "Синхронизация...",
"Library": "Библиотека...",
"Library": "Библиотека",
"Database": "База данных...",
"Settings": "Настройки",
"About": "О программе"
Expand Down Expand Up @@ -502,7 +502,7 @@
},
"Library":
{
"WindowTitle": "Локальная библиотека",
"TabTitle": "Библиотека",
"Scan": "СКАНИРОВАТЬ ПО БАЗЕ НЕХУДОЖЕСТВЕННОЙ ЛИТЕРАТУРЫ...",
"BrowseDirectoryDialogTitle": "Искать известные книги в...",
"ScanStarted": "Начато сканирование в {directory}",
Expand Down
4 changes: 3 additions & 1 deletion LibgenDesktop/ViewModels/Library/ScanResultItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ namespace LibgenDesktop.ViewModels.Library
internal class ScanResultItemViewModel : ViewModel
{
public ScanResultItemViewModel(LibgenObjectType libgenObjectType, int libgenObjectId, string fullFilePath, string relativeFilePath, string authors,
string title)
string title, NonFictionBook libgenObject)
{
LibgenObjectType = libgenObjectType;
LibgenObjectId = libgenObjectId;
FullFilePath = fullFilePath;
RelativeFilePath = relativeFilePath;
Authors = authors;
Title = title;
LibgenObject = libgenObject;
}

public LibgenObjectType LibgenObjectType { get; }
Expand All @@ -21,5 +22,6 @@ public ScanResultItemViewModel(LibgenObjectType libgenObjectType, int libgenObje
public string RelativeFilePath { get; }
public string Authors { get; }
public string Title { get; }
public NonFictionBook LibgenObject { get; }
}
}
Loading

0 comments on commit 3b35b27

Please sign in to comment.