Skip to content

Commit

Permalink
1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
libgenapps committed May 10, 2020
1 parent efc1d63 commit 2dc8bd9
Show file tree
Hide file tree
Showing 311 changed files with 12,245 additions and 4,519 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[*.cs]

# CA1810: Initialize reference type static fields inline
dotnet_diagnostic.CA1810.severity = none

# CA1031: Do not catch general exception types
dotnet_diagnostic.CA1031.severity = none

# IDE0039: Use local function
csharp_style_pattern_local_over_anonymous_function = true:none

# CA2100: Review SQL queries for security vulnerabilities
dotnet_diagnostic.CA2100.severity = none

# IDE0049: Simplify Names
dotnet_style_predefined_type_for_locals_parameters_members = false:silent
3 changes: 3 additions & 0 deletions LibgenDesktop.Setup/AppFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ static AppFiles()
X64.Add(new AppFile(@"x64\SQLite.Interop.dll", "SQLite.Interop.dll"));
AddFile(@"Languages\English.lng");
AddFile(@"Languages\French.lng");
AddFile(@"Languages\Italian.lng");
AddFile(@"Languages\Portuguse_BR.lng");
AddFile(@"Languages\Romanian.lng");
AddFile(@"Languages\Russian.lng");
AddFile(@"Languages\Simplified Chinese.lng");
Expand All @@ -39,6 +41,7 @@ static AppFiles()
AddFile(@"Mirrors\booklid_org_step2.xslt");
AddFile(@"Mirrors\booksc_org_step1.xslt");
AddFile(@"Mirrors\booksc_org_step2.xslt");
AddFile(@"Mirrors\genlibrusec_dbdumps.xslt");
AddFile(@"Mirrors\libgen_lc_fiction.xslt");
AddFile(@"Mirrors\libgen_lc_nonfiction.xslt");
AddFile(@"Mirrors\libgen_lc_scimag.xslt");
Expand Down
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.3.5";
public const string TITLE_VERSION = "1.3.5";
public const string CURRENT_VERSION = "1.4.0";
public const string TITLE_VERSION = "1.4.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
29 changes: 15 additions & 14 deletions LibgenDesktop.Setup/LibgenDesktop.Setup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<AssemblyName>WixSharp Setup</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp></NuGetPackageImportStamp>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug x86|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -43,10 +44,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="BootstrapperCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.9.2\lib\BootstrapperCore.dll</HintPath>
<HintPath>..\packages\WixSharp.bin.1.14.3\lib\BootstrapperCore.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Deployment.WindowsInstaller, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.9.2\lib\Microsoft.Deployment.WindowsInstaller.dll</HintPath>
<HintPath>..\packages\WixSharp.bin.1.14.3\lib\Microsoft.Deployment.WindowsInstaller.dll</HintPath>
</Reference>
<Reference Include="SharpCompress, Version=0.22.0.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.22.0\lib\net35\SharpCompress.dll</HintPath>
Expand All @@ -57,14 +58,14 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WixSharp, Version=1.9.2.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.9.2\lib\WixSharp.dll</HintPath>
<Reference Include="WixSharp, Version=1.14.3.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.14.3\lib\WixSharp.dll</HintPath>
</Reference>
<Reference Include="WixSharp.Msi, Version=1.9.2.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.9.2\lib\WixSharp.Msi.dll</HintPath>
<Reference Include="WixSharp.Msi, Version=1.14.3.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.14.3\lib\WixSharp.Msi.dll</HintPath>
</Reference>
<Reference Include="WixSharp.UI, Version=1.9.2.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.9.2\lib\WixSharp.UI.dll</HintPath>
<Reference Include="WixSharp.UI, Version=1.14.3.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.14.3\lib\WixSharp.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -92,14 +93,14 @@
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\packages\WixSharp.bin.1.9.2\build\WixSharp.bin.targets" Condition="Exists('..\packages\WixSharp.bin.1.9.2\build\WixSharp.bin.targets')" />
<UsingTask AssemblyFile="$(SolutionDir)packages\WixSharp.1.9.2\build\SetEnvVar.dll" TaskName="SetEnvVar" />
<Import Project="..\packages\WixSharp.bin.1.14.3\build\WixSharp.bin.targets" Condition="Exists('..\packages\WixSharp.bin.1.14.3\build\WixSharp.bin.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\WixSharp.bin.1.9.2\build\WixSharp.bin.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WixSharp.bin.1.9.2\build\WixSharp.bin.targets'))" />
<Error Condition="!Exists('..\packages\WixSharp.1.9.2\build\WixSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WixSharp.1.9.2\build\WixSharp.targets'))" />
<Error Condition="!Exists('..\packages\WixSharp.bin.1.14.3\build\WixSharp.bin.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WixSharp.bin.1.14.3\build\WixSharp.bin.targets'))" />
<Error Condition="!Exists('..\packages\WixSharp.1.14.3\build\WixSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WixSharp.1.14.3\build\WixSharp.targets'))" />
</Target>
<Import Project="..\packages\WixSharp.1.9.2\build\WixSharp.targets" Condition="Exists('..\packages\WixSharp.1.9.2\build\WixSharp.targets')" />
<UsingTask AssemblyFile="$(SolutionDir)packages\WixSharp.1.9.2\build\SetEnvVar.dll" TaskName="SetEnvVar" />
<Import Project="..\packages\WixSharp.1.14.3\build\WixSharp.targets" Condition="Exists('..\packages\WixSharp.1.14.3\build\WixSharp.targets')" />
</Project>
3 changes: 1 addition & 2 deletions LibgenDesktop.Setup/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.IO;
using System.IO;

