forked from TASEmulators/BizHawk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainDiscoForm.cs
144 lines (130 loc) · 3.65 KB
/
MainDiscoForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Threading;
using BizHawk.Common;
using BizHawk.Common.StringExtensions;
using BizHawk.Emulation.DiscSystem;
namespace BizHawk.Client.DiscoHawk
{
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()
{
InitializeComponent();
}
private void MainDiscoForm_Load(object sender, EventArgs e)
{
lvCompareTargets.Columns[0].Width = lvCompareTargets.ClientSize.Width;
}
private void ExitButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e)
{
List<string> files = validateDrop(e.Data);
if (files.Count == 0) return;
try
{
this.Cursor = Cursors.WaitCursor;
foreach (var file in files)
{
var job = new DiscMountJob { IN_FromPath = file };
job.Run();
var disc = job.OUT_Disc;
if (job.OUT_ErrorLevel)
{
System.Windows.Forms.MessageBox.Show(job.OUT_Log, "Error loading disc");
break;
}
string baseName = Path.GetFileNameWithoutExtension(file);
baseName += "_hawked";
string outfile = Path.Combine(Path.GetDirectoryName(file), baseName) + ".ccd";
CCD_Format.Dump(disc, outfile);
}
this.Cursor = Cursors.Default;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error loading disc");
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)
{
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)
{
string ext = Path.GetExtension(str).ToUpper();
if(!ext.In(new string[]{".CUE",".ISO",".CCD", ".MDS"}))
{
return new List<string>();
}
ret.Add(str);
}
return ret;
}
private void lblMp3ExtractMagicArea_DragDrop(object sender, DragEventArgs e)
{
var files = validateDrop(e.Data);
if (files.Count == 0) return;
foreach (var file in files)
{
using (var disc = Disc.LoadAutomagic(file))
{
var path = Path.GetDirectoryName(file);
var filename = Path.GetFileNameWithoutExtension(file);
AudioExtractor.Extract(disc, path, filename);
}
}
}
private void btnAbout_Click(object sender, EventArgs e)
{
new About().ShowDialog();
}
}
}