Skip to content

Commit

Permalink
Fix popup dispose error. Add ability to do JPG 50/80%. Add a lovely i…
Browse files Browse the repository at this point in the history
…con.
  • Loading branch information
wappenull committed Apr 13, 2021
1 parent bdd6041 commit e3f0482
Show file tree
Hide file tree
Showing 13 changed files with 1,001 additions and 323 deletions.
10 changes: 9 additions & 1 deletion DLSiteDumperCS/DLSiteDumperCS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -24,7 +25,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand All @@ -47,6 +47,9 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>dldump_icon_kr9_icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down Expand Up @@ -99,6 +102,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
Expand Down Expand Up @@ -135,5 +139,9 @@
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<Content Include="dldump_icon_kr9_icon.ico" />
<None Include="Resources\dldump_icon.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
43 changes: 28 additions & 15 deletions DLSiteDumperCS/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 37 additions & 13 deletions DLSiteDumperCS/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ namespace DLSiteDumperCS
{
public partial class MainForm : Form
{
const string DefaultExt = "jpg";

ViewerDumper m_Vd;
string m_UsingImageExt;

OutputFormat UsingOutputImageFormat => (OutputFormat)imageExtSelect.SelectedIndex;

string UsingImageExt => Helper.GetOutputExt( UsingOutputImageFormat );

public MainForm( )
{
Expand All @@ -29,13 +30,14 @@ public MainForm( )

private void Form1_Load( object sender, EventArgs e )
{
this.Text += $"| V {Application.ProductVersion}";

// Auto detect PID on load
int foundPid = _AutoDetectProcess( );
pidTextBox.Text = foundPid.ToString( );

// Select PNG on start
imageExtSelect.SelectedIndex = imageExtSelect.FindString( DefaultExt );
m_UsingImageExt = DefaultExt;
// Select default ext on start
imageExtSelect.SelectedIndex = (int)OutputFormat.Jpeg50;

// Auto pick some save path
string initialSave = Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments );
Expand Down Expand Up @@ -97,12 +99,12 @@ void Dump( bool isBatch )

// Resetup if PID changed
if( m_Vd.TargetPid != pid )
m_Vd.Setup( pid );
m_Vd.SetupTargetPid( pid );

m_Vd.BasePageOffset = (int)startPageInput.Value;
m_Vd.BaseSavePath = savePathTextBox.Text;
m_Vd.TargetImageExt = m_UsingImageExt;
m_Vd.BetweenPageDelayMs = (int)betweenPageDelay.Value;
m_Vd.SetupOutputEncoder( UsingOutputImageFormat );

if( !m_Vd.IsReady )
{
Expand Down Expand Up @@ -156,12 +158,12 @@ private void autoDetectPidButton_Click( object sender, EventArgs e )

private void browseButton_Click( object sender, EventArgs e )
{
string forecastFilename = ViewerDumper.GetFileNameForPage( (int)startPageInput.Value, m_UsingImageExt );
string forecastFilename = ViewerDumper.GetFileNameForPage( (int)startPageInput.Value, UsingImageExt );

var sfd = new SaveFileDialog( );
sfd.InitialDirectory = savePathTextBox.Text;
sfd.FileName = forecastFilename;
sfd.DefaultExt = m_UsingImageExt;
sfd.DefaultExt = UsingImageExt;
sfd.Filter = "Image file|*.*";
sfd.ValidateNames = false;
sfd.CheckFileExists = false;
Expand All @@ -182,7 +184,6 @@ private void savePathTextBox_TextChanged( object sender, EventArgs e )

private void imageExtSelect_SelectedIndexChanged( object sender, EventArgs e )
{
m_UsingImageExt = imageExtSelect.Text;
_UpdateEffectivePath( );
}

Expand All @@ -193,7 +194,7 @@ private void startPageInput_ValueChanged( object sender, EventArgs e )

private void _UpdateEffectivePath( )
{
effectivePathTextBox.Text = Path.Combine( savePathTextBox.Text, ViewerDumper.GetFileNameForPage( (int)startPageInput.Value, m_UsingImageExt ) );
effectivePathTextBox.Text = Path.Combine( savePathTextBox.Text, ViewerDumper.GetFileNameForPage( (int)startPageInput.Value, UsingImageExt ) );
}

private void OpenUrlFromLinkLabel( object sender, LinkLabelLinkClickedEventArgs e )
Expand Down Expand Up @@ -267,7 +268,8 @@ private void BackgroundWorker1_ProgressChanged( object sender, ProgressChangedEv

private void BackgroundWorker1_RunWorkerCompleted( object sender, RunWorkerCompletedEventArgs e )
{
m_Popup.Close( );
m_Popup.Close( ); // Note: this will dispose, so also set null, credit to ntsa (https://forums.e-hentai.org/index.php?showuser=189943) for this finding
m_Popup = null;

if( e.Cancelled )
InfoMsg( "User cancelled operation. Are you joking to me?" );
Expand Down Expand Up @@ -326,4 +328,26 @@ private void genHtmlButton_Click( object sender, EventArgs e )

}

// Choice order in imageExtSelect must be by this
enum OutputFormat
{
Jpeg80,
Jpeg50,
Png
}

static class Helper
{
public static string GetOutputExt( OutputFormat f )
{
switch( f )
{
case OutputFormat.Jpeg80: // JPG 80%
case OutputFormat.Jpeg50: // JPG 50%
return "jpg";
default:
return "png";
}
}
}
}
Loading

0 comments on commit e3f0482

Please sign in to comment.