Discohawk - use new main form, currently just does the simple magic dropping with default settings.

This commit is contained in:
andres.delikat 2011-09-01 01:24:26 +00:00
parent 9f4ffde86f
commit 4fde4116d6
3 changed files with 85 additions and 1 deletions

View File

@ -41,7 +41,7 @@ namespace BizHawk
if (gui) if (gui)
{ {
var dialog = new DiscoHawkDialog(); var dialog = new MainDiscoForm();
dialog.ShowDialog(); dialog.ShowDialog();
return; return;
} }

View File

@ -48,6 +48,8 @@
// //
// lblMagicDragArea // lblMagicDragArea
// //
this.lblMagicDragArea.AllowDrop = true;
this.lblMagicDragArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblMagicDragArea.Controls.Add(this.label1); this.lblMagicDragArea.Controls.Add(this.label1);
this.lblMagicDragArea.Location = new System.Drawing.Point(84, 12); this.lblMagicDragArea.Location = new System.Drawing.Point(84, 12);
this.lblMagicDragArea.Name = "lblMagicDragArea"; this.lblMagicDragArea.Name = "lblMagicDragArea";

View File

@ -6,12 +6,21 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO;
using System.Threading;
using BizHawk.DiscSystem; using BizHawk.DiscSystem;
namespace BizHawk namespace BizHawk
{ {
public partial class MainDiscoForm : Form public partial class MainDiscoForm : Form
{ {
//Release TODO:
//An input (queue) list
//An outputted list showing new file name
//Progress bar should show file being converted
//Add disc button, which puts it on the progress cue (converts it)
public MainDiscoForm() public MainDiscoForm()
{ {
InitializeComponent(); InitializeComponent();
@ -33,14 +42,87 @@ namespace BizHawk
this.Close(); this.Close();
} }
CueBinPrefs GetCuePrefs()
{
var prefs = new DiscSystem.CueBinPrefs();
prefs.AnnotateCue = true; // TODO? checkCueProp_Annotations.Checked;
prefs.OneBlobPerTrack = false; //TODO? checkCueProp_OneBlobPerTrack.Checked;
prefs.ReallyDumpBin = false;
prefs.SingleSession = true;
return prefs;
}
private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e) private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e)
{ {
List<string> files = validateDrop(e.Data);
if (files.Count == 0) return;
try
{
foreach (var file in files)
{
Disc disc = Disc.FromCuePath(file);
string baseName = Path.GetFileNameWithoutExtension(file);
baseName += "_hawked";
var prefs = GetCuePrefs();
prefs.ReallyDumpBin = true;
var cueBin = disc.DumpCueBin(baseName, GetCuePrefs());
Dump(cueBin, Path.GetDirectoryName(file), prefs);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "oops! error");
throw;
}
}
bool Dump(CueBin cueBin, string directoryTo, CueBinPrefs prefs)
{
ProgressReport pr = new ProgressReport();
Thread workThread = new Thread(() =>
{
cueBin.Dump(directoryTo, prefs, pr);
});
ProgressDialog pd = new ProgressDialog(pr);
pd.Show(this);
this.Enabled = false;
workThread.Start();
for (; ; )
{
Application.DoEvents();
Thread.Sleep(10);
if (workThread.ThreadState != ThreadState.Running)
break;
pd.Update();
}
this.Enabled = true;
pd.Dispose();
return !pr.CancelSignal;
} }
private void lblMagicDragArea_DragEnter(object sender, DragEventArgs e) private void lblMagicDragArea_DragEnter(object sender, DragEventArgs e)
{ {
List<string> files = validateDrop(e.Data);
if (files.Count > 0)
e.Effect = DragDropEffects.Link;
else e.Effect = DragDropEffects.None;
}
List<string> validateDrop(IDataObject ido)
{
List<string> ret = new List<string>();
string[] files = (string[])ido.GetData(System.Windows.Forms.DataFormats.FileDrop);
if (files == null) return new List<string>();
foreach (string str in files)
{
if (Path.GetExtension(str).ToUpper() != ".CUE")
{
return new List<string>();
}
ret.Add(str);
}
return ret;
} }
} }
} }