private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { if (m_Vd != null) { m_Vd.Dispose( ); m_Vd = null; } }
void Dump(bool isBatch) { if (m_Vd == null) { m_Vd = new ViewerDumper(this); } if (!int.TryParse(pidTextBox.Text, out int pid) || pid == 0) { ErrorMsg("Hey, type in valid value into PID box, seriously!"); return; } _UpdateEffectivePath( ); // Check if file already exists if (File.Exists(effectivePathTextBox.Text)) { InfoMsg($"Looks like there is file exists at\n{effectivePathTextBox.Text}\nPlease resolve this manually, for safety reason (loss of data), program will not continue."); return; } // Try create directory once if (!Directory.Exists(savePathTextBox.Text)) { Directory.CreateDirectory(savePathTextBox.Text); } if (!Directory.Exists(savePathTextBox.Text)) { ErrorMsg($"Save path \n{savePathTextBox.Text}\nis invalid"); return; } // Resetup if PID changed if (m_Vd.TargetPid != pid) { m_Vd.SetupTargetPid(pid); } m_Vd.BasePageOffset = (int)startPageInput.Value; m_Vd.BaseSavePath = savePathTextBox.Text; m_Vd.BetweenPageDelayMs = (int)betweenPageDelay.Value; m_Vd.SetupOutputEncoder(UsingOutputImageFormat); if (!m_Vd.IsReady) { ErrorMsg($"Cannot open DLSiteViewer process ID {pid}"); return; } if (m_Popup == null) { m_Popup = new WorkingDialog(this); } backgroundWorker1.RunWorkerAsync(isBatch); m_Popup.ShowDialog(this); // ShowDialog is blocking call }
private void browseButton_Click(object sender, EventArgs e) { string forecastFilename = ViewerDumper.GetFileNameForPage((int)startPageInput.Value, UsingImageExt); var sfd = new SaveFileDialog( ); sfd.InitialDirectory = savePathTextBox.Text; sfd.FileName = forecastFilename; sfd.DefaultExt = UsingImageExt; sfd.Filter = "Image file|*.*"; sfd.ValidateNames = false; sfd.CheckFileExists = false; sfd.CheckPathExists = true; sfd.RestoreDirectory = true; if (sfd.ShowDialog( ) == DialogResult.OK) { savePathTextBox.Text = Path.GetDirectoryName(sfd.FileName); _UpdateEffectivePath( ); } }
private void _UpdateEffectivePath( ) { effectivePathTextBox.Text = Path.Combine(savePathTextBox.Text, ViewerDumper.GetFileNameForPage((int)startPageInput.Value, UsingImageExt)); }