X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmQueue.cs;h=352978960565caf1fa194c8a8985ae2816f6f26e;hb=cfa1fb7010dc9324e15d257bad7a73af66e9eb10;hp=ceb127fb4f574bcae27429d0ec91145e32a00c7c;hpb=93d0c80acec28a1e38c5b1d2edc0ec9d91e1cdb9;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index ceb127fb..35297896 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -8,34 +8,36 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; +using Handbrake.EncodeQueue; +using System.Collections.ObjectModel; namespace Handbrake { public partial class frmQueue : Form { private delegate void UpdateHandler(); - Queue.QueueHandler queue; + private EncodeAndQueueHandler queue; - public frmQueue(Queue.QueueHandler q) + public frmQueue(EncodeAndQueueHandler q) { InitializeComponent(); this.queue = q; - queue.OnEncodeStart += new EventHandler(queue_OnEncodeStart); - queue.OnQueueFinished += new EventHandler(queue_OnQueueFinished); - queue.OnPaused += new EventHandler(queue_OnPaused); + queue.NewJobStarted += new EventHandler(queueOnEncodeStart); + queue.QueueCompleted += new EventHandler(queueOnQueueFinished); + queue.QueuePauseRequested += new EventHandler(queueOnPaused); } - void queue_OnPaused(object sender, EventArgs e) + void queueOnPaused(object sender, EventArgs e) { setUIEncodeFinished(); updateUIElements(); } - void queue_OnQueueFinished(object sender, EventArgs e) + void queueOnQueueFinished(object sender, EventArgs e) { setUIEncodeFinished(); resetQueue(); // Reset the Queue Window } - void queue_OnEncodeStart(object sender, EventArgs e) + void queueOnEncodeStart(object sender, EventArgs e) { setUIEncodeStarted(); // make sure the UI is set correctly setCurrentEncodeInformation(); @@ -55,7 +57,7 @@ namespace Handbrake /// public new void Show() { - Show(true); + Show(true); } /// @@ -66,28 +68,29 @@ namespace Handbrake { if (doSetQueue) setQueue(); base.Show(); - Activate(); + + //Activate(); } // Start and Stop Controls private void btn_encode_Click(object sender, EventArgs e) { - if (queue.isPaused) + if (queue.PauseRequested) { setUIEncodeStarted(); MessageBox.Show("Encoding restarted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } - if (!queue.isEncodeStarted) - queue.startEncode(); + if (!queue.isEncoding) + queue.StartEncodeQueue(); } private void btn_pause_Click(object sender, EventArgs e) { - queue.pauseEncode(); + queue.RequestPause(); setUIEncodeFinished(); resetQueue(); - MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode Video' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + MessageBox.Show("No further items on the queue will start. The current encode process will continue until it is finished. \nClick 'Encode' when you wish to continue encoding the queue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // Window Display Management @@ -139,14 +142,14 @@ namespace Handbrake } list_queue.Items.Clear(); - List theQueue = queue.getQueue(); - foreach (Queue.QueueItem queue_item in theQueue) + ReadOnlyCollection theQueue = queue.CurrentQueue; + foreach (Job queue_item in theQueue) { string q_item = queue_item.Query; Functions.QueryParser parsed = Functions.QueryParser.Parse(q_item); // Get the DVD Title - string title = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString(); + string title = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString(); // Get the DVD Chapters string chapters; @@ -165,7 +168,17 @@ namespace Handbrake item.SubItems.Add(queue_item.Source); // Source item.SubItems.Add(queue_item.Destination); // Destination item.SubItems.Add(parsed.VideoEncoder); // Video - item.SubItems.Add(parsed.AudioEncoder1); // Audio + + // Display The Audio Track Information + string audio = string.Empty; + foreach (Functions.AudioTrack track in parsed.AudioInformation) + { + if (audio != "") + audio += ", " + track.Encoder; + else + audio = track.Encoder; + } + item.SubItems.Add(audio); // Audio list_queue.Items.Add(item); } @@ -191,14 +204,14 @@ namespace Handbrake } // found query is a global varible - Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.getLastQueryItem().Query); - lbl_source.Text = queue.getLastQueryItem().Source; - lbl_dest.Text = queue.getLastQueryItem().Destination; + Functions.QueryParser parsed = Functions.QueryParser.Parse(queue.LastEncode.Query); + lbl_source.Text = queue.LastEncode.Source; + lbl_dest.Text = queue.LastEncode.Destination; lbl_title.Text = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString(); if (Equals(parsed.DVDChapterStart, 0)) - lbl_chapt.Text = "Auto"; + lbl_chapt.Text = "Auto"; else { string chapters = parsed.DVDChapterStart.ToString(); @@ -208,7 +221,17 @@ namespace Handbrake } lbl_vEnc.Text = parsed.VideoEncoder; - lbl_aEnc.Text = parsed.AudioEncoder1; + + // Display The Audio Track Information + string audio = string.Empty; + foreach (Functions.AudioTrack track in parsed.AudioInformation) + { + if (audio != "") + audio += ", " + track.Encoder; + else + audio = track.Encoder; + } + lbl_aEnc.Text = audio; } catch (Exception) { @@ -229,16 +252,15 @@ namespace Handbrake // Reverse the list to delete the items from last to first (preserves indices) selectedIndices.Reverse(); - + // Remove each selected item foreach (int selectedIndex in selectedIndices) - queue.remove(selectedIndex); + queue.RemoveJob(selectedIndex); - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file updateUIElements(); // Select the item where the first deleted item was previously - if (firstSelectedIndex < list_queue.Items.Count) + if (firstSelectedIndex < list_queue.Items.Count) list_queue.Items[firstSelectedIndex].Selected = true; } @@ -246,19 +268,39 @@ namespace Handbrake } // Queue Management - private void btn_re_add_Click(object sender, EventArgs e) + private void mnu_up_Click(object sender, EventArgs e) { - if (queue.getLastQueryItem() != null) - { - queue.add(queue.getLastQueryItem().Query, queue.getLastQueryItem().Source, queue.getLastQueryItem().Destination); - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file - updateUIElements(); - } + moveUp(); + } + private void mnu_Down_Click(object sender, EventArgs e) + { + moveDown(); + } + private void mnu_delete_Click(object sender, EventArgs e) + { + deleteSelectedItems(); } private void btn_up_Click(object sender, EventArgs e) { + moveUp(); + } + private void btn_down_Click(object sender, EventArgs e) + { + moveDown(); + } + private void btn_delete_Click(object sender, EventArgs e) + { + deleteSelectedItems(); + } + private void list_queue_deleteKey(object sender, KeyEventArgs e) + { + if (e.KeyCode == Keys.Delete) + deleteSelectedItems(); + } + private void moveUp() + { // If there are selected items and the first item is not selected - if (list_queue.SelectedIndices.Count > 0 && ! list_queue.SelectedIndices.Contains(0)) + if (list_queue.SelectedIndices.Count > 0 && !list_queue.SelectedIndices.Contains(0)) { // Copy the selected indices to preserve them during the movement List selectedIndices = new List(list_queue.SelectedIndices.Count); @@ -267,9 +309,8 @@ namespace Handbrake // Move up each selected item foreach (int selectedIndex in selectedIndices) - queue.moveUp(selectedIndex); + queue.MoveUp(selectedIndex); - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file updateUIElements(); // Keep the selected item(s) selected, now moved up one index @@ -280,11 +321,11 @@ namespace Handbrake list_queue.Select(); // Activate the control to show the selected items } - private void btn_down_Click(object sender, EventArgs e) + private void moveDown() { // If there are selected items and the last item is not selected - if (list_queue.SelectedIndices.Count > 0 && - ! list_queue.SelectedIndices.Contains(list_queue.Items[list_queue.Items.Count-1].Index)) + if (list_queue.SelectedIndices.Count > 0 && + !list_queue.SelectedIndices.Contains(list_queue.Items[list_queue.Items.Count - 1].Index)) { // Copy the selected indices to preserve them during the movement List selectedIndices = new List(list_queue.SelectedIndices.Count); @@ -296,28 +337,18 @@ namespace Handbrake // Move down each selected item foreach (int selectedIndex in selectedIndices) - queue.moveDown(selectedIndex); - - queue.write2disk("hb_queue_recovery.xml"); // Update the queue recovery file + queue.MoveDown(selectedIndex); + updateUIElements(); // Keep the selected item(s) selected, now moved down one index foreach (int selectedIndex in selectedIndices) if (selectedIndex + 1 < list_queue.Items.Count) // Defensive programming: ensure index is good - list_queue.Items[selectedIndex + 1].Selected = true; + list_queue.Items[selectedIndex + 1].Selected = true; } list_queue.Select(); // Activate the control to show the selected items } - private void btn_delete_Click(object sender, EventArgs e) - { - deleteSelectedItems(); - } - private void list_queue_deleteKey(object sender, KeyEventArgs e) - { - if (e.KeyCode == Keys.Delete) - deleteSelectedItems(); - } // Queue Import/Export Features private void mnu_batch_Click(object sender, EventArgs e) @@ -326,7 +357,7 @@ namespace Handbrake SaveFile.Filter = "Batch|.bat"; SaveFile.ShowDialog(); if (SaveFile.FileName != String.Empty) - queue.writeBatchScript(SaveFile.FileName); + queue.WriteBatchScriptToFile(SaveFile.FileName); } private void mnu_export_Click(object sender, EventArgs e) { @@ -334,16 +365,24 @@ namespace Handbrake SaveFile.Filter = "HandBrake Queue|*.queue"; SaveFile.ShowDialog(); if (SaveFile.FileName != String.Empty) - queue.write2disk(SaveFile.FileName); + queue.WriteQueueStateToFile(SaveFile.FileName); } private void mnu_import_Click(object sender, EventArgs e) { OpenFile.FileName = ""; OpenFile.ShowDialog(); if (OpenFile.FileName != String.Empty) - queue.recoverQueue(OpenFile.FileName); + queue.LoadQueueFromFile(OpenFile.FileName); updateUIElements(); } + private void mnu_readd_Click(object sender, EventArgs e) + { + if (!queue.LastEncode.IsEmpty) + { + queue.AddJob(queue.LastEncode.Query, queue.LastEncode.Source, queue.LastEncode.Destination, queue.LastEncode.CustomQuery); + updateUIElements(); + } + } // Hide's the window when the user tries to "x" out of the window instead of closing it. protected override void OnClosing(CancelEventArgs e) @@ -353,6 +392,5 @@ namespace Handbrake base.OnClosing(e); } - } }