namespace LibgenDesktop.Setup
{
Expand Down
4 changes: 2 additions & 2 deletions LibgenDesktop.Setup/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpCompress" version="0.22.0" targetFramework="net35" />
<package id="WixSharp" version="1.9.2" targetFramework="net35" />
<package id="WixSharp.bin" version="1.9.2" targetFramework="net35" />
<package id="WixSharp" version="1.14.3" targetFramework="net35" />
<package id="WixSharp.bin" version="1.14.3" targetFramework="net35" />
</packages>
9 changes: 7 additions & 2 deletions LibgenDesktop.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
# Visual Studio Version 16
VisualStudioVersion = 16.0.29911.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibgenDesktop", "LibgenDesktop\LibgenDesktop.csproj", "{7158E1EB-44F7-4C26-BF9A-DA055F85D0BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibgenDesktop.Setup", "LibgenDesktop.Setup\LibgenDesktop.Setup.csproj", "{44555887-C439-470C-944D-8866EC3D7067}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DD4F677-B56F-4422-90B9-4A8A1CC6D69B}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug x64|Any CPU = Debug x64|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions LibgenDesktop/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<AppContextSwitchOverrides value="Switch.System.Windows.DoNotScaleForDpiChanges=false" />
</runtime>
</configuration>
6 changes: 3 additions & 3 deletions LibgenDesktop/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Red.xaml" />
<ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/materialdesign.xaml" />
<ResourceDictionary Source="Views\Styles\CommonStyles.xaml" />
<ResourceDictionary Source="Views\Styles\TabControlStyles.xaml" />
<ResourceDictionary Source="Views\Styles\WindowStyles.xaml" />
<ResourceDictionary Source="Styles\Common.xaml" />
<ResourceDictionary Source="Styles\Controls\Tab.xaml" />
<ResourceDictionary Source="Styles\Windows\Windows.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Expand Down
103 changes: 94 additions & 9 deletions LibgenDesktop/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using LibgenDesktop.Common;
Expand All @@ -10,22 +11,106 @@ namespace LibgenDesktop
{
public partial class App : Application
{
private enum DatabaseOpenResult
{
IN_PROGRESS = 1,
DATABASE_OPENED,
SHOW_SETUP_WIZARD,
EXIT_REQUESTED
}

private MainModel mainModel;

protected override void OnStartup(StartupEventArgs e)
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
SetupExceptionHandlers();
try
{
mainModel = new MainModel();
if (mainModel.LocalDatabaseStatus == MainModel.DatabaseStatus.OPENED)
string databaseFilePath = mainModel.AppSettings.DatabaseFileName;
bool saveDatabaseFilePathAfterSuccessfulOpen = false;
MainModel.OpenDatabaseOptions openDatabaseOptions = MainModel.OpenDatabaseOptions.NONE;
DatabaseOpenResult databaseOpenResult = DatabaseOpenResult.IN_PROGRESS;
while (databaseOpenResult == DatabaseOpenResult.IN_PROGRESS)
{
ShowMainWindow(mainModel);
MainModel.DatabaseStatus databaseStatus = await mainModel.OpenDatabase(databaseFilePath, openDatabaseOptions);
if (databaseStatus == MainModel.DatabaseStatus.OPENED)
{
databaseOpenResult = DatabaseOpenResult.DATABASE_OPENED;
if (saveDatabaseFilePathAfterSuccessfulOpen)
{
mainModel.AppSettings.DatabaseFileName = MainModel.GetDatabaseNormalizedPath(databaseFilePath);
mainModel.SaveSettings();
}
}
else if (databaseStatus == MainModel.DatabaseStatus.NOT_SET)
{
databaseOpenResult = DatabaseOpenResult.SHOW_SETUP_WIZARD;
}
else
{
DatabaseErrorWindowViewModel.OptionSet optionSet;
switch (databaseStatus)
{
case MainModel.DatabaseStatus.NOT_FOUND:
optionSet = DatabaseErrorWindowViewModel.OptionSet.DATABASE_NOT_FOUND;
break;
case MainModel.DatabaseStatus.POSSIBLE_DUMP_FILE:
optionSet = DatabaseErrorWindowViewModel.OptionSet.DATABASE_DUMP_FILE;
break;
case MainModel.DatabaseStatus.OLD_FICTION_SCHEMA:
optionSet = DatabaseErrorWindowViewModel.OptionSet.OLD_FICTION_SCHEMA;
break;
case MainModel.DatabaseStatus.CORRUPTED:
optionSet = DatabaseErrorWindowViewModel.OptionSet.DATABASE_NOT_VALID;
break;
case MainModel.DatabaseStatus.SERVER_DATABASE:
optionSet = DatabaseErrorWindowViewModel.OptionSet.SERVER_DATABASE;
break;
default:
throw new Exception($"Unknown database status: {databaseStatus}.");
}
DatabaseErrorWindowViewModel databaseErrorWindowViewModel = new DatabaseErrorWindowViewModel(mainModel, optionSet, databaseFilePath);
IWindowContext windowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.DATABASE_ERROR_WINDOW,
databaseErrorWindowViewModel);
windowContext.ShowDialog();
switch (databaseErrorWindowViewModel.Result)
{
case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.OPEN_ANOTHER_DATABASE:
OpenFileDialogResult selectDatabaseFileDialogResult = DatabaseWindowViewModel.SelectDatabaseFile(mainModel);
if (selectDatabaseFileDialogResult.DialogResult)
{
databaseFilePath = selectDatabaseFileDialogResult.SelectedFilePaths.First();
saveDatabaseFilePathAfterSuccessfulOpen = true;
}
break;
case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.START_SETUP_WIZARD:
databaseOpenResult = DatabaseOpenResult.SHOW_SETUP_WIZARD;
break;
case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.DELETE_FICTION:
openDatabaseOptions = MainModel.OpenDatabaseOptions.MIGRATE_FICTION;
break;
case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.EXIT:
case DatabaseErrorWindowViewModel.DatabaseErrorWindowResult.CANCEL:
databaseOpenResult = DatabaseOpenResult.EXIT_REQUESTED;
break;
default:
throw new Exception($"Unknown database error view model result: {databaseErrorWindowViewModel.Result}.");
}
}
}
else
switch (databaseOpenResult)
{
ShowCreateDatabaseWindow(mainModel);
case DatabaseOpenResult.DATABASE_OPENED:
ShowMainWindow(mainModel);
break;
case DatabaseOpenResult.SHOW_SETUP_WIZARD:
ShowSetupWizardWindow(mainModel);
break;
default:
Close();
break;
}
}
catch (Exception exception)
Expand All @@ -44,10 +129,10 @@ private void ShowMainWindow(MainModel mainModel)
windowContext.Show();
}

private void ShowCreateDatabaseWindow(MainModel mainModel)
private void ShowSetupWizardWindow(MainModel mainModel)
{
CreateDatabaseWindowViewModel createDatabaseWindowViewModel = new CreateDatabaseWindowViewModel(mainModel);
IWindowContext windowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.CREATE_DATABASE_WINDOW, createDatabaseWindowViewModel);
SetupWizardWindowViewModel setupWizardWindowViewModel = new SetupWizardWindowViewModel(mainModel);
IWindowContext windowContext = WindowManager.CreateWindow(RegisteredWindows.WindowKey.SETUP_WIZARD_WINDOW, setupWizardWindowViewModel);
bool? result = windowContext.ShowDialog();
if (result == true)
{
Expand Down Expand Up @@ -101,7 +186,7 @@ private void Close()
{
if (mainModel != null)
{
mainModel.Downloader.Shutdown();
mainModel.DownloadManager.Shutdown();
mainModel.Dispose();
}
Shutdown();
Expand Down
Loading

0 comments on commit 2dc8bd9

Please sign in to comment.