diff options
Diffstat (limited to 'win/C#/frmQueue.cs')
-rw-r--r-- | win/C#/frmQueue.cs | 86 |
1 files changed, 75 insertions, 11 deletions
diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index e806ad879..143533196 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -5,36 +5,100 @@ using System.Data; using System.Drawing;
using System.Text;
using System.Windows.Forms;
+using System.Threading;
+using System.Diagnostics;
namespace Handbrake
{
public partial class frmQueue : Form
{
- private string query = "";
+ private frmQueue thisWindow;
- public frmQueue(string query)
+ public frmQueue()
{
InitializeComponent();
- this.query = query;
}
- public void addItem(String item)
+ private void btn_Close_Click(object sender, EventArgs e)
{
- list_queue.Items.Add(item);
- MessageBox.Show("test");
+ this.Hide();
}
- private void btn_Close_Click(object sender, EventArgs e)
+ private void btn_delete_Click(object sender, EventArgs e)
+ {
+ list_queue.Items.Remove(list_queue.SelectedItem);
+ }
+
+ private void btn_up_Click(object sender, EventArgs e)
+ {
+ int count = list_queue.Items.Count;
+ int itemToMove = list_queue.SelectedIndex;
+ int previousItemint = 0;
+ String previousItem = "";
+
+ if (itemToMove > 0){
+ previousItemint = itemToMove - 1;
+ previousItem = list_queue.Items[previousItemint].ToString();
+ list_queue.Items[previousItemint] = list_queue.Items[itemToMove];
+ list_queue.Items[itemToMove] = previousItem;
+ list_queue.SelectedIndex = list_queue.SelectedIndex - 1;
+ }
+ }
+
+ private void btn_down_Click(object sender, EventArgs e)
{
- this.Close();
+ int count = list_queue.Items.Count;
+ int itemToMove = list_queue.SelectedIndex;
+ int itemAfterInt = 0;
+ String itemAfter = "";
+
+ if (itemToMove < (count - 1))
+ {
+ itemAfterInt = itemToMove + 1;
+ itemAfter = list_queue.Items[itemAfterInt].ToString();
+ list_queue.Items[itemAfterInt] = list_queue.Items[itemToMove];
+ list_queue.Items[itemToMove] = itemAfter;
+ list_queue.SelectedIndex = list_queue.SelectedIndex + 1;
+ }
}
- private void frmQueue_Load(object sender, EventArgs e)
+ private void btn_q_encoder_Click(object sender, EventArgs e)
{
- addItem(query);
- MessageBox.Show("test");
+ progressBar.Value = 0;
+ lbl_progressValue.Text = "0 %";
+ progressBar.Update();
+ ThreadPool.QueueUserWorkItem(startProc);
}
+ private void startProc(object state)
+ {
+ int listSize = list_queue.Items.Count;
+ listSize--;
+ int counter = 0;
+ int progressSplit = listSize / 100;
+
+ while (counter <= listSize)
+ {
+ String query = list_queue.Items[0].ToString();
+ Process hbProc = new Process();
+ hbProc.StartInfo.FileName = "hbcli.exe";
+ hbProc.StartInfo.Arguments = query;
+ hbProc.StartInfo.UseShellExecute = false;
+ hbProc.Start();
+ hbProc.WaitForExit();
+ hbProc.Close();
+ counter++;
+ //updateUIElements(progressSplit);
+ }
+ }
+
+ private void updateUIElements(int progressSplit)
+ {
+ // This needs to be written so there is no cross-thread problems
+ thisWindow.list_queue.Items.Remove(0);
+ progressBar.Value = progressBar.Value + progressSplit;
+ progressBar.Update();
+ }
}
}
\ No newline at end of file |