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.Collections.Specialized;\r
4 using System.ComponentModel;\r
5 using System.Data;\r
6 using System.Drawing;\r
7 using System.Text;\r
8 using System.Windows.Forms;\r
9 using System.Net;\r
10 using System.IO;\r
11 using System.Diagnostics;\r
12 using System.Threading;\r
13 using System.Runtime.InteropServices;\r
14 \r
15 \r
16 namespace Handbrake\r
17 {\r
18 \r
19     public partial class frmMain : Form\r
20     {\r
21         // -------------------------------------------------------------- \r
22         // Applicaiton Startup Stuff\r
23         // --------------------------------------------------------------\r
24 \r
25         #region Application Startup\r
26 \r
27         private Process hbProc;\r
28         private Parsing.DVD thisDVD;        \r
29         private frmQueue queueWindow = new frmQueue();  \r
30         //private frmDvdInfo dvdInfoWindow = new frmDvdInfo();\r
31 \r
32         public frmMain()\r
33         {\r
34 \r
35             ThreadPool.QueueUserWorkItem(showSplash);\r
36             Thread.Sleep(1000);\r
37 \r
38             InitializeComponent();\r
39 \r
40             // This is a quick Hack fix for the cross-thread problem with frmDvdIndo ************************\r
41             //dvdInfoWindow.Show();\r
42             //dvdInfoWindow.Hide();\r
43             // **********************************************************************************************\r
44 \r
45             // Set the Version number lable to the corect version.\r
46             Version.Text = "Version " + Properties.Settings.Default.GuiVersion;\r
47 \r
48             // Run the update checker.\r
49             updateCheck();\r
50 \r
51             // Now load the users default if required. (Will overide the above setting)\r
52             loadUserDefaults();\r
53 \r
54             // Display the quick start window if required.\r
55             quickStart();\r
56 \r
57             // Enable or disable tooltips\r
58             tooltip();\r
59 \r
60             // Hide the presets part of the window\r
61             this.Width = 590;\r
62 \r
63             // Create and initializes a new StringCollection.\r
64             StringCollection myCol = new StringCollection();\r
65             // Add a range of elements from an array to the end of the StringCollection.\r
66             String[] myArr = new String[] { "RED", "orange", "yellow", "RED", "green", "blue", "RED", "indigo", "violet", "RED" };\r
67             myCol.AddRange(myArr);\r
68 \r
69             Properties.Settings.Default.BuiltInPresets = myCol;\r
70         }\r
71 \r
72         private void showSplash(object sender)\r
73         {\r
74             Form splash = new frmSplashScreen();\r
75             splash.Show();\r
76             Thread.Sleep(1500);  // Display splash screen for 1.5 Seconds\r
77             splash.Close(); // Then close.\r
78         }\r
79 \r
80         private void loadUserDefaults()\r
81         { \r
82             try\r
83             {\r
84                 if (Properties.Settings.Default.defaultSettings == "Checked")\r
85                 {\r
86                     // Source\r
87                     text_source.Text = Properties.Settings.Default.DVDSource;\r
88                     drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;\r
89                     drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;\r
90                     drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;\r
91 \r
92                     // Destination\r
93                     text_destination.Text = Properties.Settings.Default.VideoDest;\r
94                     drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;\r
95                     drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;\r
96                     text_width.Text = Properties.Settings.Default.Width;\r
97                     text_height.Text = Properties.Settings.Default.Height;\r
98 \r
99                     // Picture Settings Tab\r
100                     drp_crop.Text = Properties.Settings.Default.CroppingOption;\r
101                     text_top.Text = Properties.Settings.Default.CropTop;\r
102                     text_bottom.Text = Properties.Settings.Default.CropBottom;\r
103                     text_left.Text = Properties.Settings.Default.CropLeft;\r
104                     text_right.Text = Properties.Settings.Default.CropRight;\r
105                     drp_subtitle.Text = Properties.Settings.Default.Subtitles;\r
106 \r
107                     // Video Settings Tab\r
108                     text_bitrate.Text = Properties.Settings.Default.VideoBitrate;\r
109                     text_filesize.Text = Properties.Settings.Default.VideoFilesize;\r
110                     slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;\r
111 \r
112                     if (Properties.Settings.Default.TwoPass == "Checked")\r
113                     {\r
114                         check_2PassEncode.CheckState = CheckState.Checked;\r
115                     }\r
116 \r
117                     drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;\r
118                     drp_deNoise.Text = Properties.Settings.Default.denoise;\r
119 \r
120                     if (Properties.Settings.Default.detelecine == "Checked")\r
121                     {\r
122                         check_detelecine.CheckState = CheckState.Checked;\r
123                     }\r
124 \r
125                     if (Properties.Settings.Default.detelecine == "Checked")\r
126                     {\r
127                         check_deblock.CheckState = CheckState.Checked;\r
128                     }\r
129 \r
130 \r
131                     if (Properties.Settings.Default.Grayscale == "Checked")\r
132                     {\r
133                         check_grayscale.CheckState = CheckState.Checked;\r
134                     }\r
135 \r
136                     drp_videoFramerate.Text = Properties.Settings.Default.Framerate;\r
137 \r
138                     if (Properties.Settings.Default.PixelRatio == "Checked")\r
139                     {\r
140                         CheckPixelRatio.CheckState = CheckState.Checked;\r
141                     }\r
142                     if (Properties.Settings.Default.turboFirstPass == "Checked")\r
143                     {\r
144                         check_turbo.CheckState = CheckState.Checked;\r
145                     }\r
146                     if (Properties.Settings.Default.largeFile == "Checked")\r
147                     {\r
148                         check_largeFile.CheckState = CheckState.Checked;\r
149                     }\r
150                     // Audio Settings Tab\r
151                     drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;\r
152                     drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;\r
153                     drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;\r
154 \r
155                     // H264 Tab\r
156                     if (Properties.Settings.Default.CRF == "Checked")\r
157                     {\r
158                         CheckCRF.CheckState = CheckState.Checked;\r
159                     }\r
160                     rtf_h264advanced.Text = Properties.Settings.Default.H264;\r
161 \r
162                     groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.SelectedPreset + ")";\r
163                 }\r
164                 else\r
165                 {\r
166                     // Load the default preset on lauch\r
167                     ListBox_Presets.SelectedItem = "Normal";\r
168                 }\r
169             }\r
170             catch (Exception)\r
171             {\r
172                 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.\r
173             }\r
174         }\r
175 \r
176         private Boolean updateCheck()\r
177         {\r
178             try\r
179             {\r
180                 if (Properties.Settings.Default.updateStatus == "Checked")\r
181                 {\r
182                     String updateFile = Properties.Settings.Default.updateFile;\r
183                     WebClient client = new WebClient();\r
184                     String data = client.DownloadString(updateFile);\r
185                     String[] versionData = data.Split('\n');\r
186 \r
187                     int verdata = int.Parse(versionData[0].Replace(".", ""));\r
188                     int vergui = int.Parse(Properties.Settings.Default.GuiVersion.Replace(".", ""));\r
189                     int verd1 = int.Parse(versionData[1].Replace(".", ""));\r
190                     int cliversion = int.Parse(Properties.Settings.Default.CliVersion.Replace(".", ""));\r
191 \r
192                     Boolean update = ((verdata > vergui) || (verd1 > cliversion));\r
193    \r
194                     lbl_update.Visible = update;\r
195 \r
196                     return update;   \r
197                 }\r
198                 else\r
199                 {\r
200                     return false;\r
201                 }\r
202             }\r
203             catch (Exception)\r
204             {\r
205                 // Silently ignore the error\r
206                 return false;\r
207             }\r
208         }\r
209 \r
210         private void quickStart()\r
211         {\r
212             if ((Properties.Settings.Default.QuickStartWindow == "Checked") || (Properties.Settings.Default.QuickStartWindow == ""))\r
213             {\r
214                 frmQuickStart quickstart = new frmQuickStart();\r
215                 quickstart.ShowDialog();\r
216             }\r
217         }\r
218 \r
219         private void tooltip()\r
220         {\r
221             if (Properties.Settings.Default.tooltipEnable == "Checked")\r
222             {\r
223                 ToolTip.Active = true;\r
224             }\r
225         }\r
226 \r
227         #endregion\r
228 \r
229         // -------------------------------------------------------------- \r
230         // The main Menu bar.\r
231         // -------------------------------------------------------------- \r
232 \r
233         #region File Menu\r
234 \r
235         private void mnu_exit_Click(object sender, EventArgs e)\r
236         {\r
237             Application.Exit();\r
238         }\r
239 \r
240         #endregion\r
241 \r
242         #region Tools Menu\r
243 \r
244         private void mnu_encode_Click(object sender, EventArgs e)\r
245         {\r
246             showQueue();\r
247         }\r
248    \r
249         private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
250         {\r
251             frmDvdInfo dvdInfoWindow = new frmDvdInfo();\r
252             dvdInfoWindow.Show();\r
253         }\r
254 \r
255         private void mnu_options_Click(object sender, EventArgs e)\r
256         {\r
257             Form Options = new frmOptions();\r
258             Options.ShowDialog();\r
259         }\r
260 \r
261         #endregion\r
262 \r
263         #region Presets Menu\r
264 \r
265         private void mnu_presetReset_Click(object sender, EventArgs e)\r
266         {\r
267             ListBox_Presets.Items.Clear();\r
268             ListBox_Presets.Items.Add("Animation");\r
269             ListBox_Presets.Items.Add("AppleTV");\r
270             ListBox_Presets.Items.Add("Bedlam");\r
271             ListBox_Presets.Items.Add("Blind");\r
272             ListBox_Presets.Items.Add("Broke");\r
273             ListBox_Presets.Items.Add("Classic");\r
274             ListBox_Presets.Items.Add("Constant Quality Rate");\r
275             ListBox_Presets.Items.Add("Deux Six Quatre");\r
276             ListBox_Presets.Items.Add("Film");\r
277             ListBox_Presets.Items.Add("iPhone");\r
278             ListBox_Presets.Items.Add("iPod High-Rez");\r
279             ListBox_Presets.Items.Add("iPod Low-Rez");\r
280             ListBox_Presets.Items.Add("Normal");\r
281             ListBox_Presets.Items.Add("PS3");\r
282             ListBox_Presets.Items.Add("PSP");\r
283             ListBox_Presets.Items.Add("QuickTime");\r
284             ListBox_Presets.Items.Add("Television");\r
285 \r
286             if (presetStatus == false)\r
287             {\r
288                 this.Width = 881;\r
289                 presetStatus = true;\r
290                 btn_presets.Text = "Hide Presets";\r
291             }\r
292         }\r
293 \r
294         private void mnu_SelectDefault_Click(object sender, EventArgs e)\r
295         {\r
296             ListBox_Presets.SelectedItem = "Normal";\r
297             if (presetStatus == false)\r
298             {\r
299                 this.Width = 881;\r
300                 presetStatus = true;\r
301                 btn_presets.Text = "Hide Presets";\r
302             }\r
303         }\r
304 \r
305         #endregion\r
306 \r
307         #region Help Menu\r
308 \r
309         private void mnu_wiki_Click(object sender, EventArgs e)\r
310         {\r
311            Process.Start("http://handbrake.m0k.org/trac");\r
312         }\r
313 \r
314         private void mnu_faq_Click(object sender, EventArgs e)\r
315         {\r
316             Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");\r
317         }\r
318 \r
319         private void mnu_onlineDocs_Click(object sender, EventArgs e)\r
320         {\r
321             Process.Start("http://handbrake.m0k.org/?page_id=11");\r
322         }\r
323 \r
324         private void mnu_homepage_Click(object sender, EventArgs e)\r
325         {\r
326            Process.Start("http://handbrake.m0k.org");\r
327         }\r
328 \r
329         private void mnu_forum_Click(object sender, EventArgs e)\r
330         {\r
331             Process.Start("http://handbrake.m0k.org/forum");\r
332         }\r
333 \r
334         private void mnu_UpdateCheck_Click(object sender, EventArgs e)\r
335         {\r
336             Boolean update = updateCheck();\r
337             if (update == true)\r
338             {\r
339                 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
340             }\r
341             else\r
342             {\r
343                 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);\r
344             }\r
345         }\r
346 \r
347         private void mnu_about_Click(object sender, EventArgs e)\r
348         {\r
349                         Form About = new frmAbout();\r
350             About.ShowDialog();\r
351         }\r
352 \r
353         #endregion\r
354 \r
355         // -------------------------------------------------------------- \r
356         // Buttons on the main Window\r
357         // --------------------------------------------------------------\r
358 \r
359         #region Buttons\r
360 \r
361         private void btn_Browse_Click(object sender, EventArgs e)\r
362         {\r
363             String filename =""; \r
364                     text_source.Text = "";\r
365             frmDvdInfo dvdInfoWindow = new frmDvdInfo();                 \r
366                     if (RadioDVD.Checked) \r
367                     { \r
368                         DVD_Open.ShowDialog(); \r
369                         filename = DVD_Open.SelectedPath; \r
370                         if (filename != "") \r
371                         { \r
372                             Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow); \r
373                             text_source.Text = filename; \r
374                             frmRD.ShowDialog(); \r
375                         } \r
376                      } \r
377                      else \r
378                      { \r
379                         ISO_Open.ShowDialog(); \r
380                         filename = ISO_Open.FileName; \r
381                         if (filename != "") \r
382                         { \r
383                             Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow); \r
384                             text_source.Text = filename; \r
385                             frmRD.ShowDialog(); \r
386                         } \r
387                      }   \r
388                  \r
389                      // Check if there was titles in the dvd title dropdown \r
390                      if (filename == "") \r
391                      { \r
392                         text_source.Text = "Click 'Browse' to continue"; \r
393                      } \r
394                  \r
395                      if (drp_dvdtitle.Items.Count == 0) \r
396                      { \r
397                         MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source. Please refer to the FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); \r
398                      }                  \r
399         }\r
400 \r
401         private void btn_destBrowse_Click(object sender, EventArgs e)\r
402         {\r
403             // TODO: Need to write some code to check if there is a reasonable amount of disk space left.\r
404 \r
405             DVD_Save.ShowDialog();\r
406             text_destination.Text = DVD_Save.FileName;\r
407 \r
408             if (Check_ChapterMarkers.Checked)\r
409             {\r
410                 string destination = text_destination.Text;\r
411                 destination = destination.Replace(".mp4", ".m4v");\r
412                 text_destination.Text = destination;\r
413             }\r
414         }\r
415 \r
416         private void btn_h264Clear_Click(object sender, EventArgs e)\r
417         {\r
418             rtf_h264advanced.Text = "";\r
419         }\r
420 \r
421         private void GenerateQuery_Click(object sender, EventArgs e)\r
422         {\r
423             String query = GenerateTheQuery();\r
424             QueryEditorText.Text = query;\r
425         }\r
426 \r
427         private void btn_ClearQuery_Click(object sender, EventArgs e)\r
428         {\r
429             QueryEditorText.Text = "";\r
430         }\r
431 \r
432         private void btn_queue_Click(object sender, EventArgs e)\r
433         {\r
434             if (text_destination.Text != "" && text_source.Text != "")\r
435             {\r
436                 string query;\r
437                 if (QueryEditorText.Text == "")\r
438                 {\r
439                     query = GenerateTheQuery();\r
440                 }\r
441                 else\r
442                 {\r
443                     query = QueryEditorText.Text;\r
444                 }\r
445                 queueWindow.list_queue.Items.Add(query);\r
446                 queueWindow.Show();\r
447             } \r
448             else \r
449             {\r
450                 MessageBox.Show("No Source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
451             }\r
452         }\r
453 \r
454         private void btn_copy_Click(object sender, EventArgs e)\r
455         {\r
456             Clipboard.SetText(QueryEditorText.Text, TextDataFormat.Text);\r
457         }\r
458 \r
459         private void showQueue()\r
460         {\r
461             queueWindow.Show();\r
462         }\r
463 \r
464         #endregion\r
465 \r
466         // -------------------------------------------------------------- \r
467         // Main Window Preset System\r
468         // --------------------------------------------------------------\r
469 \r
470         #region Preset System\r
471 \r
472         // Varibles\r
473         private Boolean presetStatus = false;\r
474 \r
475         // Buttons\r
476         private void btn_presets_Click(object sender, EventArgs e)\r
477         {\r
478             if (presetStatus == false)\r
479             {\r
480                 this.Width = 881;\r
481                 presetStatus = true;\r
482                 btn_presets.Text = "Hide Presets";\r
483             }\r
484             else\r
485             {\r
486                 this.Width = 590;\r
487                 presetStatus = false;\r
488                 btn_presets.Text = "Show Presets";\r
489             }\r
490 \r
491         }\r
492 \r
493         private void btn_addPreset_Click(object sender, EventArgs e)\r
494         {\r
495             string filename;\r
496             File_Open.ShowDialog();\r
497             filename = File_Open.FileName;\r
498             if (filename != "")\r
499             {\r
500                 try\r
501                 {\r
502                     // Create StreamReader & open file\r
503                     StreamReader line = new StreamReader(filename);\r
504                     string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.\r
505 \r
506                     // Read in the data and set the correct GUI component with the setting.\r
507                     text_source.Text = line.ReadLine();\r
508                     drp_dvdtitle.Text = line.ReadLine();\r
509                     drop_chapterStart.Text = line.ReadLine();\r
510                     drop_chapterFinish.Text = line.ReadLine();\r
511                     text_destination.Text = line.ReadLine();\r
512                     drp_videoEncoder.Text = line.ReadLine();\r
513                     drp_audioCodec.Text = line.ReadLine();\r
514                     text_width.Text = line.ReadLine();\r
515                     text_height.Text = line.ReadLine();\r
516                     text_top.Text = line.ReadLine();\r
517                     text_bottom.Text = line.ReadLine();\r
518                     text_left.Text = line.ReadLine();\r
519                     text_right.Text = line.ReadLine();\r
520                     drp_subtitle.Text = line.ReadLine();\r
521                     text_bitrate.Text = line.ReadLine();\r
522                     text_filesize.Text = line.ReadLine();\r
523                     slider_videoQuality.Value = int.Parse(line.ReadLine());\r
524 \r
525                     temporyLine = line.ReadLine();\r
526                     if (temporyLine == "Checked")\r
527                     {\r
528                         check_2PassEncode.CheckState = CheckState.Checked;\r
529                     }\r
530 \r
531                     drp_deInterlace_option.Text = line.ReadLine();\r
532 \r
533                     temporyLine = line.ReadLine();\r
534                     if (temporyLine == "Checked")\r
535                     {\r
536                         check_grayscale.CheckState = CheckState.Checked;\r
537                     }\r
538 \r
539                     drp_videoFramerate.Text = line.ReadLine();\r
540 \r
541                     temporyLine = line.ReadLine();\r
542                     if (temporyLine == "Checked")\r
543                     {\r
544                         Check_ChapterMarkers.CheckState = CheckState.Checked;\r
545                     }\r
546 \r
547                     temporyLine = line.ReadLine();\r
548                     if (temporyLine == "Checked")\r
549                     {\r
550                         CheckPixelRatio.CheckState = CheckState.Checked;\r
551                     }\r
552 \r
553                     temporyLine = line.ReadLine();\r
554                     if (temporyLine == "Checked")\r
555                     {\r
556                         check_turbo.CheckState = CheckState.Checked;\r
557                     }\r
558 \r
559                     temporyLine = line.ReadLine();\r
560                     if (temporyLine == "Checked")\r
561                     {\r
562                         check_largeFile.CheckState = CheckState.Checked;\r
563                     }\r
564 \r
565                     drp_audioBitrate.Text = line.ReadLine();\r
566                     drp_audioSampleRate.Text = line.ReadLine();\r
567                     drp_audioChannels.Text = line.ReadLine();\r
568                     drp_audioMixDown.Text = line.ReadLine();\r
569 \r
570                     // Advanced H264 Options\r
571                     temporyLine = line.ReadLine();\r
572                     if (temporyLine == "Checked")\r
573                     {\r
574                         CheckCRF.CheckState = CheckState.Checked;\r
575                     }\r
576                     rtf_h264advanced.Text = line.ReadLine();\r
577 \r
578                     // Close the stream\r
579                     line.Close();\r
580 \r
581 \r
582                     // Fix for SliderValue not appearing when Opening saved file\r
583                     SliderValue.Text = slider_videoQuality.Value + "%";\r
584 \r
585                 }\r
586                 catch (Exception)\r
587                 {\r
588                     MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
589                 }\r
590             }\r
591         }\r
592 \r
593         private void btn_removePreset_Click(object sender, EventArgs e)\r
594         {\r
595             string filename;\r
596             File_Save.ShowDialog();\r
597             filename = File_Save.FileName;\r
598             if (filename != "")\r
599             {\r
600                 try\r
601                 {\r
602                     // Create a StreamWriter and open the file\r
603                     StreamWriter line = new StreamWriter(filename);\r
604 \r
605                     //Source\r
606                     line.WriteLine(text_source.Text);\r
607                     line.WriteLine(drp_dvdtitle.Text);\r
608                     line.WriteLine(drop_chapterStart.Text);\r
609                     line.WriteLine(drop_chapterFinish.Text);\r
610                     //Destination\r
611                     line.WriteLine(text_destination.Text);\r
612                     line.WriteLine(drp_videoEncoder.Text);\r
613                     line.WriteLine(drp_audioCodec.Text);\r
614                     line.WriteLine(text_width.Text);\r
615                     line.WriteLine(text_height.Text);\r
616                     //Picture Settings Tab\r
617                     line.WriteLine(text_top.Text);\r
618                     line.WriteLine(text_bottom.Text);\r
619                     line.WriteLine(text_left.Text);\r
620                     line.WriteLine(text_right.Text);\r
621                     line.WriteLine(drp_subtitle.Text);\r
622                     //Video Settings Tab\r
623                     line.WriteLine(text_bitrate.Text);\r
624                     line.WriteLine(text_filesize.Text);\r
625                     line.WriteLine(slider_videoQuality.Value.ToString());\r
626                     line.WriteLine(check_2PassEncode.CheckState.ToString());\r
627                     line.WriteLine(drp_deInterlace_option.Text);\r
628                     line.WriteLine(check_grayscale.CheckState.ToString());\r
629                     line.WriteLine(drp_videoFramerate.Text);\r
630                     line.WriteLine(Check_ChapterMarkers.CheckState.ToString());\r
631                     line.WriteLine(CheckPixelRatio.CheckState.ToString());\r
632                     line.WriteLine(check_turbo.CheckState.ToString());\r
633                     line.WriteLine(check_largeFile.CheckState.ToString());\r
634                     //Audio Settings Tab\r
635                     line.WriteLine(drp_audioBitrate.Text);\r
636                     line.WriteLine(drp_audioSampleRate.Text);\r
637                     line.WriteLine(drp_audioChannels.Text);\r
638                     line.WriteLine(drp_audioMixDown.Text);\r
639                     //H264 Tab\r
640                     line.WriteLine(CheckCRF.CheckState.ToString());\r
641                     line.WriteLine(rtf_h264advanced.Text);\r
642                     // close the stream\r
643                     line.Close();\r
644                     MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
645                 }\r
646                 catch (Exception)\r
647                 {\r
648                     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
649                 }\r
650 \r
651             }\r
652         }\r
653 \r
654         private void btn_setDefault_Click(object sender, EventArgs e)\r
655         {\r
656             //Source\r
657             Properties.Settings.Default.DVDSource = text_source.Text;\r
658             Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;\r
659             Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;\r
660             Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;\r
661             //Destination\r
662             Properties.Settings.Default.VideoDest = text_destination.Text;\r
663             Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;\r
664             Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;\r
665             Properties.Settings.Default.Width = text_width.Text;\r
666             Properties.Settings.Default.Height = text_height.Text;\r
667             //Picture Settings Tab\r
668             Properties.Settings.Default.CroppingOption = drp_crop.Text;\r
669             Properties.Settings.Default.CropTop = text_top.Text;\r
670             Properties.Settings.Default.CropBottom = text_bottom.Text;\r
671             Properties.Settings.Default.CropLeft = text_left.Text;\r
672             Properties.Settings.Default.CropRight = text_right.Text;\r
673             Properties.Settings.Default.Subtitles = drp_subtitle.Text;\r
674             //Video Settings Tab\r
675             Properties.Settings.Default.VideoBitrate = text_bitrate.Text;\r
676             Properties.Settings.Default.VideoFilesize = text_filesize.Text;\r
677             Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;\r
678             Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();\r
679             Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;\r
680             Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();\r
681             Properties.Settings.Default.Framerate = drp_videoFramerate.Text;\r
682             Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();\r
683             Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();\r
684             Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();\r
685             Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();\r
686             Properties.Settings.Default.denoise = drp_deNoise.Text;\r
687             Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();\r
688             //Audio Settings Tab\r
689             Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;\r
690             Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;\r
691             Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;\r
692             //H264 Tab\r
693             Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();\r
694             Properties.Settings.Default.H264 = rtf_h264advanced.Text;\r
695             Properties.Settings.Default.SelectedPreset = ListBox_Presets.SelectedItem.ToString();\r
696             Properties.Settings.Default.Save();\r
697         }\r
698 \r
699 \r
700         // Preset Seleciton\r
701         private void ListBox_Presets_SelectedIndexChanged(object sender, EventArgs e)\r
702         {\r
703             string selectedPreset = null;\r
704             if (ListBox_Presets.SelectedItem != null)\r
705             {\r
706                 selectedPreset = ListBox_Presets.SelectedItem.ToString();\r
707             }\r
708             else\r
709             {\r
710                 selectedPreset = "";\r
711             }\r
712 \r
713             switch (selectedPreset)\r
714             {\r
715                 case "Animation":\r
716                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "1000", "", 0, "0%", "160", CheckState.Checked, "48", "ref=5:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2", "Origional (Fast)", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Apple Animation)");\r
717                     setMkv();\r
718                     break;\r
719                 case "AppleTV":\r
720                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "2500", "", 0, "0%", "160", CheckState.Checked, "48", "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: Apple TV)");\r
721                     break;\r
722                 case "Bedlam":\r
723                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "1800", "", 0, "0%", "160", CheckState.Checked, "48", "ref=16:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:me-range=64:analyse=all:8x8dct:trellis=2:no-fast-pskip:no-dct-decimate:filter=-2,-1", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Bedlam)");\r
724                     setMkv();\r
725                     break;\r
726                 case "Blind":\r
727                     setGuiSetttings(CheckState.Unchecked, "512", "", "H.264", "512", "", 0, "0%", "128", CheckState.Checked, "48", "", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: Blind)");\r
728                     break;\r
729                 case "Broke":\r
730                     setGuiSetttings(CheckState.Unchecked, "640", "", "H.264", "", "695", 0, "0%", "128", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=6:bime:weightb:b-rdo:b-pyramid::direct=auto:me=umh:subme=6:trellis=1:analyse=all:8x8dct:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Broke)");\r
731                     break;\r
732                 case "Classic":\r
733                     setGuiSetttings(CheckState.Unchecked, "", "", "H.264", "1000", "", 0, "0%", "160", CheckState.Unchecked, "48", "", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: Classic)");\r
734                     break;\r
735                 case "Constant Quality Rate":\r
736                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "", "", 64, "64%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=3:b-pyramid:b-rdo:bime:weightb:filter=-2,-1:subme=6:trellis=1:analyse=all:8x8dct:me=umh", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AC3", "Output Settings (Preset: CQR)");\r
737                     setMkv();\r
738                     break;\r
739                 case "Deux Six Quatre":\r
740                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "1600", "", 0, "0%", "160", CheckState.Checked, "48", "ref=5:mixed-refs:bframes=3:bime:weightb:b-rdo:b-pyramid:me=umh:subme=7:trellis=1:analyse=all:8x8dct:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AC3", "Output Settings (Preset: DSQ)");\r
741                     setMkv();\r
742                     break;\r
743                 case "Film":\r
744                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "2000", "", 0, "0%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AC3", "Output Settings (Preset: Film)");\r
745                     setMkv();\r
746                     break;\r
747                 case "iPhone":\r
748                     setGuiSetttings(CheckState.Unchecked, "480", "", "H.264", "960", "", 0, "0%", "128", CheckState.Checked, "48", "cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: iPhone)");\r
749                     break;\r
750                 case "iPod High-Rez":\r
751                     setGuiSetttings(CheckState.Unchecked, "640", "", "H.264", "1500", "", 0, "0%", "160", CheckState.Checked, "48", "keyint=300:keyint-min=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: iPod High Rez)");\r
752                     break;\r
753                 case "iPod Low-Rez":\r
754                     setGuiSetttings(CheckState.Unchecked, "320", "", "H.264", "700", "", 0, "0%", "160", CheckState.Checked, "48", "keyint=300:keyint-min=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: iPod Low Rez)");\r
755                     break;\r
756                 case "Normal":\r
757                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "1500", "", 0, "0%", "160", CheckState.Checked, "48", "ref=2:bframes=2:subme=5:me=umh", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Normal)");\r
758                     break;\r
759                 case "PS3":\r
760                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "2500", "", 0, "0%", "160", CheckState.Checked, "48", "level=41:subme=5:me=umh", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: PS3)");\r
761                     break;\r
762                 case "PSP":\r
763                     setGuiSetttings(CheckState.Unchecked, "368", "208", "Mpeg 4", "1024", "", 0, "0%", "160", CheckState.Unchecked, "48", "", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: PSP)");\r
764                     break;\r
765                 case "QuickTime":\r
766                     setGuiSetttings(CheckState.Checked, "", "", "H.264", "2000", "", 0, "0%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct-auto:me=umh:subme=5:analyse=all:8x8dct:trellis=1:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Quicktime)");\r
767                     break;\r
768                 case "Television":\r
769                     setGuiSetttings(CheckState.Unchecked, "", "", "H.264", "1300", "", 0, "0%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=6:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip", "Origional (Fast)", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Television)");\r
770                     setMkv();\r
771                     break;\r
772                 default:\r
773                     break;\r
774             }\r
775         }\r
776 \r
777 \r
778         // Functions - It's a bit dirty but i'll sort this out later. Simply done to reduce the amount of code above.\r
779         private void setGuiSetttings(CheckState anamorphic, string width, string height, string vencoder, string bitrate, string filesize, int quality, string qpercent, string audioBit, CheckState chpt, string audioSample, string h264, string deinterlace, CheckState twopass, string crop, CheckState turbo, string audioCodec, string preset)\r
780         {\r
781             CheckPixelRatio.CheckState = anamorphic;\r
782             text_width.Text = width;\r
783             text_height.Text = height;\r
784             drp_videoEncoder.Text = vencoder;\r
785             text_bitrate.Text = bitrate;\r
786             text_filesize.Text = filesize;\r
787             slider_videoQuality.Value = quality;\r
788             SliderValue.Text = qpercent;\r
789             drp_audioBitrate.Text = audioBit;\r
790             Check_ChapterMarkers.CheckState = chpt;\r
791             drp_audioSampleRate.Text = audioSample;\r
792             rtf_h264advanced.Text = h264;\r
793             drp_deInterlace_option.Text = deinterlace;\r
794             check_2PassEncode.CheckState = twopass;\r
795             drp_crop.Text = crop;\r
796             check_turbo.CheckState = turbo;\r
797             drp_audioCodec.Text = audioCodec;\r
798 \r
799             groupBox_output.Text = preset;\r
800         }\r
801 \r
802         private void setMkv()\r
803         {\r
804             // Set file extension to MKV\r
805             string destination = text_destination.Text;\r
806             destination = destination.Replace(".mp4", ".mkv");\r
807             destination = destination.Replace(".avi", ".mkv");\r
808             destination = destination.Replace(".m4v", ".mkv");\r
809             destination = destination.Replace(".ogm", ".mkv");\r
810             text_destination.Text = destination;\r
811         }\r
812 \r
813         #endregion\r
814 \r
815         //---------------------------------------------------\r
816         // Encode / Cancel Buttons\r
817         // Encode Progress Text Handler\r
818         //---------------------------------------------------\r
819 \r
820         #region Encode/CLI\r
821 \r
822         Functions.CLI process = new Functions.CLI();\r
823 \r
824         private void btn_encode_Click(object sender, EventArgs e)\r
825         {\r
826             //btn_eCancel.Enabled = true;\r
827             String query = "";            \r
828             if (QueryEditorText.Text == "")\r
829             {\r
830                 query = GenerateTheQuery();\r
831             }\r
832             else\r
833             {\r
834                 query = QueryEditorText.Text;\r
835             }\r
836 \r
837             ThreadPool.QueueUserWorkItem(procMonitor, query);\r
838             lbl_encode.Visible = true;\r
839             lbl_encode.Text = "Encoding in Progress";\r
840         }\r
841 \r
842         private void btn_eCancel_Click(object sender, EventArgs e)\r
843         {\r
844             process.killCLI();\r
845             process.setNull();\r
846             lbl_encode.Text = "Encoding Canceled";\r
847         }\r
848 \r
849 \r
850         [DllImport("user32.dll")]\r
851         public static extern void LockWorkStation();\r
852         [DllImport("user32.dll")]\r
853         public static extern int ExitWindowsEx(int uFlags, int dwReason); \r
854 \r
855         private void procMonitor(object state)\r
856         {\r
857             // Make sure we are not already encoding and if we are then display an error.\r
858             if (hbProc != null)\r
859             {\r
860                 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
861             }\r
862             else\r
863             {\r
864                 hbProc = process.runCli(this, (string)state, false, false, false, false);\r
865                 hbProc.WaitForExit();\r
866 \r
867                 try\r
868                 {\r
869 \r
870                     //*****************************************************************************************\r
871                     // BUG!\r
872                     // When the below code is used and standard error is set to true, hbcli is outputing a\r
873                     // video stream which has mild corruption issues every few seconds.\r
874                     // Maybe an issue with the Parser cauing the CLI to hickup/pause?\r
875                     //*****************************************************************************************\r
876 \r
877                     \r
878                     /*Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);\r
879                     encode.OnEncodeProgress += encode_OnEncodeProgress;\r
880                     while (!encode.EndOfStream)\r
881                     {\r
882                         encode.ReadLine();\r
883                     }\r
884 \r
885                     hbProc.WaitForExit();\r
886                     process.closeCLI();\r
887                     */\r
888                 }\r
889                 catch (Exception)\r
890                 {\r
891                     // Do nothing\r
892                 }\r
893 \r
894 \r
895                 setEncodeLabel();\r
896                 hbProc = null;\r
897 \r
898                 // Do something whent he encode ends.\r
899                 switch (Properties.Settings.Default.CompletionOption)\r
900                 {\r
901                     case "Shutdown":\r
902                         System.Diagnostics.Process.Start("Shutdown", "-s -t 60");\r
903                         break;\r
904                     case "Log Off":\r
905                         ExitWindowsEx(0, 0); \r
906                         break;\r
907                     case "Suspend":\r
908                         Application.SetSuspendState(PowerState.Suspend, true, true);\r
909                         break;\r
910                     case "Hibernate":\r
911                         Application.SetSuspendState(PowerState.Hibernate, true, true);\r
912                         break;\r
913                     case "Lock System":\r
914                         LockWorkStation();\r
915                         break;\r
916                     case "Quit HandBrake":\r
917                         Application.Exit();\r
918                         break;\r
919                     default:\r
920                         break;\r
921                 }\r
922             }\r
923         }\r
924 \r
925         private delegate void UpdateUIHandler();\r
926 \r
927         private void setEncodeLabel()\r
928         {\r
929             if (this.InvokeRequired)\r
930             {\r
931                 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));\r
932                 return;\r
933             }\r
934             lbl_encode.Text = "Encoding Finished";\r
935         }\r
936 \r
937         /*private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)\r
938         {\r
939             \r
940             if (this.InvokeRequired)\r
941             {\r
942                 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),\r
943                     new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });\r
944                 return;\r
945             }\r
946             lbl_encode.Text = string.Format("Encode Progress: {0}%,       FPS: {1},       Avg FPS: {2},       Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);\r
947         }*/\r
948 \r
949         #endregion\r
950 \r
951         //---------------------------------------------------\r
952         //  Items that require actions on frmMain\r
953         //---------------------------------------------------\r
954 \r
955         #region frmMain Actions\r
956 \r
957         private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
958         {\r
959             drop_chapterStart.BackColor = Color.White;\r
960             QueryEditorText.Text = "";\r
961             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
962             {\r
963                 try\r
964                 {\r
965                     int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
966                     int chapterStart = int.Parse(drop_chapterStart.Text);\r
967 \r
968                     if (chapterFinish < chapterStart)\r
969                     {\r
970                         drop_chapterStart.BackColor = Color.LightCoral;\r
971                     }\r
972                 }\r
973                 catch (Exception)\r
974                 {\r
975                     drop_chapterStart.BackColor = Color.LightCoral;\r
976                 }\r
977             }\r
978 \r
979             \r
980         }\r
981 \r
982         private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
983         {\r
984             drop_chapterFinish.BackColor = Color.White;\r
985             QueryEditorText.Text = "";\r
986             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
987             {\r
988                 try\r
989                 {\r
990                     int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
991                     int chapterStart = int.Parse(drop_chapterStart.Text);\r
992 \r
993                     if (chapterFinish < chapterStart)\r
994                     {\r
995                         drop_chapterFinish.BackColor = Color.LightCoral;\r
996                     }\r
997                 }\r
998                 catch (Exception)\r
999                 {\r
1000                     drop_chapterFinish.BackColor = Color.LightCoral;\r
1001                 }\r
1002             }\r
1003         }\r
1004 \r
1005         private void text_bitrate_TextChanged(object sender, EventArgs e)\r
1006         {\r
1007             text_filesize.Text = "";\r
1008             slider_videoQuality.Value = 0;\r
1009             SliderValue.Text = "0%";\r
1010             CheckCRF.CheckState = CheckState.Unchecked;\r
1011             CheckCRF.Enabled = false;\r
1012         }\r
1013 \r
1014         private void text_filesize_TextChanged(object sender, EventArgs e)\r
1015         {\r
1016             text_bitrate.Text = "";\r
1017             slider_videoQuality.Value = 0;\r
1018             SliderValue.Text = "0%";\r
1019             CheckCRF.CheckState = CheckState.Unchecked;\r
1020             CheckCRF.Enabled = false;\r
1021         }\r
1022 \r
1023         private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
1024         {\r
1025             SliderValue.Text = slider_videoQuality.Value.ToString() + "%";\r
1026             text_bitrate.Text = "";\r
1027             text_filesize.Text = "";\r
1028             CheckCRF.Enabled = true;\r
1029         }\r
1030 \r
1031         private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
1032         {\r
1033             Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");\r
1034         }\r
1035 \r
1036         private void text_width_TextChanged(object sender, EventArgs e)\r
1037         {\r
1038 \r
1039             try\r
1040             {\r
1041                 if (CheckPixelRatio.Checked)\r
1042                 {\r
1043                     text_width.Text = "";\r
1044                     text_width.BackColor = Color.White;\r
1045                 }\r
1046                 else\r
1047                 {\r
1048                     if ((int.Parse(text_width.Text) % 16) != 0)\r
1049                     {\r
1050                         text_width.BackColor = Color.LightCoral;\r
1051                     }\r
1052                     else\r
1053                     {\r
1054                         text_width.BackColor = Color.LightGreen;\r
1055                     }\r
1056                 }\r
1057 \r
1058                 if (lbl_Aspect.Text != "Select a Title")\r
1059                 {\r
1060                     double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);\r
1061                     double mod16 = height % 16;\r
1062                     height = height - mod16;\r
1063 \r
1064                     if (text_width.Text == "")\r
1065                     {\r
1066                         text_height.Text = "";\r
1067                         text_width.BackColor = Color.White;\r
1068                     }\r
1069                     else\r
1070                     {\r
1071                         text_height.Text = height.ToString();\r
1072                     }\r
1073                 }\r
1074             }\r
1075             catch (Exception)\r
1076             {\r
1077                 // No need to throw an error here.\r
1078                 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.\r
1079             }\r
1080                \r
1081           \r
1082         }\r
1083 \r
1084         private void text_height_TextChanged(object sender, EventArgs e)\r
1085         {\r
1086             try\r
1087             {\r
1088                 if (text_height.Text != "Auto")\r
1089                 {\r
1090                     if (CheckPixelRatio.Checked)\r
1091                     {\r
1092                         text_height.Text = "";\r
1093                         text_width.BackColor = Color.White;\r
1094                     }\r
1095                     else\r
1096                     {\r
1097                         if ((int.Parse(text_height.Text) % 16) != 0)\r
1098                         {\r
1099                             text_height.BackColor = Color.LightCoral;\r
1100                         }\r
1101                         else\r
1102                         {\r
1103                             text_height.BackColor = Color.LightGreen;\r
1104                         }\r
1105                     }\r
1106                 }\r
1107             } catch(Exception){\r
1108                 // No need to alert the user.\r
1109             }\r
1110         }\r
1111 \r
1112         private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)\r
1113         {\r
1114             if ((string)drp_crop.SelectedItem == "Manual")\r
1115             {\r
1116             text_left.Enabled = true;\r
1117             text_right.Enabled = true;\r
1118             text_top.Enabled = true;\r
1119             text_bottom.Enabled = true;\r
1120             }\r
1121 \r
1122             if ((string)drp_crop.SelectedItem == "Auto Crop")\r
1123             {\r
1124                 text_left.Enabled = false;\r
1125                 text_right.Enabled = false;\r
1126                 text_top.Enabled = false;\r
1127                 text_bottom.Enabled = false;\r
1128                 text_left.Text = "";\r
1129                 text_right.Text = "";\r
1130                 text_top.Text = "";\r
1131                 text_bottom.Text = "";\r
1132 \r
1133                 if (lbl_RecomendedCrop.Text != "Select a Title")\r
1134                 {\r
1135                     string[] temp = new string[4];\r
1136                     temp = lbl_RecomendedCrop.Text.Split('/');\r
1137                     text_left.Text = temp[2];\r
1138                     text_right.Text = temp[3];\r
1139                     text_top.Text = temp[0];\r
1140                     text_bottom.Text = temp[1];\r
1141                 }\r
1142             }\r
1143 \r
1144             if ((string)drp_crop.SelectedItem == "No Crop")\r
1145             {\r
1146                 text_left.Enabled = false;\r
1147                 text_right.Enabled = false;\r
1148                 text_top.Enabled = false;\r
1149                 text_bottom.Enabled = false;\r
1150                 text_left.Text = "0";\r
1151                 text_right.Text = "0";\r
1152                 text_top.Text = "0";\r
1153                 text_bottom.Text = "0";\r
1154 \r
1155             }\r
1156         }\r
1157         \r
1158         private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)\r
1159         {\r
1160             text_width.Text = "";\r
1161             text_height.Text = "";\r
1162             text_width.BackColor = Color.White;\r
1163             text_height.BackColor = Color.White;\r
1164         }\r
1165 \r
1166         private void drp_dvdtitle_Click(object sender, EventArgs e)\r
1167         {\r
1168             if (drp_dvdtitle.Items.Count == 0)\r
1169             {\r
1170                 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
1171             }\r
1172         }\r
1173 \r
1174         private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)\r
1175         {\r
1176 \r
1177             //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch\r
1178 \r
1179             drp_audioMixDown.Items.Clear();\r
1180 \r
1181             if (drp_audioCodec.Text == "AAC")\r
1182             {\r
1183                 drp_audioMixDown.Items.Clear();\r
1184                 drp_audioMixDown.Items.Add("Mono");\r
1185                 drp_audioMixDown.Items.Add("Stereo");\r
1186                 drp_audioMixDown.Items.Add("Dolby Surround");\r
1187                 drp_audioMixDown.Items.Add("Dolby Pro Logic II");\r
1188                 drp_audioMixDown.Items.Add("6 Channel Discrete");\r
1189                 \r
1190                 drp_audioBitrate.Items.Clear();\r
1191                 drp_audioBitrate.Items.Add("32");\r
1192                 drp_audioBitrate.Items.Add("40");\r
1193                 drp_audioBitrate.Items.Add("48");\r
1194                 drp_audioBitrate.Items.Add("56");\r
1195                 drp_audioBitrate.Items.Add("64");\r
1196                 drp_audioBitrate.Items.Add("80");\r
1197                 drp_audioBitrate.Items.Add("86");\r
1198                 drp_audioBitrate.Items.Add("112");\r
1199                 drp_audioBitrate.Items.Add("128");\r
1200                 drp_audioBitrate.Items.Add("160");\r
1201 \r
1202             }\r
1203             else\r
1204             {\r
1205                 drp_audioMixDown.Items.Clear();\r
1206                 drp_audioMixDown.Items.Add("Stereo");\r
1207                 drp_audioMixDown.Items.Add("Dolby Surround");\r
1208                 drp_audioMixDown.Items.Add("Dolby Pro Logic II");\r
1209 \r
1210                 drp_audioBitrate.Items.Clear();\r
1211                 drp_audioBitrate.Items.Add("32");\r
1212                 drp_audioBitrate.Items.Add("40");\r
1213                 drp_audioBitrate.Items.Add("48");\r
1214                 drp_audioBitrate.Items.Add("56");\r
1215                 drp_audioBitrate.Items.Add("64");\r
1216                 drp_audioBitrate.Items.Add("80");\r
1217                 drp_audioBitrate.Items.Add("86");\r
1218                 drp_audioBitrate.Items.Add("112");\r
1219                 drp_audioBitrate.Items.Add("128");\r
1220                 drp_audioBitrate.Items.Add("160");\r
1221                 drp_audioBitrate.Items.Add("192");\r
1222                 drp_audioBitrate.Items.Add("224");\r
1223                 drp_audioBitrate.Items.Add("256");\r
1224                 drp_audioBitrate.Items.Add("320");\r
1225             }\r
1226         }\r
1227 \r
1228         private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)\r
1229         {\r
1230             if (drp_audioCodec.Text == "AAC")\r
1231             {\r
1232                 if (drp_audioMixDown.Text == "6 Channel Discrete")\r
1233                 {\r
1234 \r
1235                     drp_audioBitrate.Items.Clear();\r
1236                     drp_audioBitrate.Items.Add("32");\r
1237                     drp_audioBitrate.Items.Add("40");\r
1238                     drp_audioBitrate.Items.Add("48");\r
1239                     drp_audioBitrate.Items.Add("56");\r
1240                     drp_audioBitrate.Items.Add("64");\r
1241                     drp_audioBitrate.Items.Add("80");\r
1242                     drp_audioBitrate.Items.Add("86");\r
1243                     drp_audioBitrate.Items.Add("112");\r
1244                     drp_audioBitrate.Items.Add("128");\r
1245                     drp_audioBitrate.Items.Add("160");\r
1246                     drp_audioBitrate.Items.Add("192");\r
1247                     drp_audioBitrate.Items.Add("224");\r
1248                     drp_audioBitrate.Items.Add("256");\r
1249                     drp_audioBitrate.Items.Add("320");\r
1250                     drp_audioBitrate.Items.Add("384");\r
1251                 }\r
1252             }\r
1253         }\r
1254 \r
1255         private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)\r
1256         {\r
1257             if (Check_ChapterMarkers.Checked)\r
1258             {\r
1259                 string destination = text_destination.Text;\r
1260                 destination = destination.Replace(".mp4", ".m4v");\r
1261                 text_destination.Text = destination;\r
1262             }\r
1263             else\r
1264             {\r
1265                 string destination = text_destination.Text;\r
1266                 destination = destination.Replace(".m4v", ".mp4");\r
1267                 text_destination.Text = destination;\r
1268             }\r
1269         }\r
1270 \r
1271         private void check_largeFile_CheckedChanged(object sender, EventArgs e)\r
1272         {\r
1273             if (!text_destination.Text.Contains(".mp4"))\r
1274             {\r
1275                 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
1276                 check_largeFile.CheckState = CheckState.Unchecked;\r
1277             }\r
1278         }\r
1279 \r
1280         private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)\r
1281         {\r
1282             //Turn off some options which are H.264 only when the user selects a non h.264 encoder\r
1283             if (!drp_videoEncoder.Text.Contains("H.264"))\r
1284             {\r
1285                 check_turbo.CheckState = CheckState.Unchecked;\r
1286                 CheckCRF.CheckState = CheckState.Unchecked;\r
1287                 CheckCRF.Enabled = false;\r
1288                 check_turbo.Enabled = false;\r
1289                 h264Tab.Enabled = false;\r
1290             }\r
1291             else\r
1292             {\r
1293                 CheckCRF.Enabled = true;\r
1294                 check_turbo.Enabled = true;\r
1295                 h264Tab.Enabled = true;\r
1296             }\r
1297 \r
1298         }\r
1299 \r
1300         public void setStreamReader(Parsing.DVD dvd)\r
1301         {\r
1302             this.thisDVD = dvd;\r
1303         }\r
1304 \r
1305         private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)\r
1306         {\r
1307             // Reset some values on the form\r
1308             lbl_Aspect.Text = "Select a Title";\r
1309             lbl_RecomendedCrop.Text = "Select a Title";\r
1310             drop_chapterStart.Items.Clear();\r
1311             drop_chapterFinish.Items.Clear();\r
1312             QueryEditorText.Text = "";\r
1313 \r
1314             // If the dropdown is set to automatic nothing else needs to be done.\r
1315             // Otheriwse if its not, title data has to be loased from parsing.\r
1316             if (drp_dvdtitle.Text != "Automatic")\r
1317             {\r
1318                 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;\r
1319 \r
1320                 // Set the Aspect Ratio\r
1321                 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();\r
1322 \r
1323                 // Set the Recommended Cropping values\r
1324                 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);\r
1325                 \r
1326                 // Populate the Start chapter Dropdown\r
1327                 drop_chapterStart.Items.Clear();\r
1328                 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());\r
1329                 if (drop_chapterStart.Items.Count > 0)\r
1330                 {\r
1331                     drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();\r
1332                 }\r
1333 \r
1334                 // Populate the Final Chapter Dropdown\r
1335                 drop_chapterFinish.Items.Clear();\r
1336                 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());\r
1337                 if (drop_chapterFinish.Items.Count > 0)\r
1338                 {\r
1339                     drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();\r
1340                 }\r
1341 \r
1342                 // Populate the Audio Channels Dropdown\r
1343                 drp_audioChannels.Items.Clear();\r
1344                 drp_audioChannels.Items.Add("Automatic");\r
1345                 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());\r
1346                 if (drp_audioChannels.Items.Count > 0)\r
1347                 {\r
1348                     drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();\r
1349                 }\r
1350 \r
1351                 // Populate the Subtitles dropdown\r
1352                 drp_subtitle.Items.Clear();\r
1353                 drp_subtitle.Items.Add("None");\r
1354                 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());\r
1355                 if (drp_subtitle.Items.Count > 0)\r
1356                 {\r
1357                     drp_subtitle.Text = drp_subtitle.Items[0].ToString();\r
1358                 }\r
1359             }\r
1360         }\r
1361 \r
1362         #endregion\r
1363 \r
1364         //---------------------------------------------------\r
1365         //  Some Functions\r
1366         //  - Query Generation\r
1367         //---------------------------------------------------\r
1368 \r
1369         #region Program Functions\r
1370 \r
1371         public string GenerateTheQuery()\r
1372         {\r
1373             string source = text_source.Text;\r
1374             string dvdTitle = drp_dvdtitle.Text;\r
1375             string chapterStart = drop_chapterStart.Text;\r
1376             string chapterFinish = drop_chapterFinish.Text;\r
1377             int totalChapters = drop_chapterFinish.Items.Count - 1;\r
1378             string dvdChapter = "";\r
1379 \r
1380             if (source ==  "")\r
1381                 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
1382             else\r
1383             {\r
1384                 source = " -i " + '"' + source+ '"'; //'"'+\r
1385             }\r
1386 \r
1387             if (dvdTitle ==  "Automatic")\r
1388                 dvdTitle = "";\r
1389             else\r
1390             {\r
1391                 string[] titleInfo = dvdTitle.Split(' ');\r
1392                 dvdTitle = " -t "+ titleInfo[0];\r
1393             }\r
1394 \r
1395             if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))\r
1396                 dvdChapter = "";\r
1397             else if (chapterFinish == chapterStart)\r
1398                 dvdChapter = " -c " + chapterStart;\r
1399             else\r
1400                 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;\r
1401 \r
1402             string querySource = source+ dvdTitle+ dvdChapter;\r
1403             // ----------------------------------------------------------------------\r
1404 \r
1405             // Destination\r
1406 \r
1407             string destination = text_destination.Text;\r
1408             string videoEncoder = drp_videoEncoder.Text;\r
1409             string audioEncoder = drp_audioCodec.Text;\r
1410             string width = text_width.Text;\r
1411             string height = text_height.Text;\r
1412 \r
1413             if (destination ==  "")\r
1414                 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
1415             else\r
1416                 destination = " -o " + '"' + destination + '"'; //'"'+ \r
1417 \r
1418 \r
1419             switch (videoEncoder)\r
1420             {\r
1421                 case "Mpeg 4":\r
1422                     videoEncoder = " -e ffmpeg";\r
1423                     break;\r
1424                 case "Xvid":\r
1425                     videoEncoder = " -e xvid";\r
1426                     break;\r
1427                 case "H.264":\r
1428                     videoEncoder = " -e x264";\r
1429                     break;\r
1430                 case "H.264 Baseline 1.3":\r
1431                     videoEncoder = " -e x264b13";\r
1432                     break;\r
1433                 case "H.264 (iPod)":\r
1434                     videoEncoder = " -e x264b30";\r
1435                     break;\r
1436                 default:\r
1437                     videoEncoder = " -e x264";\r
1438                     break;\r
1439             }\r
1440            \r
1441             switch (audioEncoder)\r
1442             {\r
1443                 case "AAC":\r
1444                     audioEncoder = " -E faac";\r
1445                     break;\r
1446                 case "MP3":\r
1447                     audioEncoder = " -E lame";\r
1448                     break;\r
1449                 case "Vorbis":\r
1450                     audioEncoder = " -E vorbis";\r
1451                     break;\r
1452                 case "AC3":\r
1453                     audioEncoder = " -E ac3";\r
1454                     break;\r
1455                 default:\r
1456                     audioEncoder = " -E faac";\r
1457                     break;\r
1458             }\r
1459 \r
1460             if (width !=  "")\r
1461                 width = " -w "+ width;\r
1462 \r
1463 \r
1464             if (height == "Auto")\r
1465             {\r
1466                 height = "";\r
1467             }\r
1468             else if (height != "")\r
1469             {\r
1470                 height = " -l " + height;\r
1471             }\r
1472             \r
1473 \r
1474             string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;\r
1475             // ----------------------------------------------------------------------\r
1476 \r
1477             // Picture Settings Tab\r
1478 \r
1479             string cropSetting = drp_crop.Text;\r
1480             string cropTop = text_top.Text;\r
1481             string cropBottom = text_bottom.Text;\r
1482             string cropLeft = text_left.Text;\r
1483             string cropRight = text_right.Text;\r
1484             string subtitles = drp_subtitle.Text;\r
1485             string cropOut = "";\r
1486             string deInterlace_Option = drp_deInterlace_option.Text;\r
1487             string deinterlace = "";\r
1488             string grayscale = "";\r
1489             string pixelRatio = "";\r
1490             string ChapterMarkers = "";\r
1491             // Returns Crop Query\r
1492 \r
1493             if (cropSetting == "Auto Crop")\r
1494                 cropOut = "";\r
1495             else if (cropSetting == "No Crop")\r
1496                 cropOut = " --crop 0:0:0:0 ";\r
1497             else\r
1498             {\r
1499                 if (text_top.Text == "")\r
1500                     cropTop = "0";\r
1501                 if (text_bottom.Text == "")\r
1502                     cropBottom = "0";\r
1503                 if (text_left.Text == "")\r
1504                     cropLeft = "0";\r
1505                 if (text_right.Text == "")\r
1506                     cropRight = "0";\r
1507 \r
1508                 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;\r
1509             }\r
1510 \r
1511             if (subtitles ==  "None")\r
1512                 subtitles = "";\r
1513             else if (subtitles ==  "")\r
1514                 subtitles = "";\r
1515             else\r
1516             {\r
1517                 string[] tempSub;\r
1518                 tempSub = subtitles.Split(' ');\r
1519                 subtitles = " -s "+ tempSub[0];\r
1520             }\r
1521 \r
1522             switch (deInterlace_Option)\r
1523             {\r
1524                 case "None":\r
1525                     deinterlace = "";\r
1526                     break;\r
1527                 case "Origional (Fast)":\r
1528                     deinterlace = " --deinterlace=1";\r
1529                     break;\r
1530                 case "yadif (Slow)":\r
1531                     deinterlace = " --deinterlace=" + '"' + "0" + '"';\r
1532                     break;\r
1533                 case "yadif + mcdeint (Slower)":\r
1534                     deinterlace = " --deinterlace=" + '"' + "2:-1:1" + '"';\r
1535                     break;\r
1536                 case "yadif + mcdeint (Slowest)":\r
1537                     deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';\r
1538                     break;\r
1539                 default:\r
1540                     deinterlace = "";\r
1541                     break;\r
1542             }\r
1543 \r
1544             if (check_grayscale.Checked)\r
1545                 grayscale = " -g ";\r
1546 \r
1547             if (CheckPixelRatio.Checked)\r
1548                 pixelRatio = " -p ";\r
1549 \r
1550             if (Check_ChapterMarkers.Checked)\r
1551                 ChapterMarkers = " -m ";\r
1552 \r
1553             string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;\r
1554             // ----------------------------------------------------------------------\r
1555 \r
1556             // Video Settings Tab\r
1557 \r
1558             string videoBitrate = text_bitrate.Text;\r
1559             string videoFilesize = text_filesize.Text;\r
1560             double videoQuality = slider_videoQuality.Value;\r
1561             string vidQSetting = "";\r
1562             string twoPassEncoding = "";\r
1563             string videoFramerate = drp_videoFramerate.Text;\r
1564             string turboH264 = "";\r
1565             string largeFile = "";\r
1566             string deblock = "";\r
1567             string detelecine = "";\r
1568             string denoise = "";\r
1569             string CRF = CheckCRF.CheckState.ToString();\r
1570 \r
1571 \r
1572             if ((CRF == "Checked"))\r
1573                 CRF = " -Q ";\r
1574             else\r
1575                 CRF = "";\r
1576 \r
1577             if (videoBitrate !=  "")\r
1578                 videoBitrate = " -b "+ videoBitrate;\r
1579 \r
1580             if (videoFilesize !=  "")\r
1581                 videoFilesize = " -S "+ videoFilesize;\r
1582 \r
1583             // Video Quality Setting\r
1584 \r
1585             if ((videoQuality ==  0))\r
1586                 vidQSetting = "";\r
1587             else\r
1588             {\r
1589                 videoQuality = videoQuality / 100;\r
1590                 if (videoQuality ==  1)\r
1591                 {\r
1592                     vidQSetting = "1.0";\r
1593                 }\r
1594 \r
1595                 vidQSetting = " -q " + videoQuality.ToString();\r
1596             }\r
1597 \r
1598             if (check_2PassEncode.Checked)\r
1599                 twoPassEncoding = " -2 ";\r
1600 \r
1601             if (videoFramerate ==  "Automatic")\r
1602                 videoFramerate = "";\r
1603             else\r
1604                 videoFramerate = " -r "+ videoFramerate;\r
1605 \r
1606             if (check_turbo.Checked)\r
1607                 turboH264 = " -T ";\r
1608 \r
1609             if (check_largeFile.Checked)\r
1610                 largeFile = " -4 ";\r
1611 \r
1612             if (check_deblock.Checked)\r
1613                 deblock = " --deblock";\r
1614 \r
1615             if (check_detelecine.Checked)\r
1616                 detelecine = " --detelecine";\r
1617 \r
1618             switch (drp_deNoise.Text)\r
1619             {\r
1620                 case "None":\r
1621                     denoise = "";\r
1622                     break;\r
1623                 case "Weak":\r
1624                     denoise = " --denoise=2:1:2:3";\r
1625                     break;\r
1626                 case "Medium":\r
1627                     denoise = " --denoise=3:2:2:3";\r
1628                     break;\r
1629                 case "Strong":\r
1630                     denoise = " --denoise=7:7:5:5";\r
1631                     break;\r
1632                 default:\r
1633                     denoise = "";\r
1634                     break;\r
1635             }\r
1636 \r
1637             string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;\r
1638             // ----------------------------------------------------------------------\r
1639 \r
1640             // Audio Settings Tab\r
1641 \r
1642             string audioBitrate = drp_audioBitrate.Text;\r
1643             string audioSampleRate = drp_audioSampleRate.Text;\r
1644             string audioChannels = drp_audioChannels.Text;\r
1645             string Mixdown = drp_audioMixDown.Text;\r
1646             string SixChannelAudio = "";\r
1647 \r
1648             if (audioBitrate !=  "")\r
1649                 audioBitrate = " -B "+ audioBitrate;\r
1650 \r
1651             if (audioSampleRate !=  "")\r
1652                 audioSampleRate = " -R "+ audioSampleRate;\r
1653 \r
1654             if (audioChannels ==  "Automatic")\r
1655                 audioChannels = "";\r
1656             else if (audioChannels ==  "")\r
1657                 audioChannels = "";\r
1658             else\r
1659             {\r
1660                 string[] tempSub;\r
1661                 tempSub = audioChannels.Split(' ');\r
1662                 audioChannels = " -a "+ tempSub[0];\r
1663             }\r
1664 \r
1665             switch (Mixdown)\r
1666             {\r
1667                 case "Automatic":\r
1668                     Mixdown = "";\r
1669                     break;\r
1670                 case "Mono":\r
1671                     Mixdown = "mono";\r
1672                     break;\r
1673                 case "Stereo":\r
1674                     Mixdown = "stereo";\r
1675                     break;\r
1676                 case "Dolby Surround":\r
1677                     Mixdown = "dpl1";\r
1678                     break;\r
1679                 case "Dolby Pro Logic II":\r
1680                     Mixdown = "dpl2";\r
1681                     break;\r
1682                 case "6 Channel Discrete":\r
1683                     Mixdown = "6ch";\r
1684                     break;\r
1685                 default:\r
1686                     Mixdown = "stero";\r
1687                     break;\r
1688             }\r
1689 \r
1690             if (Mixdown !=  "")\r
1691                 SixChannelAudio = " -6 "+ Mixdown;\r
1692             else\r
1693                 SixChannelAudio = "";\r
1694 \r
1695             string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;\r
1696             // ----------------------------------------------------------------------\r
1697 \r
1698             //  H.264 Tab\r
1699 \r
1700             \r
1701             string h264Advanced = rtf_h264advanced.Text;\r
1702             \r
1703             if ((h264Advanced ==  ""))\r
1704                 h264Advanced = "";\r
1705             else\r
1706                 h264Advanced = " -x "+ h264Advanced;\r
1707     \r
1708 \r
1709             string h264Settings = h264Advanced;\r
1710             // ----------------------------------------------------------------------\r
1711 \r
1712             // Processors (Program Settings)\r
1713 \r
1714             string processors = Properties.Settings.Default.Processors;\r
1715             //  Number of Processors Handler\r
1716 \r
1717             if (processors ==  "Automatic")\r
1718                 processors = "";\r
1719             else\r
1720                 processors = " -C "+ processors+ " ";\r
1721 \r
1722 \r
1723             string queryAdvancedSettings = processors;\r
1724             // ----------------------------------------------------------------------\r
1725 \r
1726             //  Verbose option (Program Settings)\r
1727 \r
1728             string verbose = "";\r
1729             if (Properties.Settings.Default.verbose ==  "Checked")\r
1730                 verbose = " -v ";\r
1731 \r
1732             // ----------------------------------------------------------------------\r
1733 \r
1734             return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;\r
1735         }\r
1736 \r
1737         #endregion\r
1738 \r
1739 \r
1740         // This is the END of the road ------------------------------------------------------------------------------\r
1741     }\r
1742 }\r