From f2826248fce3d14896de6a02e5f59c9ecc69d1f8 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 17 Apr 2010 13:44:35 +0000 Subject: WinGui: - More stylecop warnings cleaned up git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3235 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmQueue.cs | 301 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 251 insertions(+), 50 deletions(-) (limited to 'win/C#/frmQueue.cs') diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index 51dafd032..8bb0e1910 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -1,8 +1,7 @@ /* frmQueue.cs $ - - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ namespace Handbrake { @@ -15,13 +14,35 @@ namespace Handbrake using Model; using Services; + /// + /// The Queue Window + /// public partial class frmQueue : Form { + /// + /// Update Handler Delegate + /// private delegate void UpdateHandler(); - private Queue queue; - private frmMain mainWindow; + /// + /// An instance of the Queue service + /// + private readonly Queue queue; + /// + /// A reference to the main application window + /// + private readonly frmMain mainWindow; + + /// + /// Initializes a new instance of the class. + /// + /// + /// An instance of the queue service. + /// + /// + /// The main window. + /// public frmQueue(Queue q, frmMain mw) { InitializeComponent(); @@ -34,23 +55,50 @@ namespace Handbrake queue.QueuePauseRequested += new EventHandler(QueueOnPaused); } + /// + /// Handle the Queue Paused event + /// + /// + /// The sender. + /// + /// + /// The EventArgs. + /// private void QueueOnPaused(object sender, EventArgs e) { - SetUIEncodeFinished(); - UpdateUIElements(); + SetUiEncodeFinished(); + UpdateUiElements(); } + /// + /// Handle the Queue Finished event. + /// + /// + /// The sender. + /// + /// + /// The EventArgs. + /// private void QueueOnQueueFinished(object sender, EventArgs e) { - SetUIEncodeFinished(); + SetUiEncodeFinished(); ResetQueue(); // Reset the Queue Window } + /// + /// Handle the Encode Started event + /// + /// + /// The sender. + /// + /// + /// The e. + /// private void QueueOnEncodeStart(object sender, EventArgs e) { - SetUIEncodeStarted(); // make sure the UI is set correctly + SetUiEncodeStarted(); // make sure the UI is set correctly SetCurrentEncodeInformation(); - UpdateUIElements(); // Redraw the Queue, a new encode has started. + UpdateUiElements(); // Redraw the Queue, a new encode has started. } /// @@ -58,7 +106,7 @@ namespace Handbrake /// public void SetQueue() { - UpdateUIElements(); + UpdateUiElements(); } /// @@ -81,12 +129,16 @@ namespace Handbrake // Activate(); } - // Start and Stop Controls - private void btn_encode_Click(object sender, EventArgs e) + /// + /// Handle the Encode button Click event + /// + /// The sender + /// the EventArgs + private void BtnEncodeClick(object sender, EventArgs e) { if (queue.PauseRequested) { - SetUIEncodeStarted(); + SetUiEncodeStarted(); MessageBox.Show("Encoding restarted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } @@ -94,40 +146,58 @@ namespace Handbrake queue.Start(); } - private void btn_pause_Click(object sender, EventArgs e) + /// + /// Handle the Pause button click event. + /// + /// + /// The sender. + /// + /// + /// The EventArgs. + /// + private void BtnPauseClick(object sender, EventArgs e) { queue.Pause(); - SetUIEncodeFinished(); + SetUiEncodeFinished(); ResetQueue(); 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.", + "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); } + // UI Work - // Window Display Management - private void SetUIEncodeStarted() + /// + /// Setup the UI to show that an encode has started + /// + private void SetUiEncodeStarted() { if (InvokeRequired) { - BeginInvoke(new UpdateHandler(SetUIEncodeStarted)); + BeginInvoke(new UpdateHandler(SetUiEncodeStarted)); return; } btn_encode.Enabled = false; btn_pause.Visible = true; } - private void SetUIEncodeFinished() + /// + /// Setup the UI to indicate that an encode has finished. + /// + private void SetUiEncodeFinished() { if (InvokeRequired) { - BeginInvoke(new UpdateHandler(SetUIEncodeFinished)); + BeginInvoke(new UpdateHandler(SetUiEncodeFinished)); return; } btn_pause.Visible = false; btn_encode.Enabled = true; } + /// + /// Reset the Queue Window display + /// private void ResetQueue() { if (InvokeRequired) @@ -148,6 +218,9 @@ namespace Handbrake lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending"; } + /// + /// Redraw the Queue window with the latest information about HandBrakes status + /// private void RedrawQueue() { if (InvokeRequired) @@ -158,10 +231,10 @@ namespace Handbrake list_queue.Items.Clear(); ReadOnlyCollection theQueue = queue.CurrentQueue; - foreach (Job queue_item in theQueue) + foreach (Job queueItem in theQueue) { - string q_item = queue_item.Query; - QueryParser parsed = Functions.QueryParser.Parse(q_item); + string qItem = queueItem.Query; + QueryParser parsed = Functions.QueryParser.Parse(qItem); // Get the DVD Title string title = parsed.DVDTitle == 0 ? "Auto" : parsed.DVDTitle.ToString(); @@ -180,8 +253,8 @@ namespace Handbrake ListViewItem item = new ListViewItem(); item.Text = title; // Title item.SubItems.Add(chapters); // Chapters - item.SubItems.Add(queue_item.Source); // Source - item.SubItems.Add(queue_item.Destination); // Destination + item.SubItems.Add(queueItem.Source); // Source + item.SubItems.Add(queueItem.Destination); // Destination item.SubItems.Add(parsed.VideoEncoder); // Video // Display The Audio Track Information @@ -199,11 +272,14 @@ namespace Handbrake } } - private void UpdateUIElements() + /// + /// Update the UI elements + /// + private void UpdateUiElements() { if (InvokeRequired) { - BeginInvoke(new UpdateHandler(UpdateUIElements)); + BeginInvoke(new UpdateHandler(UpdateUiElements)); return; } @@ -211,6 +287,9 @@ namespace Handbrake lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending"; } + /// + /// Set the window up with the current encode information + /// private void SetCurrentEncodeInformation() { try @@ -256,6 +335,9 @@ namespace Handbrake } } + /// + /// Delete the currently selected items on the queue + /// private void DeleteSelectedItems() { // If there are selected items @@ -275,7 +357,7 @@ namespace Handbrake foreach (int selectedIndex in selectedIndices) queue.Remove(selectedIndex); - UpdateUIElements(); + UpdateUiElements(); // Select the item where the first deleted item was previously if (firstSelectedIndex < list_queue.Items.Count) @@ -286,42 +368,108 @@ namespace Handbrake } // Queue Management - private void mnu_up_Click(object sender, EventArgs e) + /// + /// Handle the Move Up Menu Item + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuUpClick(object sender, EventArgs e) { MoveUp(); } - private void mnu_Down_Click(object sender, EventArgs e) + /// + /// Handle the Move down Menu Item + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuDownClick(object sender, EventArgs e) { MoveDown(); } - private void mnu_delete_Click(object sender, EventArgs e) + /// + /// Handle the delete Menu Item + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuDeleteClick(object sender, EventArgs e) { DeleteSelectedItems(); } - private void btn_up_Click(object sender, EventArgs e) + /// + /// Handle the Button Up Click + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void BtnUpClick(object sender, EventArgs e) { MoveUp(); } - private void btn_down_Click(object sender, EventArgs e) + /// + /// Handle the button down click + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void BtnDownClick(object sender, EventArgs e) { MoveDown(); } - private void btn_delete_Click(object sender, EventArgs e) + /// + /// Handle the delete button click + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void BtnDeleteClick(object sender, EventArgs e) { DeleteSelectedItems(); } - private void list_queue_deleteKey(object sender, KeyEventArgs e) + /// + /// Handle the delete keyboard press + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void ListQueueDeleteKey(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete) DeleteSelectedItems(); } + /// + /// Move items up in the queue + /// private void MoveUp() { // If there are selected items and the first item is not selected @@ -336,7 +484,7 @@ namespace Handbrake foreach (int selectedIndex in selectedIndices) queue.MoveUp(selectedIndex); - UpdateUIElements(); + UpdateUiElements(); // Keep the selected item(s) selected, now moved up one index foreach (int selectedIndex in selectedIndices) @@ -347,6 +495,9 @@ namespace Handbrake list_queue.Select(); // Activate the control to show the selected items } + /// + /// Move items down in the queue + /// private void MoveDown() { // If there are selected items and the last item is not selected @@ -365,7 +516,7 @@ namespace Handbrake foreach (int selectedIndex in selectedIndices) queue.MoveDown(selectedIndex); - UpdateUIElements(); + UpdateUiElements(); // Keep the selected item(s) selected, now moved down one index foreach (int selectedIndex in selectedIndices) @@ -377,7 +528,17 @@ namespace Handbrake } // Queue Import/Export Features - private void mnu_batch_Click(object sender, EventArgs e) + + /// + /// Create a batch script + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuBatchClick(object sender, EventArgs e) { SaveFile.FileName = string.Empty; SaveFile.Filter = "Batch|.bat"; @@ -386,7 +547,16 @@ namespace Handbrake queue.WriteBatchScriptToFile(SaveFile.FileName); } - private void mnu_export_Click(object sender, EventArgs e) + /// + /// Export Queue + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuExportClick(object sender, EventArgs e) { SaveFile.FileName = string.Empty; SaveFile.Filter = "HandBrake Queue|*.queue"; @@ -395,26 +565,53 @@ namespace Handbrake queue.WriteQueueStateToFile(SaveFile.FileName); } - private void mnu_import_Click(object sender, EventArgs e) + /// + /// Import Queue + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuImportClick(object sender, EventArgs e) { OpenFile.FileName = string.Empty; OpenFile.ShowDialog(); if (OpenFile.FileName != String.Empty) queue.LoadQueueFromFile(OpenFile.FileName); - UpdateUIElements(); + UpdateUiElements(); } - private void mnu_readd_Click(object sender, EventArgs e) + /// + /// Readd current job to queue + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuReaddClick(object sender, EventArgs e) { if (!queue.LastEncode.IsEmpty) { - queue.Add(queue.LastEncode.Query, queue.LastEncode.Source, queue.LastEncode.Destination, + queue.Add(queue.LastEncode.Query, queue.LastEncode.Source, queue.LastEncode.Destination, queue.LastEncode.CustomQuery); - UpdateUIElements(); + UpdateUiElements(); } } - private void mnu_reconfigureJob_Click(object sender, EventArgs e) + /// + /// Edit Job + /// + /// + /// The sender. + /// + /// + /// The e. + /// + private void MnuReconfigureJobClick(object sender, EventArgs e) { if (list_queue.SelectedIndices != null) { @@ -431,8 +628,12 @@ namespace Handbrake } } - - // Hide's the window when the user tries to "x" out of the window instead of closing it. + /// + /// Hide's the window when the user tries to "x" out of the window instead of closing it. + /// + /// + /// The e. + /// protected override void OnClosing(CancelEventArgs e) { e.Cancel = true; -- cgit v1.2.3