+ // Copy the selected indices to preserve them during the movement\r
+ List<int> selectedIndices = new List<int>(list_queue.SelectedIndices.Count);\r
+ foreach (int selectedIndex in list_queue.SelectedIndices)\r
+ selectedIndices.Add(selectedIndex);\r
+\r
+ // Move up each selected item\r
+ foreach (int selectedIndex in selectedIndices)\r
+ queue.MoveUp(selectedIndex);\r
+\r
+ updateUIElements();\r
+\r
+ // Keep the selected item(s) selected, now moved up one index\r
+ foreach (int selectedIndex in selectedIndices)\r
+ if (selectedIndex - 1 > -1) // Defensive programming: ensure index is good\r
+ list_queue.Items[selectedIndex - 1].Selected = true;\r
+ }\r
+\r
+ list_queue.Select(); // Activate the control to show the selected items\r
+ }\r
+ private void moveDown()\r
+ {\r
+ // If there are selected items and the last item is not selected\r
+ if (list_queue.SelectedIndices.Count > 0 &&\r
+ !list_queue.SelectedIndices.Contains(list_queue.Items[list_queue.Items.Count - 1].Index))\r
+ {\r
+ // Copy the selected indices to preserve them during the movement\r
+ List<int> selectedIndices = new List<int>(list_queue.SelectedIndices.Count);\r
+ foreach (int selectedIndex in list_queue.SelectedIndices)\r
+ selectedIndices.Add(selectedIndex);\r
+\r
+ // Reverse the indices to move the items down from last to first (preserves indices)\r
+ selectedIndices.Reverse();\r
+\r
+ // Move down each selected item\r
+ foreach (int selectedIndex in selectedIndices)\r
+ queue.MoveDown(selectedIndex);\r
+\r
+ updateUIElements();\r
+\r
+ // Keep the selected item(s) selected, now moved down one index\r
+ foreach (int selectedIndex in selectedIndices)\r
+ if (selectedIndex + 1 < list_queue.Items.Count) // Defensive programming: ensure index is good\r
+ list_queue.Items[selectedIndex + 1].Selected = true;\r
+ }\r
+\r
+ list_queue.Select(); // Activate the control to show the selected items\r
+ }\r
+\r
+ // Queue Import/Export Features\r
+ private void mnu_batch_Click(object sender, EventArgs e)\r
+ {\r
+ SaveFile.FileName = "";\r
+ SaveFile.Filter = "Batch|.bat";\r
+ SaveFile.ShowDialog();\r
+ if (SaveFile.FileName != String.Empty)\r
+ queue.WriteBatchScriptToFile(SaveFile.FileName);\r
+ }\r
+ private void mnu_export_Click(object sender, EventArgs e)\r
+ {\r
+ SaveFile.FileName = "";\r
+ SaveFile.Filter = "HandBrake Queue|*.queue";\r
+ SaveFile.ShowDialog();\r
+ if (SaveFile.FileName != String.Empty)\r
+ queue.WriteQueueStateToFile(SaveFile.FileName);\r
+ }\r
+ private void mnu_import_Click(object sender, EventArgs e)\r
+ {\r
+ OpenFile.FileName = "";\r
+ OpenFile.ShowDialog();\r
+ if (OpenFile.FileName != String.Empty)\r
+ queue.LoadQueueFromFile(OpenFile.FileName);\r
+ updateUIElements();\r
+ }\r
+ private void mnu_readd_Click(object sender, EventArgs e)\r
+ {\r
+ if (!queue.LastEncode.IsEmpty)\r
+ {\r
+ queue.AddJob(queue.LastEncode.Query, queue.LastEncode.Source, queue.LastEncode.Destination);\r
+ updateUIElements();\r