X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmMain.cs;h=83ea0de121def14055c8959f83491b84510490ad;hb=8d0c431738a99cd4776cc31e195fea690f6fb20a;hp=6f9341641d884f02bc0acd9b27852b08e68d3e1b;hpb=5b0de6de37b89c8c142ee61d12372bcda676af9a;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 6f934164..83ea0de1 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -8,14 +8,10 @@ using System; using System.Collections; using System.Collections.Generic; using System.Drawing; -using System.Text; using System.Windows.Forms; using System.IO; using System.Diagnostics; using System.Threading; -using System.Runtime.InteropServices; -using System.Globalization; -using System.Text.RegularExpressions; namespace Handbrake { @@ -88,7 +84,7 @@ namespace Handbrake loadPresetPanel(); // Load the Preset Panel treeView_presets.ExpandAll(); lbl_encode.Text = ""; - queueWindow = new frmQueue(this); // Prepare the Queue + queueWindow = new frmQueue(encodeQueue); // Prepare the Queue if (Properties.Settings.Default.QueryEditorTab != "Checked") tabs_panel.TabPages.RemoveAt(5); // Remove the query editor tab if the user does not want it enabled. @@ -133,8 +129,7 @@ namespace Handbrake this.Enabled = true; // Event Handlers - if (Properties.Settings.Default.MainWindowMinimize == "Checked") - this.Resize += new EventHandler(frmMain_Resize); + events(); // Queue Recovery queueRecovery(); @@ -180,6 +175,34 @@ namespace Handbrake } #endregion + #region Events + // Encoding Events for setting up the GUI + private void events() + { + // Handle Window Resize + if (Properties.Settings.Default.MainWindowMinimize == "Checked") + this.Resize += new EventHandler(frmMain_Resize); + + // Handle Encode Start + encodeQueue.OnEncodeEnded += new EventHandler(encodeEnded); + encodeQueue.OnPaused += new EventHandler(encodePaused); + encodeQueue.OnEncodeStart += new EventHandler(encodeStarted); + } + private void encodeStarted(object sender, EventArgs e) + { + setLastAction("encode"); + setEncodeStarted(); + } + private void encodeEnded(object sender, EventArgs e) + { + setEncodeFinished(); + } + private void encodePaused(object sender, EventArgs e) + { + setEncodeFinished(); + } + #endregion + // User Interface Menus / Tool Strips ********************************* #region File Menu @@ -192,7 +215,7 @@ namespace Handbrake #region Tools Menu private void mnu_encode_Click(object sender, EventArgs e) { - queueWindow.setQueue(encodeQueue); + queueWindow.setQueue(); queueWindow.Show(); } private void mnu_encodeLog_Click(object sender, EventArgs e) @@ -208,7 +231,7 @@ namespace Handbrake } private void mnu_options_Click(object sender, EventArgs e) { - Form Options = new frmOptions(this); + Form Options = new frmOptions(); Options.ShowDialog(); } #endregion @@ -305,6 +328,14 @@ namespace Handbrake { treeView_presets.CollapseAll(); } + private void pmnu_saveChanges_Click(object sender, EventArgs e) + { + DialogResult result = MessageBox.Show("Do you wish to include picture settings when updating the preset: " + treeView_presets.SelectedNode.Text, "Update Preset", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); + if (result == DialogResult.Yes) + presetHandler.updatePreset(treeView_presets.SelectedNode.Text, queryGen.generateTabbedComponentsQuery(this), true); + else if (result == DialogResult.No) + presetHandler.updatePreset(treeView_presets.SelectedNode.Text, queryGen.generateTabbedComponentsQuery(this), false); + } private void pmnu_delete_click(object sender, EventArgs e) { if (treeView_presets.SelectedNode != null) @@ -322,6 +353,21 @@ namespace Handbrake } treeView_presets.Select(); } + private void presets_menu_Opening(object sender, System.ComponentModel.CancelEventArgs e) + { + // Make sure that the save menu is always disabled by default + pmnu_saveChanges.Enabled = false; + + // Now enable the save menu if the selected preset is a user preset + if (treeView_presets.SelectedNode != null) + { + if (presetHandler.checkIfUserPresetExists(treeView_presets.SelectedNode.Text)) + { + pmnu_saveChanges.Enabled = true; + } + } + treeView_presets.Select(); + } // Presets Management private void btn_addPreset_Click(object sender, EventArgs e) @@ -504,6 +550,10 @@ namespace Handbrake if (result == DialogResult.Yes) { + // Pause The Queue + encodeQueue.pauseEncode(); + + // Kill the current process. Process[] aProc = Process.GetProcessesByName("HandBrakeCLI"); Process HandBrakeCLI; if (aProc.Length > 0) @@ -511,8 +561,9 @@ namespace Handbrake HandBrakeCLI = aProc[0]; HandBrakeCLI.Kill(); } - if (!queueWindow.isEncoding()) - setEncodeFinished(); + + // Update the GUI + setEncodeFinished(); } } else @@ -534,13 +585,13 @@ namespace Handbrake encodeQueue.add(query, text_source.Text, text_destination.Text); encodeQueue.write2disk("hb_queue_recovery.xml"); } - queueWindow.setQueue(encodeQueue); + queueWindow.setQueue(); if (encodeQueue.count() > 1) queueWindow.Show(); - queueWindow.frmMain_encode(); - setEncodeStarted(); // Encode is running, so setup the GUI appropriately + encodeQueue.startEncode(); // Start The Queue Encoding Process + } else if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty) MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); @@ -560,13 +611,13 @@ namespace Handbrake encodeQueue.add(query, text_source.Text, text_destination.Text); encodeQueue.write2disk("hb_queue_recovery.xml"); // Writes the queue to the recovery file, just incase the GUI crashes. - queueWindow.setQueue(encodeQueue); + queueWindow.setQueue(); queueWindow.Show(); } } private void btn_showQueue_Click(object sender, EventArgs e) { - queueWindow.setQueue(encodeQueue); + queueWindow.setQueue(); queueWindow.Show(); } private void mnu_vlcpreview_Click(object sender, EventArgs e) @@ -884,15 +935,15 @@ namespace Handbrake DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "").Replace(".ogm", "").Replace(".avi", ""); // Show the dialog and set the main form file path - if (text_destination.Text.EndsWith(".mp4")) + if (drop_format.SelectedIndex.Equals(0)) DVD_Save.FilterIndex = 1; - else if (text_destination.Text.EndsWith(".m4v")) + else if (drop_format.SelectedIndex.Equals(1)) DVD_Save.FilterIndex = 2; - else if (text_destination.Text.EndsWith(".avi")) + else if (drop_format.SelectedIndex.Equals(2)) DVD_Save.FilterIndex = 3; - else if (text_destination.Text.EndsWith(".ogm")) + else if (drop_format.SelectedIndex.Equals(3)) DVD_Save.FilterIndex = 4; - else if (text_destination.Text.EndsWith(".mkv")) + else if (drop_format.SelectedIndex.Equals(4)) DVD_Save.FilterIndex = 5; if (DVD_Save.ShowDialog() == DialogResult.OK) @@ -1896,6 +1947,9 @@ namespace Handbrake #endregion + + + // This is the END of the road ------------------------------------------------------------------------------ } } \ No newline at end of file