OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmMain.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.ComponentModel;\r
4 using System.Data;\r
5 using System.Drawing;\r
6 using System.Text;\r
7 using System.Windows.Forms;\r
8 using System.Net;\r
9 using System.IO;\r
10 using System.Diagnostics;\r
11 \r
12 namespace Handbrake\r
13 {\r
14     public partial class frmMain : Form\r
15     {\r
16         public frmMain()\r
17         {\r
18             InitializeComponent();\r
19         }\r
20 \r
21         // --------------------------------------------------------------\r
22         // onLoad - setup the program ready for use.\r
23         // --------------------------------------------------------------\r
24         private void frmMain_Load(object sender, EventArgs e)\r
25         {\r
26             // Set the Version number lable to the corect version.\r
27             Version.Text = "Version " + Properties.Settings.Default.GuiVersion;\r
28 \r
29             // Run the update checker.\r
30             updateCheck();\r
31 \r
32             // Now load the users default if required.\r
33             loadUserDefaults();\r
34             \r
35         }\r
36 \r
37         public void loadUserDefaults()\r
38         { \r
39             try\r
40             {\r
41                 if (Properties.Settings.Default.defaultSettings == "Checked")\r
42                 {\r
43                     //Source\r
44                     text_source.Text = Properties.Settings.Default.DVDSource;\r
45                     drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;\r
46                     drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;\r
47                     drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;\r
48                     //Destination\r
49                     text_destination.Text = Properties.Settings.Default.VideoDest;\r
50                     drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;\r
51                     drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;\r
52                     text_width.Text = Properties.Settings.Default.Width;\r
53                     text_height.Text = Properties.Settings.Default.Height;\r
54                     //Picture Settings Tab\r
55                     drp_crop.Text = Properties.Settings.Default.CroppingOption;\r
56                     text_top.Text = Properties.Settings.Default.CropTop;\r
57                     text_bottom.Text = Properties.Settings.Default.CropBottom;\r
58                     text_left.Text = Properties.Settings.Default.CropLeft;\r
59                     text_right.Text = Properties.Settings.Default.CropRight;\r
60                     drp_subtitle.Text = Properties.Settings.Default.Subtitles;\r
61                     //Video Settings Tab\r
62                     text_bitrate.Text = Properties.Settings.Default.VideoBitrate;\r
63                     text_filesize.Text = Properties.Settings.Default.VideoFilesize;\r
64                     slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;\r
65                     if (Properties.Settings.Default.TwoPass == "Checked")\r
66                     {\r
67                         check_2PassEncode.CheckState = CheckState.Checked;\r
68                     }\r
69                     if (Properties.Settings.Default.DeInterlace == "Checked")\r
70                     {\r
71                         check_DeInterlace.CheckState = CheckState.Checked;\r
72                     }\r
73                     if (Properties.Settings.Default.Grayscale == "Checked")\r
74                     {\r
75                         check_grayscale.CheckState = CheckState.Checked;\r
76                     }\r
77 \r
78                     drp_videoFramerate.Text = Properties.Settings.Default.Framerate;\r
79 \r
80                     if (Properties.Settings.Default.PixelRatio == "Checked")\r
81                     {\r
82                         CheckPixelRatio.CheckState = CheckState.Checked;\r
83                     }\r
84                     if (Properties.Settings.Default.turboFirstPass == "Checked")\r
85                     {\r
86                         check_turbo.CheckState = CheckState.Checked;\r
87                     }\r
88                     if (Properties.Settings.Default.largeFile == "Checked")\r
89                     {\r
90                         check_largeFile.CheckState = CheckState.Checked;\r
91                     }\r
92                     //Audio Settings Tab\r
93                     drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;\r
94                     drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;\r
95                     drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;\r
96                     //H264 Tab\r
97                     if (Properties.Settings.Default.CRF == "Checked")\r
98                     {\r
99                         CheckCRF.CheckState = CheckState.Checked;\r
100                     }\r
101                     rtf_h264advanced.Text = Properties.Settings.Default.H264;\r
102                 }\r
103             }\r
104             catch (Exception)\r
105             {\r
106                 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.\r
107             }\r
108         }\r
109 \r
110         public void updateCheck()\r
111         {\r
112             if (Properties.Settings.Default.updateStatus == "Checked")\r
113             {\r
114 \r
115                 try\r
116                 {\r
117                     String updateFile = Properties.Settings.Default.updateFile;\r
118                     WebClient client = new WebClient();\r
119                     String data = client.DownloadString(updateFile);\r
120                     String[] versionData = data.Split('\n');\r
121 \r
122                     if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))\r
123                     {\r
124                         lbl_update.Visible = true;\r
125                     }\r
126                 }\r
127                 //else fail displaying an error message.\r
128                 catch (Exception)\r
129                 {\r
130                     //Silently ignore the error\r
131                 }\r
132             }\r
133         }\r
134 \r
135 \r
136         // --------------------------------------------------------------\r
137         // The Menu Bar\r
138         // --------------------------------------------------------------\r
139 \r
140         // FILE MENU --------------------------------------------------------------\r
141         private void mnu_open_Click(object sender, EventArgs e)\r
142         {\r
143             string filename;\r
144             File_Open.ShowDialog();\r
145             filename = File_Open.FileName;\r
146             if (filename != "")\r
147             {\r
148                 try\r
149                 {\r
150                     // Create StreamReader & open file\r
151                     StreamReader line = new StreamReader(filename);\r
152                     string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.\r
153                     \r
154                     // Read in the data and set the correct GUI component with the setting.\r
155                     text_source.Text = line.ReadLine();\r
156                     drp_dvdtitle.Text = line.ReadLine();\r
157                     drop_chapterStart.Text = line.ReadLine();\r
158                     drop_chapterFinish.Text = line.ReadLine();\r
159                     text_destination.Text = line.ReadLine();\r
160                     drp_videoEncoder.Text = line.ReadLine();\r
161                     drp_audioCodec.Text = line.ReadLine();\r
162                     text_width.Text = line.ReadLine();\r
163                     text_height.Text = line.ReadLine();\r
164                     text_top.Text = line.ReadLine();\r
165                     text_bottom.Text = line.ReadLine();\r
166                     text_left.Text = line.ReadLine();\r
167                     text_right.Text = line.ReadLine();\r
168                     drp_subtitle.Text = line.ReadLine();\r
169                     text_bitrate.Text = line.ReadLine();\r
170                     text_filesize.Text = line.ReadLine();\r
171                     slider_videoQuality.Value = int.Parse(line.ReadLine());\r
172 \r
173                     temporyLine = line.ReadLine();\r
174                     if (temporyLine == "Checked")\r
175                     {\r
176                         check_2PassEncode.CheckState = CheckState.Checked;\r
177                     }\r
178 \r
179                     temporyLine = line.ReadLine();\r
180                     if (temporyLine == "Checked")\r
181                     {\r
182                         check_DeInterlace.CheckState = CheckState.Checked;\r
183                     }\r
184 \r
185                     temporyLine = line.ReadLine();\r
186                     if (temporyLine == "Checked")\r
187                     {\r
188                         check_grayscale.CheckState = CheckState.Checked;\r
189                     }\r
190 \r
191                     drp_videoFramerate.Text = line.ReadLine();\r
192 \r
193                     temporyLine = line.ReadLine();\r
194                     if (temporyLine == "Checked")\r
195                     {\r
196                         Check_ChapterMarkers.CheckState = CheckState.Checked;\r
197                     }\r
198 \r
199                     temporyLine = line.ReadLine();\r
200                     if (temporyLine == "Checked")\r
201                     {\r
202                         CheckPixelRatio.CheckState = CheckState.Checked;\r
203                     }\r
204 \r
205                     temporyLine = line.ReadLine();\r
206                     if (temporyLine == "Checked")\r
207                     {\r
208                         check_turbo.CheckState = CheckState.Checked;\r
209                     }\r
210 \r
211                     temporyLine = line.ReadLine();\r
212                     if (temporyLine == "Checked")\r
213                     {\r
214                         check_largeFile.CheckState = CheckState.Checked;\r
215                     }\r
216    \r
217                     drp_audioBitrate.Text = line.ReadLine();\r
218                     drp_audioSampleRate.Text = line.ReadLine();\r
219                     drp_audioChannels.Text = line.ReadLine();\r
220                     drp_audioMixDown.Text = line.ReadLine();\r
221                     \r
222                     // Advanced H264 Options\r
223                     temporyLine = line.ReadLine();\r
224                     if (temporyLine == "Checked")\r
225                     {\r
226                         CheckCRF.CheckState = CheckState.Checked;\r
227                     }\r
228                     rtf_h264advanced.Text = line.ReadLine();\r
229 \r
230                     // Close the stream\r
231                     line.Close();\r
232 \r
233 \r
234                     // Fix for SliderValue not appearing when Opening saved file\r
235                     SliderValue.Text = slider_videoQuality.Value + "%";\r
236 \r
237                 } catch (Exception){\r
238                     MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
239                 }\r
240             }\r
241         }\r
242 \r
243         private void mnu_save_Click(object sender, EventArgs e)\r
244         {\r
245 \r
246             string filename;\r
247             File_Save.ShowDialog();\r
248             filename = File_Save.FileName;\r
249             if (filename != "")\r
250             {\r
251                 try\r
252                 {\r
253                     // Create a StreamWriter and open the file\r
254                     StreamWriter line = new StreamWriter(filename);\r
255 \r
256                     //Source\r
257                     line.WriteLine(text_source.Text);\r
258                     line.WriteLine(drp_dvdtitle.Text);\r
259                     line.WriteLine(drop_chapterStart.Text);\r
260                     line.WriteLine(drop_chapterFinish.Text);\r
261                     //Destination\r
262                     line.WriteLine(text_destination.Text);\r
263                     line.WriteLine(drp_videoEncoder.Text);\r
264                     line.WriteLine(drp_audioCodec.Text);\r
265                     line.WriteLine(text_width.Text);\r
266                     line.WriteLine(text_height.Text);\r
267                     //Picture Settings Tab\r
268                     line.WriteLine(text_top.Text);\r
269                     line.WriteLine(text_bottom.Text);\r
270                     line.WriteLine(text_left.Text);\r
271                     line.WriteLine(text_right.Text);\r
272                     line.WriteLine(drp_subtitle.Text);\r
273                     //Video Settings Tab\r
274                     line.WriteLine(text_bitrate.Text);\r
275                     line.WriteLine(text_filesize.Text);\r
276                     line.WriteLine(slider_videoQuality.Value.ToString());\r
277                     line.WriteLine(check_2PassEncode.CheckState.ToString());\r
278                     line.WriteLine(check_DeInterlace.CheckState.ToString());\r
279                     line.WriteLine(check_grayscale.CheckState.ToString());\r
280                     line.WriteLine(drp_videoFramerate.Text);\r
281                     line.WriteLine(Check_ChapterMarkers.CheckState.ToString());\r
282                     line.WriteLine(CheckPixelRatio.CheckState.ToString());\r
283                     line.WriteLine(check_turbo.CheckState.ToString());\r
284                     line.WriteLine(check_largeFile.CheckState.ToString());\r
285                     //Audio Settings Tab\r
286                     line.WriteLine(drp_audioBitrate.Text);\r
287                     line.WriteLine(drp_audioSampleRate.Text);\r
288                     line.WriteLine(drp_audioChannels.Text);\r
289                     line.WriteLine(drp_audioMixDown.Text);\r
290                     //H264 Tab\r
291                     line.WriteLine(CheckCRF.CheckState.ToString());\r
292                     line.WriteLine(rtf_h264advanced.Text);\r
293                     // close the stream\r
294                     line.Close();\r
295                     MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
296                 }\r
297                 catch(Exception)\r
298                 {\r
299                     MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
300                 }\r
301                 \r
302             }\r
303         }\r
304 \r
305         private void mnu_update_Click(object sender, EventArgs e)\r
306         {\r
307             Form Update = new frmUpdate();\r
308             Update.ShowDialog();\r
309         }\r
310 \r
311         private void mnu_exit_Click(object sender, EventArgs e)\r
312         {\r
313             this.Close();\r
314         }\r
315 \r
316         // TOOLS MENU --------------------------------------------------------------\r
317         private void mnu_encode_Click(object sender, EventArgs e)\r
318         {\r
319             //Queue.ShowDialog();\r
320         }\r
321 \r
322         private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
323         {\r
324             Form DVDData = new frmDvdInfo();\r
325             DVDData.Show();\r
326         }\r
327 \r
328         private void mnu_options_Click(object sender, EventArgs e)\r
329         {\r
330             Form Options = new frmOptions();\r
331             Options.ShowDialog();\r
332         }\r
333 \r
334         // PRESETS MENU --------------------------------------------------------------\r
335         private void mnu_preset_ipod133_Click(object sender, EventArgs e)\r
336         {\r
337             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
338             text_width.Text = "640";\r
339             text_height.Text = "480";\r
340             drp_videoEncoder.Text = "H.264 (iPod)";\r
341             text_bitrate.Text = "1000";\r
342             text_filesize.Text = "";\r
343             slider_videoQuality.Value = 0;\r
344             SliderValue.Text = "0%";\r
345             drp_audioBitrate.Text = "160";\r
346             rtf_h264advanced.Text = "";\r
347             drp_crop.Text = "No Crop";\r
348         }\r
349 \r
350         private void mnu_preset_ipod178_Click(object sender, EventArgs e)\r
351         {\r
352             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
353             text_width.Text = "640";\r
354             text_height.Text = "352";\r
355             drp_videoEncoder.Text = "H.264 (iPod)";\r
356             text_bitrate.Text = "1000";\r
357             text_filesize.Text = "";\r
358             slider_videoQuality.Value = 0;\r
359             SliderValue.Text = "0%";\r
360             drp_audioBitrate.Text = "160";\r
361             rtf_h264advanced.Text = "";\r
362             drp_crop.Text = "No Crop";\r
363         }\r
364 \r
365         private void mnu_preset_ipod235_Click(object sender, EventArgs e)\r
366         {\r
367             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
368             text_width.Text = "640";\r
369             text_height.Text = "272";\r
370             drp_videoEncoder.Text = "H.264 (iPod)";\r
371             text_bitrate.Text = "1000";\r
372             text_filesize.Text = "";\r
373             slider_videoQuality.Value = 0;\r
374             SliderValue.Text = "0%";\r
375             drp_audioBitrate.Text = "160";\r
376             rtf_h264advanced.Text = "";\r
377             drp_crop.Text = "No Crop";\r
378         }\r
379 \r
380         private void mnu_appleTv_Click(object sender, EventArgs e)\r
381         {\r
382             text_width.Text = "";\r
383             text_height.Text = "";\r
384             drp_videoEncoder.Text = "H.264";\r
385             text_bitrate.Text = "3000";\r
386             text_filesize.Text = "";\r
387             slider_videoQuality.Value = 0;\r
388             SliderValue.Text = "0%";\r
389             drp_audioBitrate.Text = "160";\r
390             CheckPixelRatio.CheckState = CheckState.Checked;\r
391             drp_audioSampleRate.Text = "48";\r
392             rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";\r
393             drp_crop.Text = "No Crop";\r
394             \r
395         }\r
396 \r
397         private void mnu_presetPS3_Click(object sender, EventArgs e)\r
398         {\r
399             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
400             text_width.Text = "";\r
401             text_height.Text = "";\r
402             drp_videoEncoder.Text = "H.264";\r
403             text_bitrate.Text = "3000";\r
404             text_filesize.Text = "";\r
405             slider_videoQuality.Value = 0;\r
406             SliderValue.Text = "0%";\r
407             drp_audioBitrate.Text = "160";\r
408             CheckPixelRatio.CheckState = CheckState.Checked;\r
409             drp_audioSampleRate.Text = "48";\r
410             rtf_h264advanced.Text = "level=41";\r
411             drp_crop.Text = "No Crop";\r
412         }\r
413 \r
414         private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)\r
415         {\r
416             //Source\r
417             Properties.Settings.Default.DVDSource = text_source.Text;\r
418             Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;\r
419             Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;\r
420             Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;\r
421             //Destination\r
422             Properties.Settings.Default.VideoDest = text_destination.Text;\r
423             Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;\r
424             Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;\r
425             Properties.Settings.Default.Width = text_width.Text;\r
426             Properties.Settings.Default.Height = text_height.Text;\r
427             //Picture Settings Tab\r
428             Properties.Settings.Default.CroppingOption = drp_crop.Text;\r
429             Properties.Settings.Default.CropTop = text_top.Text;\r
430             Properties.Settings.Default.CropBottom = text_bottom.Text;\r
431             Properties.Settings.Default.CropLeft = text_left.Text;\r
432             Properties.Settings.Default.CropRight = text_right.Text;\r
433             Properties.Settings.Default.Subtitles = drp_subtitle.Text;\r
434             //Video Settings Tab\r
435             Properties.Settings.Default.VideoBitrate = text_bitrate.Text;\r
436             Properties.Settings.Default.VideoFilesize = text_filesize.Text;\r
437             Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;\r
438             Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();\r
439             Properties.Settings.Default.DeInterlace = check_DeInterlace.CheckState.ToString();\r
440             Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();\r
441             Properties.Settings.Default.Framerate = drp_videoFramerate.Text;\r
442             Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();\r
443             Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();\r
444             Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();\r
445             //Audio Settings Tab\r
446             Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;\r
447             Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;\r
448             Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;\r
449             //H264 Tab\r
450             Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();\r
451             Properties.Settings.Default.H264 = rtf_h264advanced.Text;\r
452             Properties.Settings.Default.Save();\r
453         }\r
454 \r
455         // Help Menu --------------------------------------------------------------\r
456         private void mnu_wiki_Click(object sender, EventArgs e)\r
457         {\r
458            Process.Start("http://handbrake.m0k.org/trac");\r
459         }\r
460 \r
461         private void mnu_onlineDocs_Click(object sender, EventArgs e)\r
462         {\r
463             Process.Start("http://handbrake.m0k.org/?page_id=11");\r
464         }\r
465 \r
466         private void mnu_faq_Click(object sender, EventArgs e)\r
467         {\r
468             Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");\r
469         }\r
470 \r
471         private void mnu_homepage_Click(object sender, EventArgs e)\r
472         {\r
473            Process.Start("http://handbrake.m0k.org");\r
474         }\r
475 \r
476         private void mnu_forum_Click(object sender, EventArgs e)\r
477         {\r
478             Process.Start("http://handbrake.m0k.org/forum");\r
479         }\r
480 \r
481         private void mnu_about_Click(object sender, EventArgs e)\r
482         {\r
483                         Form About = new frmAbout();\r
484             About.ShowDialog();\r
485         }\r
486 \r
487 \r
488 \r
489         // -------------------------------------------------------------- \r
490         // Buttons on the main Window\r
491         // --------------------------------------------------------------\r
492         private void btn_Browse_Click(object sender, EventArgs e)\r
493         {\r
494             String filename ="";\r
495             text_source.Text = "";\r
496 \r
497             if (RadioDVD.Checked)\r
498             {\r
499                 DVD_Open.ShowDialog();\r
500                 filename = DVD_Open.SelectedPath;\r
501                 if (filename != "")\r
502                 {\r
503                     text_source.Text = filename;\r
504                     Form frmReadDVD = new frmReadDVD(filename, this);\r
505                     frmReadDVD.ShowDialog();\r
506                 }\r
507             }\r
508             else\r
509             {\r
510                 ISO_Open.ShowDialog();\r
511                 filename = ISO_Open.FileName;\r
512                 if (filename != "")\r
513                 {\r
514                     text_source.Text = filename;\r
515                     Form frmReadDVD = new frmReadDVD(filename, this);\r
516                     frmReadDVD.ShowDialog();\r
517                 }\r
518             }  \r
519         }\r
520 \r
521         private void btn_destBrowse_Click(object sender, EventArgs e)\r
522         {\r
523             // TODO: Need to write some code to check if there is a reasonable amount of disk space left.\r
524 \r
525             DVD_Save.ShowDialog();\r
526             text_destination.Text = DVD_Save.FileName;\r
527 \r
528             if (Check_ChapterMarkers.Checked)\r
529             {\r
530                 string destination = text_destination.Text;\r
531                 destination = destination.Replace(".mp4", ".m4v");\r
532                 text_destination.Text = destination;\r
533             }\r
534         }\r
535 \r
536         private void btn_h264Clear_Click(object sender, EventArgs e)\r
537         {\r
538             rtf_h264advanced.Text = "";\r
539         }\r
540 \r
541         private void GenerateQuery_Click(object sender, EventArgs e)\r
542         {\r
543             String query = GenerateTheQuery();\r
544             QueryEditorText.Text = query;\r
545         }\r
546 \r
547         private void btn_ClearQuery_Click(object sender, EventArgs e)\r
548         {\r
549             QueryEditorText.Text = "";\r
550         }\r
551 \r
552 \r
553         \r
554      \r
555         private frmQueue queueWindow = (frmQueue)new frmQueue();\r
556         private void btn_queue_Click(object sender, EventArgs e)\r
557         {\r
558             String query = GenerateTheQuery();\r
559             queueWindow.list_queue.Items.Add(query);\r
560             queueWindow.Show();\r
561         }\r
562 \r
563         private void btn_encode_Click(object sender, EventArgs e)\r
564         {\r
565             String query = "";\r
566  \r
567             if (QueryEditorText.Text == "")\r
568             {\r
569                 query = GenerateTheQuery();\r
570             }\r
571             else\r
572             {\r
573                 query = QueryEditorText.Text;\r
574             }\r
575 \r
576             System.Diagnostics.Process hbProc = new System.Diagnostics.Process();\r
577             hbProc.StartInfo.FileName = "hbcli.exe";\r
578             hbProc.StartInfo.Arguments = query;\r
579             hbProc.StartInfo.UseShellExecute = false;\r
580             hbProc.Start();\r
581             \r
582 \r
583             MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
584        \r
585             // TODO: Need to write a bit of code here to do process monitoring.\r
586             // Note: hbProc.waitForExit will freeze the app, meaning one cannot add additional items to the queue during an encode.\r
587         }\r
588 \r
589         // -------------------------------------------------------------- \r
590         // Items that require actions on frmMain\r
591         // --------------------------------------------------------------\r
592 \r
593 \r
594         private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
595         {\r
596             QueryEditorText.Text = "";\r
597             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
598             {\r
599                 try\r
600                 {\r
601                     int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
602                     int chapterStart = int.Parse(drop_chapterStart.Text);\r
603 \r
604                     if (chapterFinish < chapterStart)\r
605                     {\r
606                         MessageBox.Show("Invalid Chapter Range! - Final chapter can not be smaller than the starting chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
607                     }\r
608                 }\r
609                 catch (Exception)\r
610                 {\r
611                     MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
612                 }\r
613             }\r
614 \r
615             \r
616         }\r
617 \r
618         private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
619         {\r
620             QueryEditorText.Text = "";\r
621             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
622             {\r
623                 try\r
624                 {\r
625                     int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
626                     int chapterStart = int.Parse(drop_chapterStart.Text);\r
627 \r
628                     if (chapterFinish > chapterStart)\r
629                     {\r
630                         MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
631                     }\r
632                 }\r
633                 catch (Exception)\r
634                 {\r
635                     MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
636                 }\r
637             }\r
638         }\r
639 \r
640         private void text_bitrate_TextChanged(object sender, EventArgs e)\r
641         {\r
642             text_filesize.Text = "";\r
643             slider_videoQuality.Value = 0;\r
644             SliderValue.Text = "0%";\r
645             CheckCRF.CheckState = CheckState.Unchecked;\r
646         }\r
647 \r
648         private void text_filesize_TextChanged(object sender, EventArgs e)\r
649         {\r
650             text_bitrate.Text = "";\r
651             slider_videoQuality.Value = 0;\r
652             SliderValue.Text = "0%";\r
653             CheckCRF.CheckState = CheckState.Unchecked;\r
654         }\r
655 \r
656         private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
657         {\r
658             SliderValue.Text = slider_videoQuality.Value.ToString() + "%";\r
659             text_bitrate.Text = "";\r
660             text_filesize.Text = "";\r
661         }\r
662 \r
663         private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
664         {\r
665             Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");\r
666         }\r
667 \r
668         private void text_width_TextChanged(object sender, EventArgs e)\r
669         {\r
670             try\r
671             {\r
672                 if (CheckPixelRatio.Checked) {\r
673                     text_width.Text = "";\r
674                 } else {\r
675                     if ((int.Parse(text_width.Text) % 16) != 0){\r
676                         text_width.BackColor = Color.LightCoral;\r
677                     }else {\r
678                         text_width.BackColor = Color.LightGreen;\r
679                     }\r
680                 }\r
681 \r
682                 if (!lbl_Aspect.Text.Equals("Select a Title")){\r
683                     int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);\r
684                     int mod16 = height % 16;\r
685                     height = height - mod16;\r
686                     text_height.Text = height.ToString();\r
687                 }\r
688                \r
689             } catch(Exception){\r
690                 \r
691             }\r
692         }\r
693 \r
694         private void text_height_TextChanged(object sender, EventArgs e)\r
695         {\r
696             try\r
697             {\r
698                 if (CheckPixelRatio.Checked)\r
699                 {\r
700                     text_height.Text = "";\r
701                 }\r
702                 else\r
703                 {\r
704                     if ((int.Parse(text_height.Text) % 16) != 0)\r
705                     {\r
706                         text_height.BackColor = Color.LightCoral;\r
707                     }\r
708                     else\r
709                     {\r
710                         text_height.BackColor = Color.LightGreen;\r
711                     }\r
712                 }\r
713             } catch(Exception){\r
714                 // No need to alert the user.\r
715             }\r
716         }\r
717 \r
718         private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)\r
719         {\r
720             if ((string)drp_crop.SelectedItem == "Manual")\r
721             {\r
722             text_left.Enabled = true;\r
723             text_right.Enabled = true;\r
724             text_top.Enabled = true;\r
725             text_bottom.Enabled = true;\r
726             }\r
727 \r
728             if ((string)drp_crop.SelectedItem == "Auto Crop")\r
729             {\r
730                 text_left.Enabled = false;\r
731                 text_right.Enabled = false;\r
732                 text_top.Enabled = false;\r
733                 text_bottom.Enabled = false;\r
734                 text_left.Text = "";\r
735                 text_right.Text = "";\r
736                 text_top.Text = "";\r
737                 text_bottom.Text = "";\r
738 \r
739                 if (lbl_RecomendedCrop.Text != "Select a Title")\r
740                 {\r
741                     string[] temp = new string[4];\r
742                     temp = lbl_RecomendedCrop.Text.Split('/');\r
743                     text_left.Text = temp[2];\r
744                     text_right.Text = temp[3];\r
745                     text_top.Text = temp[0];\r
746                     text_bottom.Text = temp[1];\r
747                 }\r
748             }\r
749 \r
750             if ((string)drp_crop.SelectedItem == "No Crop")\r
751             {\r
752                 text_left.Enabled = false;\r
753                 text_right.Enabled = false;\r
754                 text_top.Enabled = false;\r
755                 text_bottom.Enabled = false;\r
756                 text_left.Text = "0";\r
757                 text_right.Text = "0";\r
758                 text_top.Text = "0";\r
759                 text_bottom.Text = "0";\r
760 \r
761             }\r
762         }\r
763         \r
764         private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)\r
765         {\r
766             text_width.Text = "";\r
767             text_height.Text = "";\r
768             text_width.BackColor = Color.White;\r
769             text_height.BackColor = Color.White;\r
770         }\r
771 \r
772         private void drp_dvdtitle_Click(object sender, EventArgs e)\r
773         {\r
774             if (drp_dvdtitle.Items.Count == 1)\r
775             {\r
776                 MessageBox.Show("There are no titles to select. Please scan the DVD by clicking the 'browse' button above before trying to select a title.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
777             }\r
778         }\r
779 \r
780         private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)\r
781         {\r
782 \r
783             //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch\r
784 \r
785             drp_audioMixDown.Items.Clear();\r
786 \r
787             if (drp_audioCodec.Text == "AAC")\r
788             {\r
789                 drp_audioMixDown.Items.Clear();\r
790                 drp_audioMixDown.Items.Add("Mono");\r
791                 drp_audioMixDown.Items.Add("Stereo");\r
792                 drp_audioMixDown.Items.Add("Dolby Surround");\r
793                 drp_audioMixDown.Items.Add("Dolby Pro Logic II");\r
794                 drp_audioMixDown.Items.Add("6 Channel Discrete");\r
795                 \r
796                 drp_audioBitrate.Items.Clear();\r
797                 drp_audioBitrate.Items.Add("32");\r
798                 drp_audioBitrate.Items.Add("40");\r
799                 drp_audioBitrate.Items.Add("48");\r
800                 drp_audioBitrate.Items.Add("56");\r
801                 drp_audioBitrate.Items.Add("64");\r
802                 drp_audioBitrate.Items.Add("80");\r
803                 drp_audioBitrate.Items.Add("86");\r
804                 drp_audioBitrate.Items.Add("112");\r
805                 drp_audioBitrate.Items.Add("128");\r
806                 drp_audioBitrate.Items.Add("160");\r
807 \r
808             }\r
809             else\r
810             {\r
811                 drp_audioMixDown.Items.Clear();\r
812                 drp_audioMixDown.Items.Add("Stereo");\r
813                 drp_audioMixDown.Items.Add("Dolby Surround");\r
814                 drp_audioMixDown.Items.Add("Dolby Pro Logic II");\r
815 \r
816                 drp_audioBitrate.Items.Clear();\r
817                 drp_audioBitrate.Items.Add("32");\r
818                 drp_audioBitrate.Items.Add("40");\r
819                 drp_audioBitrate.Items.Add("48");\r
820                 drp_audioBitrate.Items.Add("56");\r
821                 drp_audioBitrate.Items.Add("64");\r
822                 drp_audioBitrate.Items.Add("80");\r
823                 drp_audioBitrate.Items.Add("86");\r
824                 drp_audioBitrate.Items.Add("112");\r
825                 drp_audioBitrate.Items.Add("128");\r
826                 drp_audioBitrate.Items.Add("160");\r
827                 drp_audioBitrate.Items.Add("192");\r
828                 drp_audioBitrate.Items.Add("224");\r
829                 drp_audioBitrate.Items.Add("256");\r
830                 drp_audioBitrate.Items.Add("320");\r
831                 drp_audioBitrate.Items.Add("384");\r
832             }\r
833         }\r
834 \r
835         private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)\r
836         {\r
837             if (drp_audioCodec.Text == "AAC")\r
838             {\r
839                 if (drp_audioMixDown.Text == "6 Channel Discrete")\r
840                 {\r
841 \r
842                     drp_audioBitrate.Items.Clear();\r
843                     drp_audioBitrate.Items.Add("32");\r
844                     drp_audioBitrate.Items.Add("40");\r
845                     drp_audioBitrate.Items.Add("48");\r
846                     drp_audioBitrate.Items.Add("56");\r
847                     drp_audioBitrate.Items.Add("64");\r
848                     drp_audioBitrate.Items.Add("80");\r
849                     drp_audioBitrate.Items.Add("86");\r
850                     drp_audioBitrate.Items.Add("112");\r
851                     drp_audioBitrate.Items.Add("128");\r
852                     drp_audioBitrate.Items.Add("160");\r
853                     drp_audioBitrate.Items.Add("192");\r
854                     drp_audioBitrate.Items.Add("224");\r
855                     drp_audioBitrate.Items.Add("256");\r
856                     drp_audioBitrate.Items.Add("320");\r
857                     drp_audioBitrate.Items.Add("384");\r
858                 }\r
859             }\r
860         }\r
861 \r
862         private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)\r
863         {\r
864             if (Check_ChapterMarkers.Checked)\r
865             {\r
866                 string destination = text_destination.Text;\r
867                 destination = destination.Replace(".mp4", ".m4v");\r
868                 text_destination.Text = destination;\r
869             }\r
870         }\r
871 \r
872         private void check_largeFile_CheckedChanged(object sender, EventArgs e)\r
873         {\r
874             if (!text_destination.Text.Contains(".mp4"))\r
875             {\r
876                 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
877                 check_largeFile.CheckState = CheckState.Unchecked;\r
878             }\r
879         }\r
880 \r
881         private void check_turbo_CheckedChanged(object sender, EventArgs e)\r
882         {\r
883             if (!drp_videoEncoder.Text.Contains("H.264"))\r
884             {\r
885                 MessageBox.Show("This option is only compatible with the H.264 encoder's", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
886                 check_turbo.CheckState = CheckState.Unchecked;\r
887             }\r
888         }\r
889 \r
890         private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)\r
891         {\r
892             //Turn off some options which are H.264 only when the user selects a non h.264 encoder\r
893             if (!drp_videoEncoder.Text.Contains("H.264"))\r
894             {\r
895                 check_turbo.CheckState = CheckState.Unchecked;\r
896                 CheckCRF.CheckState = CheckState.Unchecked;\r
897             }\r
898         }\r
899 \r
900         private void CheckCRF_CheckedChanged(object sender, EventArgs e)\r
901         {\r
902             if (slider_videoQuality.Value == 0)\r
903             {\r
904                 MessageBox.Show("This option is can only be used with the 'Video Quality' slider.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
905                 CheckCRF.CheckState = CheckState.Unchecked;\r
906             }\r
907         }\r
908 \r
909         Parsing.DVD thisDVD;\r
910         public void setStreamReader(Parsing.DVD dvd)\r
911         {\r
912             this.thisDVD = dvd;\r
913         }\r
914 \r
915         private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
916         {\r
917             // Reset some values on the form\r
918             lbl_Aspect.Text = "Select a Title";\r
919             lbl_RecomendedCrop.Text = "Select a Title";\r
920             QueryEditorText.Text = "";\r
921 \r
922             // If the dropdown is set to automatic nothing else needs to be done.\r
923             // Otheriwse if its not, title data has to be loased from parsing.\r
924             if (drp_dvdtitle.Text != "Automatic")\r
925             {\r
926                 string[] temp;\r
927                 string title;\r
928                 temp = drp_dvdtitle.Text.Split(' ');\r
929                 title = temp[0].Trim();\r
930               \r
931                 int count = thisDVD.Titles.Count - 1;\r
932                 int counter = 0;\r
933 \r
934                 while (count >= counter)\r
935                 {\r
936 \r
937                     if (thisDVD.Titles[counter].TitleNumber.ToString() == title)\r
938                     {\r
939                         lbl_Aspect.Text = thisDVD.Titles[counter].AspectRatio.ToString();\r
940                         lbl_RecomendedCrop.Text = thisDVD.Titles[counter].AutoCropDimensions[0] + "/" + thisDVD.Titles[counter].AutoCropDimensions[1] + "/" + thisDVD.Titles[counter].AutoCropDimensions[2] + "/" + thisDVD.Titles[counter].AutoCropDimensions[3];\r
941                         // Still need to set these up.\r
942                         MessageBox.Show(thisDVD.Titles[counter].AudioTracks[0].ToString());\r
943                         MessageBox.Show(thisDVD.Titles[counter].Chapters.ToString());\r
944                         MessageBox.Show(thisDVD.Titles[counter].Subtitles.ToString());\r
945                     }\r
946                     counter++;\r
947                 }\r
948 \r
949 \r
950             }\r
951             \r
952         } \r
953 \r
954         //\r
955         // The Query Generation Function\r
956         //\r
957 \r
958 \r
959         // This function was imported from old vb.net version of this application.\r
960         // It could probably do with being cleaned up a good deal at some point\r
961         public string GenerateTheQuery()\r
962         {\r
963             string source = text_source.Text;\r
964             string dvdTitle = drp_dvdtitle.Text;\r
965             string chapterStart = drop_chapterStart.Text;\r
966             string chapterFinish = drop_chapterFinish.Text;\r
967             int totalChapters = drop_chapterFinish.Items.Count - 1;\r
968             string dvdChapter = "";\r
969 \r
970             if (source ==  "")\r
971                 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
972             else\r
973             {\r
974                 source = " -i " + '"' + source+ '"'; //'"'+\r
975             }\r
976 \r
977             if (dvdTitle ==  "Automatic")\r
978                 dvdTitle = "";\r
979             else\r
980             {\r
981                 string[] titleInfo = dvdTitle.Split(' ');\r
982                 dvdTitle = " -t "+ titleInfo[0];\r
983             }\r
984 \r
985             if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))\r
986                 dvdChapter = "";\r
987             else if (chapterFinish == chapterStart)\r
988                 dvdChapter = " -c " + chapterStart;\r
989             else\r
990                 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;\r
991 \r
992             string querySource = source+ dvdTitle+ dvdChapter;\r
993             // ----------------------------------------------------------------------\r
994 \r
995             // Destination\r
996 \r
997             string destination = text_destination.Text;\r
998             string videoEncoder = drp_videoEncoder.Text;\r
999             string audioEncoder = drp_audioCodec.Text;\r
1000             string width = text_width.Text;\r
1001             string height = text_height.Text;\r
1002 \r
1003             if (destination ==  "")\r
1004                 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
1005             else\r
1006                 destination = " -o " + '"' + destination + '"'; //'"'+ \r
1007 \r
1008 \r
1009             switch (videoEncoder)\r
1010             {\r
1011                 case "Mpeg 4":\r
1012                     videoEncoder = " -e ffmpeg";\r
1013                     break;\r
1014                 case "Xvid":\r
1015                     videoEncoder = " -e xvid";\r
1016                     break;\r
1017                 case "H.264":\r
1018                     videoEncoder = " -e x264";\r
1019                     break;\r
1020                 case "H.264 Baseline 1.3":\r
1021                     videoEncoder = " -e x264b13";\r
1022                     break;\r
1023                 case "H.264 (iPod)":\r
1024                     videoEncoder = " -e x264b30";\r
1025                     break;\r
1026                 default:\r
1027                     videoEncoder = " -e x264";\r
1028                     break;\r
1029             }\r
1030            \r
1031             switch (audioEncoder)\r
1032             {\r
1033                 case "AAC":\r
1034                     audioEncoder = " -E faac";\r
1035                     break;\r
1036                 case "MP3":\r
1037                     audioEncoder = " -E lame";\r
1038                     break;\r
1039                 case "Vorbis":\r
1040                     audioEncoder = " -E vorbis";\r
1041                     break;\r
1042                 case "AC3":\r
1043                     audioEncoder = " -E ac3";\r
1044                     break;\r
1045                 default:\r
1046                     audioEncoder = " -E faac";\r
1047                     break;\r
1048             }\r
1049 \r
1050             if (width !=  "")\r
1051                 width = " -w "+ width;\r
1052             \r
1053 \r
1054             if (height !=  "")\r
1055                 height = " -l "+ height;\r
1056             \r
1057 \r
1058             string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;\r
1059             // ----------------------------------------------------------------------\r
1060 \r
1061             // Picture Settings Tab\r
1062 \r
1063             string cropSetting = drp_crop.Text;\r
1064             string cropTop = text_top.Text;\r
1065             string cropBottom = text_bottom.Text;\r
1066             string cropLeft = text_left.Text;\r
1067             string cropRight = text_right.Text;\r
1068             string subtitles = drp_subtitle.Text;\r
1069             string cropOut = "";\r
1070             // Returns Crop Query\r
1071 \r
1072             if (cropSetting == "Auto Crop")\r
1073                 cropOut = "";\r
1074             else if (cropSetting == "No Crop")\r
1075                 cropOut = " --crop 0:0:0:0 ";\r
1076             else\r
1077                 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
1078 \r
1079             if (subtitles ==  "None")\r
1080                 subtitles = "";\r
1081             else if (subtitles ==  "")\r
1082                 subtitles = "";\r
1083             else\r
1084             {\r
1085                 string[] tempSub;\r
1086                 tempSub = subtitles.Split(' ');\r
1087                 subtitles = " -s "+ tempSub[0];\r
1088             }\r
1089 \r
1090             string queryPictureSettings = cropOut+ subtitles;\r
1091             // ----------------------------------------------------------------------\r
1092 \r
1093             // Video Settings Tab\r
1094 \r
1095             string videoBitrate = text_bitrate.Text;\r
1096             string videoFilesize = text_filesize.Text;\r
1097             int videoQuality = slider_videoQuality.Value;\r
1098             string vidQSetting = "";\r
1099             string twoPassEncoding = "";\r
1100             string deinterlace = "";\r
1101             string grayscale = "";\r
1102             string videoFramerate = drp_videoFramerate.Text;\r
1103             string pixelRatio = "";\r
1104             string ChapterMarkers = "";\r
1105             string turboH264 = "";\r
1106             string largeFile = "";\r
1107 \r
1108             if (videoBitrate !=  "")\r
1109                 videoBitrate = " -b "+ videoBitrate;\r
1110 \r
1111             if (videoFilesize !=  "")\r
1112                 videoFilesize = " -S "+ videoFilesize;\r
1113 \r
1114             // Video Quality Setting\r
1115 \r
1116             if ((videoQuality ==  0))\r
1117                 vidQSetting = "";\r
1118             else\r
1119             {\r
1120                 videoQuality = videoQuality/ 100;\r
1121                 if (videoQuality ==  1)\r
1122                 {\r
1123                     vidQSetting = "1.0";\r
1124                 }\r
1125 \r
1126                 vidQSetting = " -q " + videoQuality.ToString();\r
1127             }\r
1128 \r
1129             if (check_2PassEncode.Checked)\r
1130                 twoPassEncoding = " -2 ";\r
1131 \r
1132             if (check_DeInterlace.Checked)\r
1133                 deinterlace = " -d ";\r
1134 \r
1135             if (check_grayscale.Checked)\r
1136                 grayscale = " -g ";\r
1137 \r
1138             if (videoFramerate ==  "Automatic")\r
1139                 videoFramerate = "";\r
1140             else\r
1141                 videoFramerate = " -r "+ videoFramerate;\r
1142 \r
1143             if (CheckPixelRatio.Checked)\r
1144                 pixelRatio = " -p ";\r
1145 \r
1146             if (Check_ChapterMarkers.Checked)\r
1147                 ChapterMarkers = " -m ";\r
1148 \r
1149             if (check_turbo.Checked)\r
1150                 turboH264 = " -T ";\r
1151 \r
1152             if (check_largeFile.Checked)\r
1153                 largeFile = " -4 ";\r
1154 \r
1155             string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers + turboH264 + largeFile;\r
1156             // ----------------------------------------------------------------------\r
1157 \r
1158             // Audio Settings Tab\r
1159 \r
1160             string audioBitrate = drp_audioBitrate.Text;\r
1161             string audioSampleRate = drp_audioSampleRate.Text;\r
1162             string audioChannels = drp_audioChannels.Text;\r
1163             string Mixdown = drp_audioMixDown.Text;\r
1164             string SixChannelAudio = "";\r
1165 \r
1166             if (audioBitrate !=  "")\r
1167                 audioBitrate = " -B "+ audioBitrate;\r
1168 \r
1169             if (audioSampleRate !=  "")\r
1170                 audioSampleRate = " -R "+ audioSampleRate;\r
1171 \r
1172             if (audioChannels ==  "Automatic")\r
1173                 audioChannels = "";\r
1174             else if (audioChannels ==  "")\r
1175                 audioChannels = "";\r
1176             else\r
1177             {\r
1178                 string[] tempSub;\r
1179                 tempSub = audioChannels.Split(' ');\r
1180                 audioChannels = " -a "+ tempSub[0];\r
1181             }\r
1182 \r
1183             switch (Mixdown)\r
1184             {\r
1185                 case "Automatic":\r
1186                     Mixdown = "";\r
1187                     break;\r
1188                 case "Mono":\r
1189                     Mixdown = "mono";\r
1190                     break;\r
1191                 case "Stereo":\r
1192                     Mixdown = "stereo";\r
1193                     break;\r
1194                 case "Dolby Surround":\r
1195                     Mixdown = "dpl1";\r
1196                     break;\r
1197                 case "Dolby Pro Logic II":\r
1198                     Mixdown = "dpl2";\r
1199                     break;\r
1200                 case "6 Channel Discrete":\r
1201                     Mixdown = "6ch";\r
1202                     break;\r
1203                 default:\r
1204                     Mixdown = "stero";\r
1205                     break;\r
1206             }\r
1207 \r
1208             if (Mixdown !=  "")\r
1209                 SixChannelAudio = " -6 "+ Mixdown;\r
1210             else\r
1211                 SixChannelAudio = "";\r
1212 \r
1213             string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;\r
1214             // ----------------------------------------------------------------------\r
1215 \r
1216             //  H.264 Tab\r
1217 \r
1218             string CRF = CheckCRF.CheckState.ToString();\r
1219             string h264Advanced = rtf_h264advanced.Text;\r
1220             if ((CRF ==  "1"))\r
1221                 CRF = " -Q ";\r
1222             else\r
1223                 CRF = "";\r
1224 \r
1225             if ((h264Advanced ==  ""))\r
1226                 h264Advanced = "";\r
1227             else\r
1228                 h264Advanced = " -x "+ h264Advanced;\r
1229     \r
1230 \r
1231             string h264Settings = CRF+ h264Advanced;\r
1232             // ----------------------------------------------------------------------\r
1233 \r
1234             // Processors (Program Settings)\r
1235 \r
1236             string processors = Properties.Settings.Default.Processors;\r
1237             //  Number of Processors Handler\r
1238 \r
1239             if (processors ==  "Automatic")\r
1240                 processors = "";\r
1241             else\r
1242                 processors = " -C "+ processors+ " ";\r
1243 \r
1244 \r
1245             string queryAdvancedSettings = processors;\r
1246             // ----------------------------------------------------------------------\r
1247 \r
1248             //  Verbose option (Program Settings)\r
1249 \r
1250             string verbose = "";\r
1251             if (Properties.Settings.Default.verbose ==  "1")\r
1252                 verbose = " -v ";\r
1253 \r
1254             // ----------------------------------------------------------------------\r
1255 \r
1256             return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;\r
1257         }\r
1258 \r
1259         // This is the END of the road ------------------------------------------------------------------------------\r
1260     }\r
1261 }