2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
9 using System.Collections.Generic;
\r
10 using System.Diagnostics;
\r
11 using System.Globalization;
\r
12 using System.Windows.Forms;
\r
14 using HandBrake.ApplicationServices;
\r
16 using Handbrake.Functions;
\r
17 using Handbrake.Model;
\r
18 using Handbrake.Properties;
\r
21 /// The Options Window
\r
23 public partial class frmOptions : Form
\r
25 private frmMain mainWindow;
\r
26 private bool optionsWindowLoading = true;
\r
28 public frmOptions(frmMain mw)
\r
30 InitializeComponent();
\r
33 IDictionary<string, string> langList = Main.MapLanguages();
\r
34 foreach (string item in langList.Keys)
\r
35 drop_preferredLang.Items.Add(item);
\r
37 // #############################
\r
39 // #############################
\r
42 if (Properties.Settings.Default.tooltipEnable)
\r
44 check_tooltip.CheckState = CheckState.Checked;
\r
45 ToolTip.Active = true;
\r
49 if (Properties.Settings.Default.updateStatus)
\r
50 check_updateCheck.CheckState = CheckState.Checked;
\r
52 // Days between update checks
\r
53 switch (Properties.Settings.Default.daysBetweenUpdateCheck)
\r
56 drop_updateCheckDays.SelectedIndex = 0;
\r
59 drop_updateCheckDays.SelectedIndex = 1;
\r
62 drop_updateCheckDays.SelectedIndex = 2;
\r
66 // On Encode Completeion Action
\r
67 drp_completeOption.Text = Properties.Settings.Default.CompletionOption;
\r
70 if (Properties.Settings.Default.growlEncode)
\r
71 check_growlEncode.CheckState = CheckState.Checked;
\r
73 if (Properties.Settings.Default.growlQueue)
\r
74 check_GrowlQueue.CheckState = CheckState.Checked;
\r
76 // Enable auto naming feature.
\r
77 if (Properties.Settings.Default.autoNaming)
\r
78 check_autoNaming.CheckState = CheckState.Checked;
\r
80 // Store the auto name path
\r
81 text_an_path.Text = Properties.Settings.Default.autoNamePath;
\r
82 if (text_an_path.Text == string.Empty)
\r
83 text_an_path.Text = "Click 'Browse' to set the default location";
\r
85 // Store auto name format
\r
86 txt_autoNameFormat.Text = Properties.Settings.Default.autoNameFormat;
\r
88 // Use iPod/iTunes friendly .m4v extension for MP4 files.
\r
89 if (Properties.Settings.Default.useM4v)
\r
90 check_m4v.CheckState = CheckState.Checked;
\r
92 // Remove Underscores
\r
93 check_removeUnderscores.Checked = Properties.Settings.Default.AutoNameRemoveUnderscore;
\r
96 check_TitleCase.Checked = Properties.Settings.Default.AutoNameTitleCase;
\r
98 // #############################
\r
100 // #############################
\r
103 txt_vlcPath.Text = Properties.Settings.Default.VLC_Path;
\r
105 // #############################
\r
106 // Audio and Subtitles Tab
\r
107 // #############################
\r
109 drop_preferredLang.SelectedItem = Properties.Settings.Default.NativeLanguage;
\r
111 switch (Settings.Default.DubMode)
\r
114 radio_dub.Checked = true;
\r
117 radio_foreignAndSubs.Checked = true;
\r
120 radio_preferredAudioAndSubs.Checked = true;
\r
124 check_AddCCTracks.Checked = Properties.Settings.Default.useClosedCaption;
\r
126 // #############################
\r
128 // #############################
\r
130 // Priority level for encodes
\r
131 drp_Priority.Text = Properties.Settings.Default.processPriority;
\r
133 check_preventSleep.Checked = Properties.Settings.Default.preventSleep;
\r
135 // Log Verbosity Level
\r
136 cb_logVerboseLvl.SelectedIndex = Properties.Settings.Default.verboseLevel;
\r
138 // Save logs in the same directory as encoded files
\r
139 if (Properties.Settings.Default.saveLogWithVideo)
\r
140 check_saveLogWithVideo.CheckState = CheckState.Checked;
\r
142 // Save Logs in a specified path
\r
143 if (Properties.Settings.Default.saveLogToSpecifiedPath)
\r
144 check_logsInSpecifiedLocation.CheckState = CheckState.Checked;
\r
146 // The saved log path
\r
147 text_logPath.Text = Properties.Settings.Default.saveLogPath;
\r
149 check_clearOldLogs.Checked = Properties.Settings.Default.clearOldLogs;
\r
151 // #############################
\r
153 // #############################
\r
155 // Minimise to Tray
\r
156 if (Properties.Settings.Default.trayIconAlerts)
\r
157 check_trayStatusAlerts.CheckState = CheckState.Checked;
\r
159 // Tray Balloon popups
\r
160 if (Properties.Settings.Default.MainWindowMinimize)
\r
161 check_mainMinimize.CheckState = CheckState.Checked;
\r
163 // Enable / Disable Query editor tab
\r
164 if (Properties.Settings.Default.QueryEditorTab)
\r
165 check_queryEditorTab.CheckState = CheckState.Checked;
\r
166 check_promptOnUnmatchingQueries.Enabled = check_queryEditorTab.Checked;
\r
168 // Prompt on inconsistant queries
\r
169 check_promptOnUnmatchingQueries.Checked = Properties.Settings.Default.PromptOnUnmatchingQueries;
\r
171 // Preset update notification
\r
172 if (Properties.Settings.Default.presetNotification)
\r
173 check_disablePresetNotification.CheckState = CheckState.Checked;
\r
176 check_showCliForInGUIEncode.Checked = Properties.Settings.Default.showCliForInGuiEncodeStatus;
\r
178 // Set the preview count
\r
179 drop_previewScanCount.SelectedItem = Properties.Settings.Default.previewScanCount.ToString();
\r
182 string step = Properties.Settings.Default.x264cqstep.ToString(new CultureInfo("en-US"));
\r
186 drop_x264step.SelectedIndex = 0;
\r
189 drop_x264step.SelectedIndex = 1;
\r
192 drop_x264step.SelectedIndex = 2;
\r
195 drop_x264step.SelectedIndex = 3;
\r
199 // Use Experimental dvdnav
\r
200 if (Properties.Settings.Default.noDvdNav)
\r
201 check_dvdnav.CheckState = CheckState.Checked;
\r
203 optionsWindowLoading = false;
\r
208 private void check_updateCheck_CheckedChanged(object sender, EventArgs e)
\r
210 Properties.Settings.Default.updateStatus = check_updateCheck.Checked;
\r
213 private void drop_updateCheckDays_SelectedIndexChanged(object sender, EventArgs e)
\r
215 switch (drop_updateCheckDays.SelectedIndex)
\r
218 Properties.Settings.Default.daysBetweenUpdateCheck = 1;
\r
221 Properties.Settings.Default.daysBetweenUpdateCheck = 7;
\r
224 Properties.Settings.Default.daysBetweenUpdateCheck = 30;
\r
229 private void check_tooltip_CheckedChanged(object sender, EventArgs e)
\r
231 Properties.Settings.Default.tooltipEnable = check_tooltip.Checked;
\r
234 private void drp_completeOption_SelectedIndexChanged(object sender, EventArgs e)
\r
236 Properties.Settings.Default.CompletionOption = drp_completeOption.Text;
\r
239 private void check_GrowlQueue_CheckedChanged(object sender, EventArgs e)
\r
241 Properties.Settings.Default.growlQueue = check_GrowlQueue.Checked;
\r
244 private void check_growlEncode_CheckedChanged(object sender, EventArgs e)
\r
246 Properties.Settings.Default.growlEncode = check_growlEncode.Checked;
\r
249 private void check_autoNaming_CheckedChanged(object sender, EventArgs e)
\r
251 Properties.Settings.Default.autoNaming = check_autoNaming.Checked;
\r
254 private void txt_autoNameFormat_TextChanged(object sender, EventArgs e)
\r
256 Properties.Settings.Default.autoNameFormat = txt_autoNameFormat.Text;
\r
259 private void btn_browse_Click(object sender, EventArgs e)
\r
261 pathFinder.ShowDialog();
\r
262 text_an_path.Text = pathFinder.SelectedPath;
\r
265 private void text_an_path_TextChanged(object sender, EventArgs e)
\r
267 if (text_an_path.Text == string.Empty)
\r
269 Properties.Settings.Default.autoNamePath = string.Empty;
\r
270 text_an_path.Text = "Click 'Browse' to set the default location";
\r
273 Properties.Settings.Default.autoNamePath = text_an_path.Text;
\r
275 if (text_an_path.Text.ToLower() == "{source_path}" && !optionsWindowLoading)
\r
278 "Be careful with this feature. Make sure you can write to the same folder as the source! \n\n If you are encoding from a DVD, do not use this feature as HandBrake will not be able to write to the DVD!",
\r
279 "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
282 if (text_an_path.Text.ToLower().Contains("{source_path}") && text_an_path.Text.ToLower() != "{source_path}")
\r
284 MessageBox.Show("Note you can not use the {source_path} within a path. {source_path} is the full source file path.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
288 private void check_m4v_CheckedChanged(object sender, EventArgs e)
\r
290 Properties.Settings.Default.useM4v = check_m4v.Checked;
\r
293 private void check_removeUnderscores_CheckedChanged(object sender, EventArgs e)
\r
295 Properties.Settings.Default.AutoNameRemoveUnderscore = check_removeUnderscores.Checked;
\r
298 private void check_TitleCase_CheckedChanged(object sender, EventArgs e)
\r
300 Properties.Settings.Default.AutoNameTitleCase = check_TitleCase.Checked;
\r
307 private void btn_vlcPath_Click(object sender, EventArgs e)
\r
309 openFile_vlc.ShowDialog();
\r
310 if (openFile_vlc.FileName != string.Empty)
\r
311 txt_vlcPath.Text = openFile_vlc.FileName;
\r
314 private void txt_vlcPath_TextChanged(object sender, EventArgs e)
\r
316 Properties.Settings.Default.VLC_Path = txt_vlcPath.Text;
\r
321 #region Audio and Subtitles
\r
323 private void drop_preferredLang_SelectedIndexChanged(object sender, EventArgs e)
\r
325 Properties.Settings.Default.NativeLanguage = drop_preferredLang.SelectedItem.ToString();
\r
328 private void radio_dub_CheckedChanged(object sender, EventArgs e)
\r
330 if (radio_dub.Checked)
\r
331 Properties.Settings.Default.DubMode = 1;
\r
334 private void radio_foreignAndSubs_CheckedChanged(object sender, EventArgs e)
\r
336 if (radio_foreignAndSubs.Checked)
\r
337 Properties.Settings.Default.DubMode = 2;
\r
340 private void radio_preferredAudioAndSubs_CheckedChanged(object sender, EventArgs e)
\r
342 if (radio_preferredAudioAndSubs.Checked)
\r
343 Properties.Settings.Default.DubMode = 3;
\r
346 private void check_AddCCTracks_CheckedChanged(object sender, EventArgs e)
\r
348 Settings.Default.useClosedCaption = check_AddCCTracks.Checked;
\r
355 private void drp_Priority_SelectedIndexChanged(object sender, EventArgs e)
\r
357 Properties.Settings.Default.processPriority = drp_Priority.Text;
\r
360 private void check_preventSleep_CheckedChanged(object sender, EventArgs e)
\r
362 Properties.Settings.Default.preventSleep = check_preventSleep.Checked;
\r
365 private void cb_logVerboseLvl_SelectedIndexChanged(object sender, EventArgs e)
\r
367 Properties.Settings.Default.verboseLevel = cb_logVerboseLvl.SelectedIndex;
\r
370 private void check_saveLogWithVideo_CheckedChanged(object sender, EventArgs e)
\r
372 Properties.Settings.Default.saveLogWithVideo = check_saveLogWithVideo.Checked;
\r
375 private void check_logsInSpecifiedLocation_CheckedChanged(object sender, EventArgs e)
\r
377 Properties.Settings.Default.saveLogToSpecifiedPath = check_logsInSpecifiedLocation.Checked;
\r
380 private void btn_saveLog_Click(object sender, EventArgs e)
\r
382 pathFinder.SelectedPath = String.Empty;
\r
383 pathFinder.ShowDialog();
\r
384 if (pathFinder.SelectedPath != string.Empty)
\r
385 text_logPath.Text = pathFinder.SelectedPath;
\r
388 private void text_logPath_TextChanged(object sender, EventArgs e)
\r
390 Properties.Settings.Default.saveLogPath = text_logPath.Text;
\r
393 private void btn_viewLogs_Click(object sender, EventArgs e)
\r
395 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
\r
396 string windir = Environment.GetEnvironmentVariable("WINDIR");
\r
397 Process prc = new Process();
\r
398 prc.StartInfo.FileName = windir + @"\explorer.exe";
\r
399 prc.StartInfo.Arguments = logDir;
\r
403 private void btn_clearLogs_Click(object sender, EventArgs e)
\r
405 DialogResult result = MessageBox.Show("Are you sure you wish to clear the log file directory?", "Clear Logs",
\r
406 MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
\r
407 if (result == DialogResult.Yes)
\r
410 MessageBox.Show(this, "HandBrake's Log file directory has been cleared!", "Notice", MessageBoxButtons.OK,
\r
411 MessageBoxIcon.Information);
\r
415 private void check_clearOldLogs_CheckedChanged(object sender, EventArgs e)
\r
417 Properties.Settings.Default.clearOldLogs = check_clearOldLogs.Checked;
\r
424 private void check_mainMinimize_CheckedChanged(object sender, EventArgs e)
\r
426 Properties.Settings.Default.MainWindowMinimize = check_mainMinimize.Checked;
\r
427 check_trayStatusAlerts.Enabled = check_mainMinimize.Checked;
\r
430 private void check_trayStatusAlerts_CheckedChanged(object sender, EventArgs e)
\r
432 Properties.Settings.Default.trayIconAlerts = check_trayStatusAlerts.Checked;
\r
435 private void check_queryEditorTab_CheckedChanged(object sender, EventArgs e)
\r
437 Properties.Settings.Default.QueryEditorTab = check_queryEditorTab.Checked;
\r
438 check_promptOnUnmatchingQueries.Enabled = check_queryEditorTab.Checked;
\r
441 private void check_promptOnUnmatchingQueries_CheckedChanged(object sender, EventArgs e)
\r
443 Properties.Settings.Default.PromptOnUnmatchingQueries = check_promptOnUnmatchingQueries.Checked;
\r
446 private void check_disablePresetNotification_CheckedChanged(object sender, EventArgs e)
\r
448 Properties.Settings.Default.presetNotification = check_disablePresetNotification.Checked;
\r
451 private void check_showCliForInGUIEncode_CheckedChanged(object sender, EventArgs e)
\r
453 Properties.Settings.Default.showCliForInGuiEncodeStatus = check_showCliForInGUIEncode.Checked;
\r
456 private void drop_previewScanCount_SelectedIndexChanged(object sender, EventArgs e)
\r
458 Properties.Settings.Default.previewScanCount = int.Parse(drop_previewScanCount.SelectedItem.ToString());
\r
461 private void x264step_SelectedIndexChanged(object sender, EventArgs e)
\r
463 switch (drop_x264step.SelectedIndex)
\r
466 Properties.Settings.Default.x264cqstep = 1.0;
\r
469 Properties.Settings.Default.x264cqstep = 0.50;
\r
472 Properties.Settings.Default.x264cqstep = 0.25;
\r
475 Properties.Settings.Default.x264cqstep = 0.20;
\r
478 mainWindow.setQualityFromSlider();
\r
481 private void check_dvdnav_CheckedChanged(object sender, EventArgs e)
\r
483 Properties.Settings.Default.noDvdNav = check_dvdnav.Checked;
\r
488 private void btn_close_Click(object sender, EventArgs e)
\r
490 Properties.Settings.Default.Save(); // Small hack for Vista. Seems to work fine on XP without this
\r
491 UpdateApplicationServicesSettings();
\r
497 /// Initialize App Services
\r
499 private static void UpdateApplicationServicesSettings()
\r
501 string versionId = String.Format(
\r
502 "Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);
\r
503 Init.SetupSettings(
\r
505 Program.InstanceId,
\r
506 Settings.Default.CompletionOption,
\r
507 Settings.Default.noDvdNav,
\r
508 Settings.Default.growlEncode,
\r
509 Settings.Default.growlQueue,
\r
510 Settings.Default.processPriority,
\r
511 Settings.Default.saveLogPath,
\r
512 Settings.Default.saveLogToSpecifiedPath,
\r
513 Settings.Default.saveLogWithVideo,
\r
514 Settings.Default.showCliForInGuiEncodeStatus,
\r
515 Settings.Default.preventSleep);
\r