Skip to content

Commit

Permalink
Search results grid context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
libgenapps committed May 22, 2019
1 parent 3cdc328 commit fdabef4
Show file tree
Hide file tree
Showing 36 changed files with 436 additions and 287 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.2.5";
public const string TITLE_VERSION = "1.2.5";
public const string CURRENT_VERSION = "1.3.0";
public const string TITLE_VERSION = "1.3.0";
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 @@ -5,9 +5,9 @@ namespace LibgenDesktop.Common
internal static class Constants
{
public const string DATABASE_METADATA_APP_NAME = "LibgenDesktop";
public const string CURRENT_VERSION = "1.2.5";
public const string CURRENT_GITHUB_RELEASE_NAME = "1.2.5";
public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2019, 3, 6);
public const string CURRENT_VERSION = "1.3.0";
public const string CURRENT_GITHUB_RELEASE_NAME = "1.3.0";
public static readonly DateTime CURRENT_GITHUB_RELEASE_DATE = new DateTime(2019, 5, 22);
public const string CURRENT_DATABASE_VERSION = "1.2.1";

public const string APP_SETTINGS_FILE_NAME = "libgen.config";
Expand Down
3 changes: 1 addition & 2 deletions LibgenDesktop/Infrastructure/EventProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;

namespace LibgenDesktop.Infrastructure
Expand Down
10 changes: 8 additions & 2 deletions LibgenDesktop/Infrastructure/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal static class WindowManager
private const int GWL_STYLE = -16;
private const int WS_MAXIMIZEBOX = 0x10000;
private const int WS_MINIMIZEBOX = 0x20000;
private const int WS_SYSMENU = 0x80000;
private const int GWL_EXSTYLE = -20;
private const int WS_EX_DLGMODALFRAME = 0x0001;
private const int SWP_NOSIZE = 0x0001;
Expand Down Expand Up @@ -172,14 +173,19 @@ public static SelectFolderDialogResult ShowSelectFolderDialog(SelectFolderDialog
}
}

public static void RemoveWindowMinimizeButton(Window window)
{
RemoveWindowStyle(window, WS_MINIMIZEBOX);
}

public static void RemoveWindowMaximizeButton(Window window)
{
RemoveWindowStyle(window, WS_MAXIMIZEBOX);
}

public static void RemoveWindowMinimizeButton(Window window)
public static void RemoveWindowCloseButton(Window window)
{
RemoveWindowStyle(window, WS_MINIMIZEBOX);
RemoveWindowStyle(window, WS_SYSMENU);
}

