OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / frmMain.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.ComponentModel;\r
4 using System.Data;\r
5 using System.Drawing;\r
6 using System.Text;\r
7 using System.Windows.Forms;\r
8 using System.Net;\r
9 \r
10 namespace Handbrake\r
11 {\r
12     public partial class frmMain : Form\r
13     {\r
14         public frmMain()\r
15         {\r
16             InitializeComponent();\r
17         }\r
18 \r
19         // --------------------------------------------------------------\r
20         // onLoad - setup the program ready for use.\r
21         // --------------------------------------------------------------\r
22         private void frmMain_Load(object sender, EventArgs e)\r
23         {\r
24             // Set the Version number lable to the corect version.\r
25             Version.Text = "Version " + Properties.Settings.Default.GuiVersion;\r
26 \r
27             // Run the update checker.\r
28             updateCheck();\r
29 \r
30             // Now load the users default if required.\r
31             loadUserDefaults();\r
32             \r
33         }\r
34 \r
35         public void loadUserDefaults()\r
36         { \r
37             try\r
38             {\r
39                 if (Properties.Settings.Default.defaultSettings == "Checked")\r
40                 {\r
41                     //Source\r
42                     text_source.Text = Properties.Settings.Default.DVDSource;\r
43                     drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;\r
44                     drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;\r
45                     drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;\r
46                     //Destination\r
47                     text_destination.Text = Properties.Settings.Default.VideoDest;\r
48                     drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;\r
49                     drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;\r
50                     text_width.Text = Properties.Settings.Default.Width;\r
51                     text_height.Text = Properties.Settings.Default.Height;\r
52                     //Picture Settings Tab\r
53                     drp_crop.Text = Properties.Settings.Default.CroppingOption;\r
54                     text_top.Text = Properties.Settings.Default.CropTop;\r
55                     text_bottom.Text = Properties.Settings.Default.CropBottom;\r
56                     text_left.Text = Properties.Settings.Default.CropLeft;\r
57                     text_right.Text = Properties.Settings.Default.CropRight;\r
58                     drp_subtitle.Text = Properties.Settings.Default.Subtitles;\r
59                     //Video Settings Tab\r
60                     text_bitrate.Text = Properties.Settings.Default.VideoBitrate;\r
61                     text_filesize.Text = Properties.Settings.Default.VideoFilesize;\r
62                     slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;\r
63                     if (Properties.Settings.Default.TwoPass == "Checked")\r
64                     {\r
65                         check_2PassEncode.CheckState = CheckState.Checked;\r
66                     }\r
67                     if (Properties.Settings.Default.DeInterlace == "Checked")\r
68                     {\r
69                         check_DeInterlace.CheckState = CheckState.Checked;\r
70                     }\r
71                     if (Properties.Settings.Default.Grayscale == "Checked")\r
72                     {\r
73                         check_grayscale.CheckState = CheckState.Checked;\r
74                     }\r
75 \r
76                     drp_videoFramerate.Text = Properties.Settings.Default.Framerate;\r
77 \r
78                     if (Properties.Settings.Default.PixelRatio == "Checked")\r
79                     {\r
80                         CheckPixelRatio.CheckState = CheckState.Checked;\r
81                     }\r
82                     if (Properties.Settings.Default.turboFirstPass == "Checked")\r
83                     {\r
84                         check_turbo.CheckState = CheckState.Checked;\r
85                     }\r
86                     if (Properties.Settings.Default.largeFile == "Checked")\r
87                     {\r
88                         check_largeFile.CheckState = CheckState.Checked;\r
89                     }\r
90                     //Audio Settings Tab\r
91                     drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;\r
92                     drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;\r
93                     drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;\r
94                     //H264 Tab\r
95                     if (Properties.Settings.Default.CRF == "Checked")\r
96                     {\r
97                         CheckCRF.CheckState = CheckState.Checked;\r
98                     }\r
99                     rtf_h264advanced.Text = Properties.Settings.Default.H264;\r
100                 }\r
101             }\r
102             catch (Exception)\r
103             {\r
104                 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.\r
105             }\r
106         }\r
107 \r
108         public void updateCheck()\r
109         {\r
110             if (Properties.Settings.Default.updateStatus == "Checked")\r
111             {\r
112 \r
113                 try\r
114                 {\r
115                     String updateFile = Properties.Settings.Default.updateFile;\r
116                     WebClient client = new WebClient();\r
117                     String data = client.DownloadString(updateFile);\r
118                     String[] versionData = data.Split('\n');\r
119 \r
120                     if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))\r
121                     {\r
122                         lbl_update.Visible = true;\r
123                     }\r
124                 }\r
125                 //else fail displaying an error message.\r
126                 catch (Exception)\r
127                 {\r
128                     //Silently ignore the error\r
129                 }\r
130             }\r
131         }\r
132 \r
133 \r
134 \r
135         // --------------------------------------------------------------\r
136         // The Menu Bar\r
137         // --------------------------------------------------------------\r
138 \r
139         // FILE MENU --------------------------------------------------------------\r
140         private void mnu_open_Click(object sender, EventArgs e)\r
141         {\r
142             File_Open.ShowDialog();\r
143         }\r
144         private void mnu_save_Click(object sender, EventArgs e)\r
145         {\r
146             File_Save.ShowDialog();\r
147         }\r
148 \r
149         private void mnu_update_Click(object sender, EventArgs e)\r
150         {\r
151             Form Update = new frmUpdate();\r
152             Update.Show();\r
153         }\r
154 \r
155         private void mnu_exit_Click(object sender, EventArgs e)\r
156         {\r
157             this.Close();\r
158         }\r
159 \r
160         // TOOLS MENU --------------------------------------------------------------\r
161         private void mnu_encode_Click(object sender, EventArgs e)\r
162         {\r
163             Form Queue = new frmQueue();\r
164             Queue.Show();\r
165         }\r
166 \r
167         private void mnu_viewDVDdata_Click(object sender, EventArgs e)\r
168         {\r
169             Form DVDData = new frmDVDData();\r
170             DVDData.Show();\r
171         }\r
172 \r
173         private void mnu_options_Click(object sender, EventArgs e)\r
174         {\r
175             Form Options = new frmOptions();\r
176             Options.Show();\r
177         }\r
178 \r
179         // PRESETS MENU --------------------------------------------------------------\r
180         private void mnu_preset_ipod133_Click(object sender, EventArgs e)\r
181         {\r
182             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
183             text_width.Text = "640";\r
184             text_height.Text = "480";\r
185             drp_videoEncoder.Text = "H.264 (iPod)";\r
186             text_bitrate.Text = "1000";\r
187             text_filesize.Text = "";\r
188             slider_videoQuality.Value = 0;\r
189             SliderValue.Text = "0%";\r
190             drp_audioBitrate.Text = "160";\r
191             rtf_h264advanced.Text = "";\r
192             drp_crop.Text = "No Crop";\r
193         }\r
194 \r
195         private void mnu_preset_ipod178_Click(object sender, EventArgs e)\r
196         {\r
197             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
198             text_width.Text = "640";\r
199             text_height.Text = "352";\r
200             drp_videoEncoder.Text = "H.264 (iPod)";\r
201             text_bitrate.Text = "1000";\r
202             text_filesize.Text = "";\r
203             slider_videoQuality.Value = 0;\r
204             SliderValue.Text = "0%";\r
205             drp_audioBitrate.Text = "160";\r
206             rtf_h264advanced.Text = "";\r
207             drp_crop.Text = "No Crop";\r
208         }\r
209 \r
210         private void mnu_preset_ipod235_Click(object sender, EventArgs e)\r
211         {\r
212             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
213             text_width.Text = "640";\r
214             text_height.Text = "272";\r
215             drp_videoEncoder.Text = "H.264 (iPod)";\r
216             text_bitrate.Text = "1000";\r
217             text_filesize.Text = "";\r
218             slider_videoQuality.Value = 0;\r
219             SliderValue.Text = "0%";\r
220             drp_audioBitrate.Text = "160";\r
221             rtf_h264advanced.Text = "";\r
222             drp_crop.Text = "No Crop";\r
223         }\r
224 \r
225         private void mnu_appleTv_Click(object sender, EventArgs e)\r
226         {\r
227             text_width.Text = "";\r
228             text_height.Text = "";\r
229             drp_videoEncoder.Text = "H.264";\r
230             text_bitrate.Text = "3000";\r
231             text_filesize.Text = "";\r
232             slider_videoQuality.Value = 0;\r
233             SliderValue.Text = "0%";\r
234             drp_audioBitrate.Text = "160";\r
235             CheckPixelRatio.CheckState = CheckState.Checked;\r
236             drp_audioSampleRate.Text = "48";\r
237             rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";\r
238             drp_crop.Text = "No Crop";\r
239             \r
240         }\r
241 \r
242         private void mnu_presetPS3_Click(object sender, EventArgs e)\r
243         {\r
244             CheckPixelRatio.CheckState = CheckState.Unchecked;\r
245             text_width.Text = "";\r
246             text_height.Text = "";\r
247             drp_videoEncoder.Text = "H.264";\r
248             text_bitrate.Text = "3000";\r
249             text_filesize.Text = "";\r
250             slider_videoQuality.Value = 0;\r
251             SliderValue.Text = "0%";\r
252             drp_audioBitrate.Text = "160";\r
253             CheckPixelRatio.CheckState = CheckState.Checked;\r
254             drp_audioSampleRate.Text = "48";\r
255             rtf_h264advanced.Text = "level=41";\r
256             drp_crop.Text = "No Crop";\r
257         }\r
258 \r
259         private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)\r
260         {\r
261             //Source\r
262             Properties.Settings.Default.DVDSource = text_source.Text;\r
263             Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;\r
264             Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;\r
265             Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;\r
266             //Destination\r
267             Properties.Settings.Default.VideoDest = text_destination.Text;\r
268             Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;\r
269             Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;\r
270             Properties.Settings.Default.Width = text_width.Text;\r
271             Properties.Settings.Default.Height = text_height.Text;\r
272             //Picture Settings Tab\r
273             Properties.Settings.Default.CroppingOption = drp_crop.Text;\r
274             Properties.Settings.Default.CropTop = text_top.Text;\r
275             Properties.Settings.Default.CropBottom = text_bottom.Text;\r
276             Properties.Settings.Default.CropLeft = text_left.Text;\r
277             Properties.Settings.Default.CropRight = text_right.Text;\r
278             Properties.Settings.Default.Subtitles = drp_subtitle.Text;\r
279             //Video Settings Tab\r
280             Properties.Settings.Default.VideoBitrate = text_bitrate.Text;\r
281             Properties.Settings.Default.VideoFilesize = text_filesize.Text;\r
282             Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;\r
283             Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();\r
284             Properties.Settings.Default.DeInterlace = check_DeInterlace.CheckState.ToString();\r
285             Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();\r
286             Properties.Settings.Default.Framerate = drp_videoFramerate.Text;\r
287             Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();\r
288             Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();\r
289             Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();\r
290             //Audio Settings Tab\r
291             Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;\r
292             Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;\r
293             Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;\r
294             //H264 Tab\r
295             Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();\r
296             Properties.Settings.Default.H264 = rtf_h264advanced.Text;\r
297             Properties.Settings.Default.Save();\r
298         }\r
299 \r
300         // Help Menu --------------------------------------------------------------\r
301         private void mnu_wiki_Click(object sender, EventArgs e)\r
302         {\r
303             System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac");\r
304         }\r
305 \r
306         private void mnu_onlineDocs_Click(object sender, EventArgs e)\r
307         {\r
308             System.Diagnostics.Process.Start("http://handbrake.m0k.org/?page_id=11");\r
309         }\r
310 \r
311         private void mnu_faq_Click(object sender, EventArgs e)\r
312         {\r
313             System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");\r
314         }\r
315 \r
316         private void mnu_homepage_Click(object sender, EventArgs e)\r
317         {\r
318             System.Diagnostics.Process.Start("http://handbrake.m0k.org");\r
319         }\r
320 \r
321         private void mnu_forum_Click(object sender, EventArgs e)\r
322         {\r
323             System.Diagnostics.Process.Start("http://handbrake.m0k.org/forum");\r
324         }\r
325 \r
326         private void mnu_about_Click(object sender, EventArgs e)\r
327         {\r
328                         Form About = new frmAbout();\r
329             About.Show();\r
330         }\r
331 \r
332 \r
333 \r
334         // -------------------------------------------------------------- \r
335         // Buttons on the main Window\r
336         // --------------------------------------------------------------\r
337         private void btn_Browse_Click(object sender, EventArgs e)\r
338         {\r
339             String filename ="";\r
340             text_source.Text = "";\r
341 \r
342             if (RadioDVD.Checked)\r
343             {\r
344                 DVD_Open.ShowDialog();\r
345                 filename = DVD_Open.SelectedPath;\r
346                 if (filename != "")\r
347                 {\r
348                     text_source.Text = filename;\r
349                     Form frmReadDVD = new frmReadDVD(filename);\r
350                     frmReadDVD.Show();\r
351                 }\r
352 \r
353             }\r
354             else\r
355             {\r
356                 ISO_Open.ShowDialog();\r
357                 filename = ISO_Open.FileName;\r
358                 if (filename != "")\r
359                 {\r
360                     text_source.Text = filename;\r
361                     Form frmReadDVD = new frmReadDVD(filename);\r
362                     frmReadDVD.Show();\r
363                 }\r
364 \r
365             }\r
366 \r
367                 \r
368         }\r
369 \r
370         private void btn_destBrowse_Click(object sender, EventArgs e)\r
371         {\r
372             // TODO: Need to write some code to check if there is a reasonable amount of disk space left.\r
373 \r
374             DVD_Save.ShowDialog();\r
375             text_destination.Text = DVD_Save.FileName;\r
376         }\r
377 \r
378         private void btn_h264Clear_Click(object sender, EventArgs e)\r
379         {\r
380             rtf_h264advanced.Text = "";\r
381         }\r
382 \r
383         private void GenerateQuery_Click(object sender, EventArgs e)\r
384         {\r
385             String query = GenerateTheQuery();\r
386             QueryEditorText.Text = query;\r
387         }\r
388 \r
389         private void btn_ClearQuery_Click(object sender, EventArgs e)\r
390         {\r
391             QueryEditorText.Text = "";\r
392         }\r
393 \r
394         private void btn_queue_Click(object sender, EventArgs e)\r
395         {\r
396             Form Queue = new frmQueue();\r
397             Queue.Show();\r
398         }\r
399 \r
400         private void btn_encode_Click(object sender, EventArgs e)\r
401         {\r
402             String query = "";\r
403  \r
404             if (QueryEditorText.Text == "")\r
405             {\r
406                 query = GenerateTheQuery();\r
407                 MessageBox.Show(query);\r
408             }\r
409             else\r
410             {\r
411                 query = QueryEditorText.Text;\r
412             }\r
413 \r
414             System.Diagnostics.Process hbProc = new System.Diagnostics.Process();\r
415             hbProc.StartInfo.FileName = "hbcli.exe";\r
416             hbProc.StartInfo.Arguments = query;\r
417             hbProc.StartInfo.UseShellExecute = false;\r
418             hbProc.Start();\r
419             \r
420 \r
421             MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);\r
422        \r
423             // TODO: Need to write a bit of code here to do process monitoring.\r
424             // Note: hbProc.waitForExit will freeze the app, meaning one cannot add additional items to the queue during an encode.\r
425         }\r
426 \r
427         // -------------------------------------------------------------- \r
428         // Items that require actions on frmMain\r
429         // --------------------------------------------------------------\r
430 \r
431 \r
432         private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)\r
433         {\r
434             QueryEditorText.Text = "";\r
435             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
436             {\r
437                 int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
438                 int chapterStart = int.Parse(drop_chapterStart.Text);\r
439 \r
440                 try\r
441                 {\r
442                     if (chapterFinish < chapterStart)\r
443                     {\r
444                         MessageBox.Show("Invalid Chapter Range! - Final chapter can not be smaller than the starting chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
445                     }\r
446                 }\r
447                 catch (Exception)\r
448                 {\r
449                     MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
450                 }\r
451             }\r
452 \r
453             \r
454         }\r
455 \r
456         private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)\r
457         {\r
458             QueryEditorText.Text = "";\r
459             if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))\r
460             {\r
461                 int chapterFinish = int.Parse(drop_chapterFinish.Text);\r
462                 int chapterStart = int.Parse(drop_chapterStart.Text);\r
463 \r
464                 try\r
465                 {\r
466                     if (chapterFinish > chapterStart)\r
467                     {\r
468                         MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
469                     }\r
470                 }\r
471                 catch (Exception)\r
472                 {\r
473                     MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);\r
474                 }\r
475             }\r
476         }\r
477 \r
478         private void text_bitrate_TextChanged(object sender, EventArgs e)\r
479         {\r
480             text_filesize.Text = "";\r
481             slider_videoQuality.Value = 0;\r
482             SliderValue.Text = "0%";\r
483             CheckCRF.CheckState = CheckState.Unchecked;\r
484         }\r
485 \r
486         private void text_filesize_TextChanged(object sender, EventArgs e)\r
487         {\r
488             text_bitrate.Text = "";\r
489             slider_videoQuality.Value = 0;\r
490             SliderValue.Text = "0%";\r
491             CheckCRF.CheckState = CheckState.Unchecked;\r
492         }\r
493 \r
494         private void slider_videoQuality_Scroll(object sender, EventArgs e)\r
495         {\r
496             SliderValue.Text = slider_videoQuality.Value.ToString() + "%";\r
497             text_bitrate.Text = "";\r
498             text_filesize.Text = "";\r
499         }\r
500 \r
501         private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
502         {\r
503             System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");\r
504         }\r
505 \r
506 \r
507 \r
508 \r
509         //\r
510         // The Query Generation Function\r
511         //\r
512 \r
513 \r
514         // This function was imported from old vb.net version of this application.\r
515         // It could probably do with being cleaned up a good deal at some point\r
516         public string GenerateTheQuery()\r
517         {\r
518             string source = text_source.Text;\r
519             string dvdTitle = drp_dvdtitle.Text;\r
520             string chapterStart = drop_chapterStart.Text;\r
521             string chapterFinish = drop_chapterFinish.Text;\r
522             int totalChapters = drop_chapterFinish.Items.Count - 1;\r
523             string dvdChapter = "";\r
524 \r
525             if (source ==  "")\r
526             {\r
527                 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
528             }else{\r
529                 source = " -i " + '"' + source+ '"'; //'"'+\r
530             }\r
531 \r
532             if (dvdTitle ==  "Automatic")\r
533             {\r
534                 dvdTitle = "";\r
535             }else{\r
536                 string[] titleInfo = dvdTitle.Split(' ');\r
537                 dvdTitle = " -t "+ titleInfo[0];\r
538             }\r
539 \r
540 \r
541 \r
542 \r
543             if ((chapterFinish.Equals("Auto") && chapterStart.Equals("Auto")))\r
544             {\r
545                 dvdChapter = "";\r
546             }\r
547             else if (chapterFinish == chapterStart)\r
548             {\r
549                 dvdChapter = " -c " + chapterStart;\r
550             }\r
551 \r
552             else\r
553             {\r
554                 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;\r
555             }\r
556 \r
557             string querySource = source+ dvdTitle+ dvdChapter;\r
558             // ----------------------------------------------------------------------\r
559 \r
560             // Destination\r
561 \r
562             string destination = text_destination.Text;\r
563             string videoEncoder = drp_videoEncoder.Text;\r
564             string audioEncoder = drp_audioCodec.Text;\r
565             string width = text_width.Text;\r
566             string height = text_height.Text;\r
567             if ((destination ==  ""))\r
568             {\r
569                 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
570             }\r
571 \r
572             else\r
573             {\r
574                 destination = " -o " + '"' + destination + '"'; //'"'+ \r
575             }\r
576 \r
577             if ((videoEncoder ==  "Mpeg 4"))\r
578             {\r
579                 videoEncoder = " -e ffmpeg";\r
580             }\r
581 \r
582             else if ((videoEncoder ==  "Xvid"))\r
583             {\r
584                 videoEncoder = " -e xvid";\r
585             }\r
586 \r
587             else if ((videoEncoder ==  "H.264"))\r
588             {\r
589                 videoEncoder = " -e x264";\r
590             }\r
591 \r
592             else if ((videoEncoder ==  "H.264 Baseline 1.3"))\r
593             {\r
594                 videoEncoder = " -e x264b13";\r
595             }\r
596 \r
597             else if ((videoEncoder ==  "H.264 (iPod)"))\r
598             {\r
599                 videoEncoder = " -e x264b30";\r
600             }\r
601 \r
602             if ((audioEncoder ==  "AAC"))\r
603             {\r
604                 audioEncoder = " -E faac";\r
605             }\r
606 \r
607             else if ((audioEncoder ==  "MP3"))\r
608             {\r
609                 audioEncoder = " -E lame";\r
610             }\r
611 \r
612             else if ((audioEncoder ==  "Vorbis"))\r
613             {\r
614                 audioEncoder = " -E vorbis";\r
615             }\r
616 \r
617             else if ((audioEncoder ==  "AC3"))\r
618             {\r
619                 audioEncoder = " -E ac3";\r
620             }\r
621 \r
622             if ((width !=  ""))\r
623             {\r
624                 width = " -w "+ width;\r
625             }\r
626 \r
627             if ((height !=  ""))\r
628             {\r
629                 height = " -l "+ height;\r
630             }\r
631 \r
632             string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;\r
633             // ----------------------------------------------------------------------\r
634 \r
635             // Picture Settings Tab\r
636 \r
637             string cropSetting = drp_crop.Text;\r
638             string cropTop = text_top.Text;\r
639             string cropBottom = text_bottom.Text;\r
640             string cropLeft = text_left.Text;\r
641             string cropRight = text_right.Text;\r
642             string subtitles = drp_subtitle.Text;\r
643             string cropOut = "";\r
644             // Returns Crop Query\r
645 \r
646             if (cropSetting ==  "Auto Crop")\r
647             {\r
648                 cropOut = "";\r
649             }\r
650 \r
651             else if (cropSetting ==  "No Crop")\r
652             {\r
653                 cropOut = " --crop 0:0:0:0 ";\r
654             }\r
655 \r
656             else\r
657             {\r
658                 cropOut = " --crop "+ cropTop+ ":"+ cropBottom+ ":"+ cropLeft+ ":"+ cropRight;\r
659             }\r
660 \r
661             if ((subtitles ==  "None"))\r
662             {\r
663                 subtitles = "";\r
664             }\r
665 \r
666             else if ((subtitles ==  ""))\r
667             {\r
668                 subtitles = "";\r
669             }\r
670 \r
671             else\r
672             {\r
673                 string[] tempSub;\r
674                 tempSub = subtitles.Split(' ');\r
675                 subtitles = " -s "+ tempSub[0];\r
676             }\r
677 \r
678             string queryPictureSettings = cropOut+ subtitles;\r
679             // ----------------------------------------------------------------------\r
680 \r
681             // Video Settings Tab\r
682 \r
683             string videoBitrate = text_bitrate.Text;\r
684             string videoFilesize = text_filesize.Text;\r
685             int videoQuality = slider_videoQuality.Value;\r
686             string vidQSetting;\r
687             string twoPassEncoding = check_2PassEncode.CheckState.ToString();\r
688             string deinterlace = check_DeInterlace.CheckState.ToString();\r
689             string grayscale = check_grayscale.CheckState.ToString();\r
690             string videoFramerate = drp_videoFramerate.Text;\r
691             string pixelRatio = CheckPixelRatio.CheckState.ToString();\r
692             string ChapterMarkers = Check_ChapterMarkers.CheckState.ToString();\r
693             string turboH264 = check_turbo.CheckState.ToString();\r
694             string largeFile = check_largeFile.CheckState.ToString();\r
695 \r
696             if ((videoBitrate !=  ""))\r
697             {\r
698                 videoBitrate = " -b "+ videoBitrate;\r
699             }\r
700 \r
701             if ((videoFilesize !=  ""))\r
702             {\r
703                 videoFilesize = " -S "+ videoFilesize;\r
704             }\r
705 \r
706             // Video Quality Setting\r
707 \r
708             if ((videoQuality ==  0))\r
709             {\r
710                 vidQSetting = "";\r
711             }\r
712 \r
713             else\r
714             {\r
715                 videoQuality = videoQuality/ 100;\r
716                 if (videoQuality ==  1)\r
717                 {\r
718                     vidQSetting = "1.0";\r
719                 }\r
720 \r
721                 vidQSetting = " -q " + videoQuality.ToString();\r
722             }\r
723 \r
724             if ((twoPassEncoding ==  "1"))\r
725             {\r
726                 twoPassEncoding = " -2 ";\r
727             }\r
728 \r
729             else\r
730             {\r
731                 twoPassEncoding = "";\r
732             }\r
733 \r
734             if ((deinterlace ==  "1"))\r
735             {\r
736                 deinterlace = " -d ";\r
737             }\r
738 \r
739             else\r
740             {\r
741                 deinterlace = "";\r
742             }\r
743 \r
744             if ((grayscale ==  "1"))\r
745             {\r
746                 grayscale = " -g ";\r
747             }\r
748 \r
749             else\r
750             {\r
751                 grayscale = "";\r
752             }\r
753 \r
754             if ((videoFramerate ==  "Automatic"))\r
755             {\r
756                 videoFramerate = "";\r
757             }\r
758 \r
759             else\r
760             {\r
761                 videoFramerate = " -r "+ videoFramerate;\r
762             }\r
763 \r
764             if ((pixelRatio ==  "1"))\r
765             {\r
766                 pixelRatio = " -p ";\r
767             }\r
768 \r
769             else\r
770             {\r
771                 pixelRatio = "";\r
772             }\r
773 \r
774             if ((ChapterMarkers ==  "1"))\r
775             {\r
776                 ChapterMarkers = " -m ";\r
777             }\r
778 \r
779             else\r
780             {\r
781                 ChapterMarkers = "";\r
782             }\r
783 \r
784             if ((turboH264 ==  "1"))\r
785             {\r
786                 turboH264 = " -T ";\r
787             }\r
788 \r
789             else\r
790             {\r
791                 turboH264 = "";\r
792             }\r
793 \r
794             if ((largeFile ==  "1"))\r
795             {\r
796                 largeFile = " -4 ";\r
797             }\r
798 \r
799             else\r
800             {\r
801                 largeFile = "";\r
802             }\r
803 \r
804             string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers + turboH264 + largeFile;\r
805             // ----------------------------------------------------------------------\r
806 \r
807             // Audio Settings Tab\r
808 \r
809             string audioBitrate = drp_audioBitrate.Text;\r
810             string audioSampleRate = drp_audioSampleRate.Text;\r
811             string audioChannels = drp_audioChannels.Text;\r
812             string Mixdown = drp_audioMixDown.Text;\r
813             string SixChannelAudio = "";\r
814             if ((audioBitrate !=  ""))\r
815             {\r
816                 audioBitrate = " -B "+ audioBitrate;\r
817             }\r
818 \r
819             if ((audioSampleRate !=  ""))\r
820             {\r
821                 audioSampleRate = " -R "+ audioSampleRate;\r
822             }\r
823 \r
824             if ((audioChannels ==  "Automatic"))\r
825             {\r
826                 audioChannels = "";\r
827             }\r
828 \r
829             else if ((audioChannels ==  ""))\r
830             {\r
831                 audioChannels = "";\r
832             }\r
833 \r
834             else\r
835             {\r
836                 string[] tempSub;\r
837                 tempSub = audioChannels.Split(' ');\r
838                 audioChannels = " -a "+ tempSub[0];\r
839             }\r
840 \r
841             if ((Mixdown ==  "Automatic"))\r
842             {\r
843                 Mixdown = "";\r
844             }\r
845 \r
846             else if (Mixdown ==  "Mono")\r
847             {\r
848                 Mixdown = "mono";\r
849             }\r
850 \r
851             else if (Mixdown ==  "Stereo")\r
852             {\r
853                 Mixdown = "stereo";\r
854             }\r
855 \r
856             else if (Mixdown ==  "Dolby Surround")\r
857             {\r
858                 Mixdown = "dpl1";\r
859             }\r
860 \r
861             else if (Mixdown ==  "Dolby Pro Logic II")\r
862             {\r
863                 Mixdown = "dpl2";\r
864             }\r
865 \r
866             else if (Mixdown ==  "6 Channel Discrete")\r
867             {\r
868                 Mixdown = "6ch";\r
869             }\r
870 \r
871             else\r
872             {\r
873                 Mixdown = "stero";\r
874             }\r
875 \r
876             if ((Mixdown !=  ""))\r
877             {\r
878                 SixChannelAudio = " -6 "+ Mixdown;\r
879             }\r
880 \r
881             else\r
882             {\r
883                 SixChannelAudio = "";\r
884             }\r
885 \r
886             string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;\r
887             // ----------------------------------------------------------------------\r
888 \r
889             //  H.264 Tab\r
890 \r
891             string CRF = CheckCRF.CheckState.ToString();\r
892             string h264Advanced = rtf_h264advanced.Text;\r
893             if ((CRF ==  "1"))\r
894             {\r
895                 CRF = " -Q ";\r
896             }\r
897 \r
898             else\r
899             {\r
900                 CRF = "";\r
901             }\r
902 \r
903             if ((h264Advanced ==  ""))\r
904             {\r
905                 h264Advanced = "";\r
906             }\r
907 \r
908             else\r
909             {\r
910                 h264Advanced = " -x "+ h264Advanced;\r
911             }\r
912 \r
913             string h264Settings = CRF+ h264Advanced;\r
914             // ----------------------------------------------------------------------\r
915 \r
916             // Processors (Program Settings)\r
917 \r
918             string processors = Properties.Settings.Default.Processors;\r
919             //  Number of Processors Handler\r
920 \r
921             if ((processors ==  "Automatic"))\r
922             {\r
923                 processors = "";\r
924             }\r
925 \r
926             else\r
927             {\r
928                 processors = " -C "+ processors+ " ";\r
929             }\r
930 \r
931             string queryAdvancedSettings = processors;\r
932             // ----------------------------------------------------------------------\r
933 \r
934             //  Verbose option (Program Settings)\r
935 \r
936             string verbose = "";\r
937             if ( Properties.Settings.Default.verbose ==  "1")\r
938             {\r
939                 verbose = " -v ";\r
940             }\r
941 \r
942             // ----------------------------------------------------------------------\r
943 \r
944             return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;\r
945         }\r
946 \r
947         \r
948 \r
949         \r
950 \r
951         // This is the END of the road ------------------------------------------------------------------------------\r
952     }\r
953 }