From 57dc995028ba55fb514d29855bf0e01f1903791b Mon Sep 17 00:00:00 2001 From: sr55 Date: Tue, 9 Sep 2008 16:48:33 +0000 Subject: WinGui: - Allow users to manually import / export the queue. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1682 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/Queue.cs | 16 +++- win/C#/HandBrakeCS.csproj | 4 +- win/C#/Properties/Resources.Designer.cs | 16 +++- win/C#/Properties/Resources.resx | 6 ++ win/C#/Resources/folder.png | Bin 0 -> 3235 bytes win/C#/Resources/save.png | Bin 0 -> 3115 bytes win/C#/frmMain.cs | 4 +- win/C#/frmQueue.Designer.cs | 139 ++++++++++++++++++++------------ win/C#/frmQueue.cs | 48 +++++++---- win/C#/frmQueue.resx | 12 ++- 10 files changed, 169 insertions(+), 76 deletions(-) create mode 100644 win/C#/Resources/folder.png create mode 100644 win/C#/Resources/save.png (limited to 'win/C#') diff --git a/win/C#/Functions/Queue.cs b/win/C#/Functions/Queue.cs index dc2345358..d6c7978de 100644 --- a/win/C#/Functions/Queue.cs +++ b/win/C#/Functions/Queue.cs @@ -101,11 +101,15 @@ namespace Handbrake.Functions /// Writes the current queue to disk. hb_queue_recovery.dat /// This function is called after getNextItemForEncoding() /// - public void write2disk() + public void write2disk(string file) { try { - string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat"); + string tempPath = ""; + if (file == "hb_queue_recovery.dat") + tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat"); + else + tempPath = file; using (StreamWriter writer = new StreamWriter(tempPath)) { foreach (string item in queue) @@ -125,11 +129,15 @@ namespace Handbrake.Functions /// /// Recover the queue from hb_queue_recovery.dat /// - public void recoverQueue() + public void recoverQueue(string file) { try { - string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat"); + string tempPath = ""; + if (file == "hb_queue_recovery.dat") + tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.dat"); + else + tempPath = file; using (StreamReader reader = new StreamReader(tempPath)) { string queue_item = reader.ReadLine(); diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index d643bbb53..801635c09 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -2,7 +2,7 @@ Debug AnyCPU - 9.0.21022 + 9.0.30729 2.0 {A2923D42-C38B-4B12-8CBA-B8D93D6B13A3} WinExe @@ -244,12 +244,14 @@ + + diff --git a/win/C#/Properties/Resources.Designer.cs b/win/C#/Properties/Resources.Designer.cs index f03af9328..ff6d278e5 100644 --- a/win/C#/Properties/Resources.Designer.cs +++ b/win/C#/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 +// Runtime Version:2.0.50727.3053 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -88,6 +88,13 @@ namespace Handbrake.Properties { } } + internal static System.Drawing.Bitmap folder { + get { + object obj = ResourceManager.GetObject("folder", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + internal static System.Drawing.Bitmap General_Preferences { get { object obj = ResourceManager.GetObject("General_Preferences", resourceCulture); @@ -193,6 +200,13 @@ namespace Handbrake.Properties { } } + internal static System.Drawing.Bitmap save { + get { + object obj = ResourceManager.GetObject("save", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + internal static System.Drawing.Bitmap SplashScreen { get { object obj = ResourceManager.GetObject("SplashScreen", resourceCulture); diff --git a/win/C#/Properties/Resources.resx b/win/C#/Properties/Resources.resx index 4fe140efd..c2b74953d 100644 --- a/win/C#/Properties/Resources.resx +++ b/win/C#/Properties/Resources.resx @@ -181,4 +181,10 @@ ..\Resources\stop.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\folder.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\save.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/win/C#/Resources/folder.png b/win/C#/Resources/folder.png new file mode 100644 index 000000000..41fa2c693 Binary files /dev/null and b/win/C#/Resources/folder.png differ diff --git a/win/C#/Resources/save.png b/win/C#/Resources/save.png new file mode 100644 index 000000000..40885d2d3 Binary files /dev/null and b/win/C#/Resources/save.png differ diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 7e673f1e1..e05ea9c1a 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -172,7 +172,7 @@ namespace Handbrake result = MessageBox.Show("HandBrake has detected unfinished items on the queue from the last time the application was launched. Would you like to recover these?", "Queue Recovery Possible", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) - encodeQueue.recoverQueue(); // Start Recovery + encodeQueue.recoverQueue("hb_queue_recovery.dat"); // Start Recovery else { // Remove the Queue recovery file if the user doesn't want to recovery the last queue. @@ -356,7 +356,7 @@ namespace Handbrake query = rtf_query.Text; encodeQueue.add(query); - encodeQueue.write2disk(); // Writes the queue to the recovery file, just incase the GUI crashes. + encodeQueue.write2disk("hb_queue_recovery.dat"); // Writes the queue to the recovery file, just incase the GUI crashes. queueWindow.setQueue(encodeQueue); queueWindow.Show(); diff --git a/win/C#/frmQueue.Designer.cs b/win/C#/frmQueue.Designer.cs index 9c1f87ed0..6c41a4e97 100644 --- a/win/C#/frmQueue.Designer.cs +++ b/win/C#/frmQueue.Designer.cs @@ -50,12 +50,8 @@ namespace Handbrake this.label1 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); - this.btn_encode = new System.Windows.Forms.ToolStripButton(); - this.btn_stop = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.btn_batch = new System.Windows.Forms.ToolStripButton(); this.SaveFile = new System.Windows.Forms.SaveFileDialog(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.list_queue = new System.Windows.Forms.ListView(); this.Title = new System.Windows.Forms.ColumnHeader(); this.Chapters = new System.Windows.Forms.ColumnHeader(); @@ -67,9 +63,17 @@ namespace Handbrake this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.progressBar = new System.Windows.Forms.ToolStripProgressBar(); this.lbl_progressValue = new System.Windows.Forms.ToolStripStatusLabel(); + this.OpenFile = new System.Windows.Forms.OpenFileDialog(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.btn_encode = new System.Windows.Forms.ToolStripButton(); + this.btn_stop = new System.Windows.Forms.ToolStripButton(); + this.drop_button_queue = new System.Windows.Forms.ToolStripDropDownButton(); + this.mnu_batch = new System.Windows.Forms.ToolStripMenuItem(); + this.mnu_import = new System.Windows.Forms.ToolStripMenuItem(); + this.mnu_export = new System.Windows.Forms.ToolStripMenuItem(); this.toolStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.statusStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // btn_down @@ -210,8 +214,7 @@ namespace Handbrake this.btn_encode, this.btn_stop, this.toolStripSeparator1, - this.btn_batch}); - this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow; + this.drop_button_queue}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; @@ -219,56 +222,15 @@ namespace Handbrake this.toolStrip1.TabIndex = 71; this.toolStrip1.Text = "toolStrip1"; // - // btn_encode - // - this.btn_encode.Image = global::Handbrake.Properties.Resources.Play; - this.btn_encode.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.btn_encode.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btn_encode.Name = "btn_encode"; - this.btn_encode.Padding = new System.Windows.Forms.Padding(5); - this.btn_encode.Size = new System.Drawing.Size(88, 46); - this.btn_encode.Text = "Encode"; - this.btn_encode.Click += new System.EventHandler(this.btn_encode_Click); - // - // btn_stop - // - this.btn_stop.Image = global::Handbrake.Properties.Resources.Pause; - this.btn_stop.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.btn_stop.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btn_stop.Name = "btn_stop"; - this.btn_stop.Size = new System.Drawing.Size(72, 46); - this.btn_stop.Text = "Pause"; - this.btn_stop.Visible = false; - this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click); - // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 49); // - // btn_batch - // - this.btn_batch.Image = global::Handbrake.Properties.Resources.ActivityWindow; - this.btn_batch.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; - this.btn_batch.ImageTransparentColor = System.Drawing.Color.Magenta; - this.btn_batch.Name = "btn_batch"; - this.btn_batch.Size = new System.Drawing.Size(100, 46); - this.btn_batch.Text = "Batch Script"; - this.btn_batch.Click += new System.EventHandler(this.btn_batch_Click); - // // SaveFile // this.SaveFile.Filter = "Batch|.bat"; // - // pictureBox1 - // - this.pictureBox1.Image = global::Handbrake.Properties.Resources.Queue; - this.pictureBox1.Location = new System.Drawing.Point(12, 61); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(37, 32); - this.pictureBox1.TabIndex = 61; - this.pictureBox1.TabStop = false; - // // list_queue // this.list_queue.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { @@ -350,6 +312,79 @@ namespace Handbrake this.lbl_progressValue.Size = new System.Drawing.Size(30, 26); this.lbl_progressValue.Text = " 0 %"; // + // OpenFile + // + this.OpenFile.Filter = "HandBrake Queue|*.queue"; + // + // pictureBox1 + // + this.pictureBox1.Image = global::Handbrake.Properties.Resources.Queue; + this.pictureBox1.Location = new System.Drawing.Point(12, 61); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(37, 32); + this.pictureBox1.TabIndex = 61; + this.pictureBox1.TabStop = false; + // + // btn_encode + // + this.btn_encode.Image = global::Handbrake.Properties.Resources.Play; + this.btn_encode.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.btn_encode.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btn_encode.Name = "btn_encode"; + this.btn_encode.Padding = new System.Windows.Forms.Padding(5); + this.btn_encode.Size = new System.Drawing.Size(88, 46); + this.btn_encode.Text = "Encode"; + this.btn_encode.Click += new System.EventHandler(this.btn_encode_Click); + // + // btn_stop + // + this.btn_stop.Image = global::Handbrake.Properties.Resources.Pause; + this.btn_stop.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.btn_stop.ImageTransparentColor = System.Drawing.Color.Magenta; + this.btn_stop.Name = "btn_stop"; + this.btn_stop.Overflow = System.Windows.Forms.ToolStripItemOverflow.Never; + this.btn_stop.Size = new System.Drawing.Size(72, 46); + this.btn_stop.Text = "Pause"; + this.btn_stop.Visible = false; + this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click); + // + // drop_button_queue + // + this.drop_button_queue.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnu_batch, + this.mnu_import, + this.mnu_export}); + this.drop_button_queue.Image = global::Handbrake.Properties.Resources.ActivityWindow; + this.drop_button_queue.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; + this.drop_button_queue.ImageTransparentColor = System.Drawing.Color.Magenta; + this.drop_button_queue.Name = "drop_button_queue"; + this.drop_button_queue.Size = new System.Drawing.Size(84, 46); + this.drop_button_queue.Text = "Queue"; + // + // mnu_batch + // + this.mnu_batch.Image = global::Handbrake.Properties.Resources.Output_Small; + this.mnu_batch.Name = "mnu_batch"; + this.mnu_batch.Size = new System.Drawing.Size(190, 22); + this.mnu_batch.Text = "Generate Batch Script"; + this.mnu_batch.Click += new System.EventHandler(this.mnu_batch_Click); + // + // mnu_import + // + this.mnu_import.Image = global::Handbrake.Properties.Resources.folder; + this.mnu_import.Name = "mnu_import"; + this.mnu_import.Size = new System.Drawing.Size(190, 22); + this.mnu_import.Text = "Import Queue"; + this.mnu_import.Click += new System.EventHandler(this.mnu_import_Click); + // + // mnu_export + // + this.mnu_export.Image = global::Handbrake.Properties.Resources.save; + this.mnu_export.Name = "mnu_export"; + this.mnu_export.Size = new System.Drawing.Size(190, 22); + this.mnu_export.Text = "Export Queue"; + this.mnu_export.Click += new System.EventHandler(this.mnu_export_Click); + // // frmQueue // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 13F); @@ -380,9 +415,9 @@ namespace Handbrake this.Text = "Encode Queue"; this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -408,7 +443,6 @@ namespace Handbrake private System.Windows.Forms.ToolStripButton btn_encode; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripButton btn_stop; - private System.Windows.Forms.ToolStripButton btn_batch; private System.Windows.Forms.SaveFileDialog SaveFile; private System.Windows.Forms.ListView list_queue; private System.Windows.Forms.ColumnHeader Title; @@ -421,5 +455,10 @@ namespace Handbrake private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripProgressBar progressBar; private System.Windows.Forms.ToolStripStatusLabel lbl_progressValue; + private System.Windows.Forms.ToolStripDropDownButton drop_button_queue; + private System.Windows.Forms.ToolStripMenuItem mnu_batch; + private System.Windows.Forms.ToolStripMenuItem mnu_import; + private System.Windows.Forms.ToolStripMenuItem mnu_export; + private System.Windows.Forms.OpenFileDialog OpenFile; } } \ No newline at end of file diff --git a/win/C#/frmQueue.cs b/win/C#/frmQueue.cs index 1cf293033..670153c96 100644 --- a/win/C#/frmQueue.cs +++ b/win/C#/frmQueue.cs @@ -110,7 +110,7 @@ namespace Handbrake btn_stop.Visible = true; progressBar.Value = 0; lbl_progressValue.Text = "0 %"; - progressBar.Step = 100 / queue.count(); + progressBar.Step = 100 / queue.count(); Thread theQ = new Thread(startProc); theQ.IsBackground = true; theQ.Start(); @@ -279,7 +279,7 @@ namespace Handbrake if (list_queue.SelectedIndices.Count != 0) { queue.moveUp(list_queue.SelectedIndices[0]); - queue.write2disk(); // Update the queue recovery file + queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file redrawQueue(); } } @@ -290,7 +290,7 @@ namespace Handbrake if (list_queue.SelectedIndices.Count != 0) { queue.moveDown(list_queue.SelectedIndices[0]); - queue.write2disk(); // Update the queue recovery file + queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file redrawQueue(); } } @@ -301,16 +301,30 @@ namespace Handbrake if (list_queue.SelectedIndices.Count != 0) { queue.remove(list_queue.SelectedIndices[0]); - queue.write2disk(); // Update the queue recovery file + queue.write2disk("hb_queue_recovery.dat"); // Update the queue recovery file redrawQueue(); } } - // Generate a batch file script to run the encode seperate of HandBrake - private void btn_batch_Click(object sender, EventArgs e) + + // Hide's the window from the users view. + private void btn_Close_Click(object sender, EventArgs e) + { + this.Hide(); + } + + // Hide's the window when the user tries to "x" out of the window instead of closing it. + protected override void OnClosing(CancelEventArgs e) + { + e.Cancel = true; + this.Hide(); + base.OnClosing(e); + } + + private void mnu_batch_Click(object sender, EventArgs e) { string queries = ""; - foreach (string query_item in queue.getQueue()) + foreach (string query_item in queue.getQueue()) { string fullQuery = '"' + Application.StartupPath.ToString() + "\\HandBrakeCLI.exe" + '"' + query_item; @@ -321,6 +335,7 @@ namespace Handbrake } string strCmdLine = queries; + SaveFile.Filter = "Batch|.bat"; SaveFile.ShowDialog(); string filename = SaveFile.FileName; @@ -344,19 +359,22 @@ namespace Handbrake } } - // Hide's the window from the users view. - private void btn_Close_Click(object sender, EventArgs e) + private void mnu_export_Click(object sender, EventArgs e) { - this.Hide(); + SaveFile.Filter = "HandBrake Queue|*.queue"; + SaveFile.ShowDialog(); + if (SaveFile.FileName != String.Empty) + queue.write2disk(SaveFile.FileName); } - // Hide's the window when the user tries to "x" out of the window instead of closing it. - protected override void OnClosing(CancelEventArgs e) + private void mnu_import_Click(object sender, EventArgs e) { - e.Cancel = true; - this.Hide(); - base.OnClosing(e); + OpenFile.ShowDialog(); + if (OpenFile.FileName != String.Empty) + queue.recoverQueue(OpenFile.FileName); + redrawQueue(); } + } } \ No newline at end of file diff --git a/win/C#/frmQueue.resx b/win/C#/frmQueue.resx index 8e6968fbb..4e272770b 100644 --- a/win/C#/frmQueue.resx +++ b/win/C#/frmQueue.resx @@ -121,13 +121,19 @@ 17, 17 - 109, 17 + 93, 17 - 208, 17 + 176, 17 - 300, 17 + 366, 17 + + + 252, 17 + + + True -- cgit v1.2.3