OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / Queue.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 using System.Collections;\r
5 \r
6 namespace Handbrake.Functions\r
7 {\r
8     public class Queue\r
9     {\r
10         ArrayList queue = new ArrayList();\r
11         string lastQuery;\r
12 \r
13         public ArrayList getQueue()\r
14         {\r
15             return queue;\r
16         }\r
17 \r
18         /// <summary>\r
19         /// Get's the next CLI query for encoding\r
20         /// </summary>\r
21         /// <returns>String</returns>\r
22         public string getNextItemForEncoding()\r
23         {\r
24             string query = queue[0].ToString();\r
25             lastQuery = query;\r
26             remove(0);\r
27             return query;\r
28         }\r
29 \r
30         /// <summary>\r
31         /// Add's a new item to the queue\r
32         /// </summary>\r
33         /// <param name="query">String</param>\r
34         public void add(string query)\r
35         {\r
36             queue.Add(query);\r
37         }\r
38 \r
39         /// <summary>\r
40         /// Removes an item from the queue.\r
41         /// </summary>\r
42         /// <param name="index">Index</param>\r
43         /// <returns>Bolean true if successful</returns>\r
44         public Boolean remove(int index)\r
45         {\r
46             try\r
47             {\r
48                 queue.RemoveAt(index);\r
49                 return true;\r
50             }\r
51             catch (Exception)\r
52             {\r
53                 return false;\r
54             }\r
55         }\r
56 \r
57         /// <summary>\r
58         /// Returns how many items are in the queue\r
59         /// </summary>\r
60         /// <returns>Int</returns>\r
61         public int count()\r
62         {\r
63             return queue.Count;\r
64         }\r
65 \r
66         /// <summary>\r
67         /// Get's the last query to be selected for encoding by getNextItemForEncoding()\r
68         /// </summary>\r
69         /// <returns>String</returns>\r
70         public string getLastQuery()\r
71         {\r
72             return lastQuery;\r
73         }\r
74 \r
75         /// <summary>\r
76         /// Move an item with an index x, up in the queue\r
77         /// </summary>\r
78         /// <param name="index">Int</param>\r
79         public void moveUp(int index)\r
80         {\r
81             if (index != 0)\r
82             {\r
83                 string item = queue[index].ToString();\r
84 \r
85                 queue.Insert((index - 1), item);\r
86                 queue.RemoveAt((index + 1));\r
87             }\r
88         }\r
89 \r
90         /// <summary>\r
91         /// Move an item with an index x, down in the queue\r
92         /// </summary>\r
93         /// <param name="index">Int</param>\r
94         public void moveDown(int index)\r
95         {\r
96             if (index != queue.Count - 1)\r
97             {\r
98                 string item = queue[index].ToString();\r
99 \r
100                 queue.Insert((index + 2), item);\r
101                 queue.RemoveAt((index));\r
102             }\r
103         }\r
104 \r
105     }\r
106 }\r