public static void RemoveWindowIcon(Window window)
Expand Down
7 changes: 7 additions & 0 deletions LibgenDesktop/LibgenDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@
<Compile Include="ViewModels\Tabs\SearchTabViewModel.cs" />
<Compile Include="ViewModels\Windows\SettingsWindowViewModel.cs" />
<Compile Include="ViewModels\Tabs\TabViewModel.cs" />
<Compile Include="Views\Controls\BookDataGridContextMenu.xaml.cs">
<DependentUpon>BookDataGridContextMenu.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Controls\HorizontalScrollViewer.cs" />
<Compile Include="Views\Utils\IconExtension.cs" />
<Compile Include="Views\Windows\ApplicationUpdateWindow.xaml.cs">
Expand Down Expand Up @@ -392,6 +395,10 @@
<Compile Include="Views\Utils\EventListenerExtensions.cs" />
<Compile Include="Views\Utils\GridLengthConverter.cs" />
<Compile Include="Views\Utils\PasswordBoxExtensions.cs" />
<Page Include="Views\Controls\BookDataGridContextMenu.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Styles\AboutWindowStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
31 changes: 25 additions & 6 deletions LibgenDesktop/Models/Download/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -886,15 +887,33 @@ private Task<HttpResponseMessage> SendRequestAsync(HttpRequestMessage request, C
CancellationTokenSource combinedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
Task<HttpResponseMessage> innerTask = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead,
combinedCancellationTokenSource.Token);
bool success = innerTask.Wait(TimeSpan.FromSeconds(downloadSettings.Timeout));
if (success)
try
{
return innerTask.Result;
bool success = innerTask.Wait(TimeSpan.FromSeconds(downloadSettings.Timeout));
if (success)
{
return innerTask.Result;
}
else
{
combinedCancellationTokenSource.Cancel();
throw new TimeoutException();
}
}
else
catch (Exception exception)
{
combinedCancellationTokenSource.Cancel();
throw new TimeoutException();
while (!(exception is SocketException) && exception.InnerException != null)
{
exception = exception.InnerException;
}
if (exception is SocketException socketException && socketException.SocketErrorCode == SocketError.TimedOut)
{
throw new TimeoutException();
}
else
{
throw;
}
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ public SearchResultsTabLocalizator(List<Translation> prioritizedTranslationList,
AddToBookmarksTooltip = Format(translation => translation?.AddToBookmarksTooltip);
RemoveFromBookmarksTooltip = Format(translation => translation?.RemoveFromBookmarksTooltip);
ExportButtonTooltip = Format(translation => translation?.ExportButtonTooltip);
Details = Format(translation => translation?.Details);
Open = Format(translation => translation?.Open);
Download = Format(translation => translation?.Download);
ErrorMessageTitle = Format(translation => translation?.ErrorMessageTitle);
OfflineModeIsOnMessageTitle = Format(translation => translation?.OfflineModeIsOnMessageTitle);
OfflineModeIsOnMessageText = Format(translation => translation?.OfflineModeIsOnMessageText);
NoDownloadMirrorError = Format(translation => translation?.NoDownloadMirrorError);
}

public string SearchPlaceHolder { get; }
Expand All @@ -24,6 +31,15 @@ public SearchResultsTabLocalizator(List<Translation> prioritizedTranslationList,
public string AddToBookmarksTooltip { get; }
public string RemoveFromBookmarksTooltip { get; }
public string ExportButtonTooltip { get; }
public string Details { get; }
public string Open { get; }
public string Download { get; }
public string ErrorMessageTitle { get; }
public string OfflineModeIsOnMessageTitle { get; }
public string OfflineModeIsOnMessageText { get; }
public string NoDownloadMirrorError { get; }

public string GetFileNotFoundErrorText(string file) => Format(translation => translation?.FileNotFoundError, new { file });

private string Format(Func<Translation.SearchResultsTabsTranslation, string> field, object templateArguments = null)
{
Expand Down
8 changes: 8 additions & 0 deletions LibgenDesktop/Models/Localization/Translation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ internal class SearchResultsTabsTranslation
public string AddToBookmarksTooltip { get; set; }
public string RemoveFromBookmarksTooltip { get; set; }
public string ExportButtonTooltip { get; set; }
public string Details { get; set; }
public string Open { get; set; }
public string Download { get; set; }
public string ErrorMessageTitle { get; set; }
public string FileNotFoundError { get; set; }
public string OfflineModeIsOnMessageTitle { get; set; }
public string OfflineModeIsOnMessageText { get; set; }
public string NoDownloadMirrorError { get; set; }
}

internal class NonFictionSearchResultsGridColumnsTranslation
Expand Down
4 changes: 2 additions & 2 deletions LibgenDesktop/Models/MainModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1140,8 +1140,8 @@ private void ValidateAndCorrectSelectedMirrors()
ValidateAndCorrectSelectedMirror(mirrorSettings.FictionBooksMirrorName, mirror => mirror.FictionDownloadUrl);
mirrorSettings.FictionCoversMirrorName =
ValidateAndCorrectSelectedMirror(mirrorSettings.FictionCoversMirrorName, mirror => mirror.FictionCoverUrl);
mirrorSettings.ArticlesMirrorMirrorName =
ValidateAndCorrectSelectedMirror(mirrorSettings.ArticlesMirrorMirrorName, mirror => mirror.SciMagDownloadUrl);
mirrorSettings.ArticlesMirrorName =
ValidateAndCorrectSelectedMirror(mirrorSettings.ArticlesMirrorName, mirror => mirror.SciMagDownloadUrl);
}

private string ValidateAndCorrectSelectedMirror(string selectedMirrorName, Func<Mirrors.MirrorConfiguration, string> mirrorProperty)
Expand Down
4 changes: 2 additions & 2 deletions LibgenDesktop/Models/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public static MirrorSettings Default
NonFictionSynchronizationMirrorName = DEFAULT_SYNCHRONIZATION_MIRROR_NAME,
FictionBooksMirrorName = DEFAULT_DOWNLOAD_MIRROR_NAME,
FictionCoversMirrorName = DEFAULT_DOWNLOAD_MIRROR_NAME,
ArticlesMirrorMirrorName = DEFAULT_DOWNLOAD_MIRROR_NAME
ArticlesMirrorName = DEFAULT_DOWNLOAD_MIRROR_NAME
};
}
}
Expand All @@ -426,7 +426,7 @@ public static MirrorSettings Default
public string NonFictionSynchronizationMirrorName { get; set; }
public string FictionBooksMirrorName { get; set; }
public string FictionCoversMirrorName { get; set; }
public string ArticlesMirrorMirrorName { get; set; }
public string ArticlesMirrorName { get; set; }
}

