Skip to content

Commit

Permalink
Rework original 200 lines CPP into over-engineered C# project 1000+ l…
Browse files Browse the repository at this point in the history
…ines OMEGALULZ
  • Loading branch information
wappenull committed Mar 24, 2021
1 parent 484d548 commit e3985bc
Show file tree
Hide file tree
Showing 34 changed files with 4,324 additions and 524 deletions.
37 changes: 37 additions & 0 deletions DLSiteDumperCS.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DLSiteDumperCS", "DLSiteDumperCS\DLSiteDumperCS.csproj", "{833A0652-30AE-4036-8F2D-FA1CE33C32D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Debug|x64.ActiveCfg = Debug|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Debug|x64.Build.0 = Debug|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Debug|x86.ActiveCfg = Debug|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Debug|x86.Build.0 = Debug|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Release|Any CPU.Build.0 = Release|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Release|x64.ActiveCfg = Release|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Release|x64.Build.0 = Release|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Release|x86.ActiveCfg = Release|Any CPU
{833A0652-30AE-4036-8F2D-FA1CE33C32D9}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5B0D083E-842D-43DD-BDB0-A295223D2752}
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions DLSiteDumperCS/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
112 changes: 112 additions & 0 deletions DLSiteDumperCS/DLSiteDumperCS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{833A0652-30AE-4036-8F2D-FA1CE33C32D9}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>DLSiteDumperCS</RootNamespace>
<AssemblyName>DLSiteDumperCS</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExplorerLikeFilenameComparer.cs" />
<Compile Include="HtmlImageReaderGenerator.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Gdi32.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="User32.cs" />
<Compile Include="Kernel32.cs" />
<Compile Include="ViewerDumper.cs" />
<Compile Include="Win32StatusBar.cs" />
<Compile Include="WndSearcher.cs" />
<Compile Include="WorkingDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="WorkingDialog.Designer.cs">
<DependentUpon>WorkingDialog.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Include="Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="WorkingDialog.resx">
<DependentUpon>WorkingDialog.cs</DependentUpon>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\HtmlTemplate.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
16 changes: 16 additions & 0 deletions DLSiteDumperCS/ExplorerLikeFilenameComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
/// <summary>
/// Enable to compare filename like a boss.
/// </summary>
public class ExplorerLikeFilenameComparer : IComparer<string>
{
[DllImport( "shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true )]
static extern int StrCmpLogicalW( string x, string y );

public int Compare( string x, string y )
{
return StrCmpLogicalW( x, y );
}

}
42 changes: 42 additions & 0 deletions DLSiteDumperCS/Gdi32.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System.Runtime.InteropServices;

public static class Gdi32
{
public enum BitmapCompressionMode : uint
{
BI_RGB = 0,
BI_RLE8 = 1,
BI_RLE4 = 2,
BI_BITFIELDS = 3,
BI_JPEG = 4,
BI_PNG = 5
}

[StructLayout( LayoutKind.Sequential )]
public struct BITMAPINFOHEADER
{
public uint biSize;
public int biWidth;
public int biHeight;
public ushort biPlanes;
public ushort biBitCount;
public BitmapCompressionMode biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public uint biClrImportant;
}

[StructLayout( LayoutKind.Sequential, Pack = 2 )]
public struct BITMAPFILEHEADER
{
public ushort bfType;
public uint bfSize;
public ushort bfReserved1;
public ushort bfReserved2;
public uint bfOffBits;
}


}
64 changes: 64 additions & 0 deletions DLSiteDumperCS/HtmlImageReaderGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Diagnostics;
using System.Text;
using System.IO;

class HtmlImageReaderGenerator
{
public string[] FileList;
public bool IsRightToLeft;
public string OutputPath;
public int ImageZoomPercent;

/// <summary>
/// It expects 3 string to replace
/// /*READ_DIRECTION_FLAG*/
/// /*IMAGE_WIDTH*/
/// /*CONTENT*/
/// </summary>
public string TemplateData;

StringBuilder sb;
StringBuilder contentSb;

public bool Generate( )
{
if( sb == null )
sb = new StringBuilder( );
sb.Clear( );
sb.Append( TemplateData );

string readDirStyle;
if( IsRightToLeft )
readDirStyle = "direction: rtl"; // This is going into CSS part
else
readDirStyle = "";
sb.Replace( "/*READ_DIRECTION_FLAG*/", readDirStyle );

string imageWidth = "width: 50%";
if( ImageZoomPercent > 0 && ImageZoomPercent <= 100 ) // Must be in valid range
imageWidth = $"width: {ImageZoomPercent}%";
sb.Replace( "/*IMAGE_WIDTH*/", imageWidth );

// For all contents
if( contentSb == null )
contentSb = new StringBuilder( );
contentSb.Clear( );
foreach( string line in FileList )
{
contentSb.AppendLine( $"<img src=\"{line}\">" );
}
sb.Replace( "/*CONTENT*/", contentSb.ToString( ) );

try
{
File.WriteAllText( OutputPath, sb.ToString( ) );
}
catch( Exception e )
{
Debug.Print( e.ToString( ) );
return false;
}
return true;
}
}
Loading

0 comments on commit e3985bc

Please sign in to comment.