OSDN Git Service

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