internal class SearchSettings
Expand Down
12 changes: 10 additions & 2 deletions LibgenDesktop/Resources/Languages/English.lng
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@
"Interrupting": "INTERRUPTING...",
"AddToBookmarksTooltip": "Add to bookmarks",
"RemoveFromBookmarksTooltip": "Remove from bookmarks",
"ExportButtonTooltip": "Export search results to a file"
"ExportButtonTooltip": "Export search results to a file",
"Details": "Details",
"Open": "Open",
"Download": "Download",
"ErrorMessageTitle": "Error",
"FileNotFoundError": "File {file} not found.",
"OfflineModeIsOnMessageTitle": "Offline mode is on",
"OfflineModeIsOnMessageText": "Downloading is disabled while the offline mode is on. You can turn it off in the settings window.",
"NoDownloadMirrorError": "No download mirror has been selected. Please choose one of the mirrors in the settings window."
},
"NonFictionSearchResultsTab":
{
Expand Down Expand Up @@ -536,7 +544,7 @@
"TotalArticles": "Total articles",
"LastUpdate": "Last update",
"Never": "never",
"CreatingIndexes": "Please wait. Creating missing database indexes...",
"CreatingIndexes": "Please wait. Creating missing database indexes...{new-line}This operation cannot be interrupted.",
"ChangeDatabase": "CHANGE DATABASE...",
"BrowseDatabaseDialogTitle": "Database file location",
"Databases": "Databases",
Expand Down
7 changes: 5 additions & 2 deletions LibgenDesktop/Resources/Languages/French.lng
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@
"Interrupting": "ARRÊT EN COURS...",
"AddToBookmarksTooltip": "Ajouter aux marque-pages",
"RemoveFromBookmarksTooltip": "Supprimer le marque-page",
"ExportButtonTooltip": "Exporter les résultats de la recherche dans un fichier"
"ExportButtonTooltip": "Exporter les résultats de la recherche dans un fichier",
"ErrorMessageTitle": "Erreur",
"FileNotFoundError": "Le fichier {file} est introuvable.",
"OfflineModeIsOnMessageTitle": "Le mode hors connexion est activé"
},
"NonFictionSearchResultsTab":
{
Expand Down Expand Up @@ -529,7 +532,7 @@
"TotalArticles": "Total des articles ",
"LastUpdate": "Dernière mise à jour ",
"Never": "jamais",
"CreatingIndexes": "Veuillez patienter. Création des index de base de données manquants...",
"CreatingIndexes": "Veuillez patienter. Création des index de base de données manquants...{new-line}This operation cannot be interrupted.",
"ChangeDatabase": "CHANGER LA BASE DE DONNÉES...",
"BrowseDatabaseDialogTitle": "Emplacement du fichier de base de données",
"Databases": "Base de données",
Expand Down
7 changes: 5 additions & 2 deletions LibgenDesktop/Resources/Languages/Romanian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@
"Interrupting": "SE ÎNTRERUPE...",
"AddToBookmarksTooltip": "Adaugă la Marcaje",
"RemoveFromBookmarksTooltip": "Șterge din Marcaje",
"ExportButtonTooltip": "Exportă rezultatele căutării într-un fișier"
"ExportButtonTooltip": "Exportă rezultatele căutării într-un fișier",
"ErrorMessageTitle": "Eroare",
"FileNotFoundError": "fișierul {file} nu a fost găsit.",
"OfflineModeIsOnMessageTitle": "Modul Offline este dezactivat"
},
"NonFictionSearchResultsTab":
{
Expand Down Expand Up @@ -535,7 +538,7 @@
"TotalArticles": "Articole disponibile",
"LastUpdate": "Ultima actualizare",
"Never": "niciodată",
"CreatingIndexes": "Vă rugăm așteptați. Se creează indecșii lipsă...",
"CreatingIndexes": "Vă rugăm așteptați. Se creează indecșii lipsă...{new-line}This operation cannot be interrupted.",
"ChangeDatabase": "SCHIMBĂ BAZA DE DATE...",
"BrowseDatabaseDialogTitle": "Locația Bazei e date",
"Databases": "Baza de date",
Expand Down
12 changes: 10 additions & 2 deletions LibgenDesktop/Resources/Languages/Russian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,15 @@
"Interrupting": "ПРЕРЫВАЕТСЯ...",
"AddToBookmarksTooltip": "Добавить в закладки",
"RemoveFromBookmarksTooltip": "Удалить из закладок",
"ExportButtonTooltip": "Экспорт результатов поиска в файл"
"ExportButtonTooltip": "Экспорт результатов поиска в файл",
"Details": "Детальная информация",
"Open": "Открыть",
"Download": "Скачать",
"ErrorMessageTitle": "Ошибка",
"FileNotFoundError": "Файл {file} не найден.",
"OfflineModeIsOnMessageTitle": "Включен автономный режим",
"OfflineModeIsOnMessageText": "Скачивание файлов недоступно в автономном режиме. Вы можете отключить автономный режим в окне настроек.",
"NoDownloadMirrorError": "Не выбрано зеркало для загрузки файлов. Пожалуйста, выберите одно из доступных зеркал в окне настроек."
},
"NonFictionSearchResultsTab":
{
Expand Down Expand Up @@ -536,7 +544,7 @@
"TotalArticles": "Всего статей",
"LastUpdate": "Последнее обновление",
"Never": "никогда",
"CreatingIndexes": "Идет создание отсутствующих индексов.{new-line}Пожалуйста, подождите...",
"CreatingIndexes": "Идет создание отсутствующих индексов.{new-line}Пожалуйста, подождите...{new-line}Эта операция не может быть прервана.",
"ChangeDatabase": "СМЕНИТЬ БАЗУ ДАННЫХ...",
"BrowseDatabaseDialogTitle": "Местоположение файла базы данных",
"Databases": "Базы данных",
Expand Down
7 changes: 5 additions & 2 deletions LibgenDesktop/Resources/Languages/Spanish.lng
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@
"Interrupting": "INTERRUMPIENDO...",
"AddToBookmarksTooltip": "Añadir a los marcadores",
"RemoveFromBookmarksTooltip": "Quitar de los marcadores",
"ExportButtonTooltip": "Exportar la búsqueda a un archivo"
"ExportButtonTooltip": "Exportar la búsqueda a un archivo",
"ErrorMessageTitle": "Error",
"FileNotFoundError": "Archivo {file} no encontrado.",
"OfflineModeIsOnMessageTitle": "El modo sin conexión está activo"
},
"NonFictionSearchResultsTab":
{
Expand Down Expand Up @@ -529,7 +532,7 @@
"TotalArticles": "Total de artículos",
"LastUpdate": "Última actualización",
"Never": "nunca",
"CreatingIndexes": "Por favor, espere. Creando los índices perdidos de la base de datos...",
"CreatingIndexes": "Por favor, espere. Creando los índices perdidos de la base de datos...{new-line}This operation cannot be interrupted.",
"ChangeDatabase": "CAMBIAR LA BASE DE DATOS...",
"BrowseDatabaseDialogTitle": "Localización de la base de datos",
"Databases": "Bases de datos",
Expand Down
7 changes: 5 additions & 2 deletions LibgenDesktop/Resources/Languages/Ukrainian.lng
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@
"SearchInProgress": "Триває пошук...",
"Interrupt": "ПЕРЕРВАТИ",
"Interrupting": "ПЕРЕРИВАЄТЬСЯ...",
"ExportButtonTooltip": "Експорт результатів пошуку в файл"
"ExportButtonTooltip": "Експорт результатів пошуку в файл",
"ErrorMessageTitle": "Помилка",
"FileNotFoundError": "Файл {file} не знайдено.",
"OfflineModeIsOnMessageTitle": "Увімкнено автономний режим"
},
"NonFictionSearchResultsTab":
{
Expand Down Expand Up @@ -505,7 +508,7 @@
"TotalArticles": "Усього статей",
"LastUpdate": "Останнє оновлення",
"Never": "ніколи",
"CreatingIndexes": "Триває створення невистачаючих індексів.{new-line}Будь ласка, зачекайте...",
"CreatingIndexes": "Триває створення невистачаючих індексів.{new-line}Будь ласка, зачекайте...{new-line}This operation cannot be interrupted.",
"ChangeDatabase": "ЗМІНИТИ БАЗУ ДАНИХ...",
"BrowseDatabaseDialogTitle": "Місцезнаходження файлу бази даних",
"Databases": "Бази даних",
Expand Down
3 changes: 0 additions & 3 deletions LibgenDesktop/ViewModels/Tabs/FictionDetailsTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@ public FictionDetailsItemViewModel DetailsItem
}

protected override string FileNameWithoutExtension => $"{DetailsItem.Authors} - {DetailsItem.Title}";

protected override string FileExtension => DetailsItem.Format;

protected override string Md5Hash => DetailsItem.Md5Hash;

protected override bool HasCover => DetailsItem.Book.Cover == "1";

protected override string GenerateDownloadUrl(Mirrors.MirrorConfiguration mirrorConfiguration)
Expand Down
Loading

0 comments on commit fdabef4

Please sign in to comment.