From 814e73cb615fcd97b9fcd133c98fd261f303363b Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 7 May 2010 18:58:46 +0000 Subject: [PATCH] WinGui: - Added Export support to the Chapters Tab. git-svn-id: svn://localhost/HandBrake/trunk@3287 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/Main.cs | 32 +++++++++++ win/C#/frmMain.Designer.cs | 139 +++++++++++++++++++++++++-------------------- win/C#/frmMain.cs | 14 +++++ win/C#/frmMain.resx | 10 ++++ 4 files changed, 134 insertions(+), 61 deletions(-) diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 80d806b4..552c6a95 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -136,6 +136,38 @@ namespace Handbrake.Functions } /// + /// Create a CSV file with the data from the Main Window Chapters tab + /// + /// Main Window + /// Path to save the csv file + /// True if successful + public static bool SaveChapterMarkersToCsv(frmMain mainWindow, string filePathName) + { + try + { + string csv = string.Empty; + + foreach (DataGridViewRow row in mainWindow.data_chpt.Rows) + { + csv += row.Cells[0].Value.ToString(); + csv += ","; + csv += row.Cells[1].Value.ToString().Replace(",", "\\,"); + csv += Environment.NewLine; + } + StreamWriter file = new StreamWriter(filePathName); + file.Write(csv); + file.Close(); + file.Dispose(); + return true; + } + catch (Exception exc) + { + MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return false; + } + } + + /// /// Function which generates the filename and path automatically based on /// the Source Name, DVD title and DVD Chapters /// diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index f9e2d11a..99ae3eb9 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -98,7 +98,6 @@ namespace Handbrake this.Label47 = new System.Windows.Forms.Label(); this.Label3 = new System.Windows.Forms.Label(); this.tab_audio = new System.Windows.Forms.TabPage(); - this.AudioSettings = new Handbrake.Controls.AudioPanel(); this.AudioMenuRowHeightHack = new System.Windows.Forms.ImageList(this.components); this.tab_video = new System.Windows.Forms.TabPage(); this.radio_cq = new System.Windows.Forms.RadioButton(); @@ -110,17 +109,13 @@ namespace Handbrake this.lbl_SliderValue = new System.Windows.Forms.Label(); this.Label46 = new System.Windows.Forms.Label(); this.tab_picture = new System.Windows.Forms.TabPage(); - this.PictureSettings = new Handbrake.Controls.PictureSettings(); this.Check_ChapterMarkers = new System.Windows.Forms.CheckBox(); this.tabs_panel = new System.Windows.Forms.TabControl(); this.tab_filters = new System.Windows.Forms.TabPage(); - this.Filters = new Handbrake.Controls.Filters(); this.tab_subtitles = new System.Windows.Forms.TabPage(); - this.Subtitles = new Handbrake.Controls.Subtitles(); this.tab_chapters = new System.Windows.Forms.TabPage(); this.label31 = new System.Windows.Forms.Label(); this.tab_advanced = new System.Windows.Forms.TabPage(); - this.x264Panel = new Handbrake.Controls.x264Panel(); this.tab_query = new System.Windows.Forms.TabPage(); this.btn_clear = new System.Windows.Forms.Button(); this.label34 = new System.Windows.Forms.Label(); @@ -172,6 +167,12 @@ namespace Handbrake this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.openPreset = new System.Windows.Forms.OpenFileDialog(); this.File_ChapterImport = new System.Windows.Forms.OpenFileDialog(); + this.btn_export = new System.Windows.Forms.Button(); + this.PictureSettings = new Handbrake.Controls.PictureSettings(); + this.Filters = new Handbrake.Controls.Filters(); + this.AudioSettings = new Handbrake.Controls.AudioPanel(); + this.Subtitles = new Handbrake.Controls.Subtitles(); + this.x264Panel = new Handbrake.Controls.x264Panel(); notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components); notifyIconMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.slider_videoQuality)).BeginInit(); @@ -274,7 +275,7 @@ namespace Handbrake this.check_turbo.Enabled = false; this.check_turbo.Location = new System.Drawing.Point(146, 123); this.check_turbo.Name = "check_turbo"; - this.check_turbo.Size = new System.Drawing.Size(99, 17); + this.check_turbo.Size = new System.Drawing.Size(101, 17); this.check_turbo.TabIndex = 7; this.check_turbo.Text = "Turbo first Pass"; this.ToolTip.SetToolTip(this.check_turbo, "Makes the first pass of a 2 pass encode faster."); @@ -523,7 +524,7 @@ namespace Handbrake this.btn_importChapters.AutoSize = true; this.btn_importChapters.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.btn_importChapters.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); - this.btn_importChapters.Location = new System.Drawing.Point(625, 26); + this.btn_importChapters.Location = new System.Drawing.Point(544, 28); this.btn_importChapters.Name = "btn_importChapters"; this.btn_importChapters.Size = new System.Drawing.Size(75, 23); this.btn_importChapters.TabIndex = 14; @@ -793,15 +794,6 @@ namespace Handbrake this.tab_audio.Text = "Audio"; this.tab_audio.UseVisualStyleBackColor = true; // - // AudioSettings - // - this.AudioSettings.BackColor = System.Drawing.Color.Transparent; - this.AudioSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.AudioSettings.Location = new System.Drawing.Point(0, 0); - this.AudioSettings.Name = "AudioSettings"; - this.AudioSettings.Size = new System.Drawing.Size(715, 310); - this.AudioSettings.TabIndex = 0; - // // AudioMenuRowHeightHack // this.AudioMenuRowHeightHack.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; @@ -840,7 +832,7 @@ namespace Handbrake this.radio_cq.BackColor = System.Drawing.Color.Transparent; this.radio_cq.Location = new System.Drawing.Point(336, 97); this.radio_cq.Name = "radio_cq"; - this.radio_cq.Size = new System.Drawing.Size(105, 17); + this.radio_cq.Size = new System.Drawing.Size(110, 17); this.radio_cq.TabIndex = 18; this.radio_cq.Text = "Constant Quality:"; this.radio_cq.UseVisualStyleBackColor = false; @@ -853,7 +845,7 @@ namespace Handbrake this.radio_avgBitrate.Checked = true; this.radio_avgBitrate.Location = new System.Drawing.Point(336, 64); this.radio_avgBitrate.Name = "radio_avgBitrate"; - this.radio_avgBitrate.Size = new System.Drawing.Size(112, 17); + this.radio_avgBitrate.Size = new System.Drawing.Size(116, 17); this.radio_avgBitrate.TabIndex = 17; this.radio_avgBitrate.TabStop = true; this.radio_avgBitrate.Text = "Avg Bitrate (kbps):"; @@ -866,7 +858,7 @@ namespace Handbrake this.radio_targetFilesize.BackColor = System.Drawing.Color.Transparent; this.radio_targetFilesize.Location = new System.Drawing.Point(336, 37); this.radio_targetFilesize.Name = "radio_targetFilesize"; - this.radio_targetFilesize.Size = new System.Drawing.Size(107, 17); + this.radio_targetFilesize.Size = new System.Drawing.Size(108, 17); this.radio_targetFilesize.TabIndex = 16; this.radio_targetFilesize.Text = "Target Size (MB):"; this.radio_targetFilesize.UseVisualStyleBackColor = false; @@ -889,7 +881,7 @@ namespace Handbrake this.check_2PassEncode.BackColor = System.Drawing.Color.Transparent; this.check_2PassEncode.Location = new System.Drawing.Point(125, 100); this.check_2PassEncode.Name = "check_2PassEncode"; - this.check_2PassEncode.Size = new System.Drawing.Size(106, 17); + this.check_2PassEncode.Size = new System.Drawing.Size(104, 17); this.check_2PassEncode.TabIndex = 6; this.check_2PassEncode.Text = "2-Pass Encoding"; this.check_2PassEncode.UseVisualStyleBackColor = false; @@ -939,25 +931,13 @@ namespace Handbrake this.tab_picture.Text = "Picture"; this.tab_picture.UseVisualStyleBackColor = true; // - // PictureSettings - // - this.PictureSettings.BackColor = System.Drawing.Color.Transparent; - this.PictureSettings.CurrentlySelectedPreset = null; - this.PictureSettings.Enabled = false; - this.PictureSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.PictureSettings.Location = new System.Drawing.Point(0, 0); - this.PictureSettings.Name = "PictureSettings"; - this.PictureSettings.PresetMaximumResolution = new System.Drawing.Size(0, 0); - this.PictureSettings.Size = new System.Drawing.Size(666, 279); - this.PictureSettings.TabIndex = 0; - // // Check_ChapterMarkers // this.Check_ChapterMarkers.AutoSize = true; this.Check_ChapterMarkers.BackColor = System.Drawing.Color.Transparent; this.Check_ChapterMarkers.Location = new System.Drawing.Point(16, 32); this.Check_ChapterMarkers.Name = "Check_ChapterMarkers"; - this.Check_ChapterMarkers.Size = new System.Drawing.Size(136, 17); + this.Check_ChapterMarkers.Size = new System.Drawing.Size(140, 17); this.Check_ChapterMarkers.TabIndex = 1; this.Check_ChapterMarkers.Text = "Create chapter markers"; this.Check_ChapterMarkers.UseVisualStyleBackColor = false; @@ -990,15 +970,6 @@ namespace Handbrake this.tab_filters.Text = "Video Filters"; this.tab_filters.UseVisualStyleBackColor = true; // - // Filters - // - this.Filters.BackColor = System.Drawing.Color.Transparent; - this.Filters.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Filters.Location = new System.Drawing.Point(0, 0); - this.Filters.Name = "Filters"; - this.Filters.Size = new System.Drawing.Size(713, 310); - this.Filters.TabIndex = 0; - // // tab_subtitles // this.tab_subtitles.Controls.Add(this.Subtitles); @@ -1010,18 +981,10 @@ namespace Handbrake this.tab_subtitles.Text = "Subtitles"; this.tab_subtitles.UseVisualStyleBackColor = true; // - // Subtitles - // - this.Subtitles.BackColor = System.Drawing.Color.Transparent; - this.Subtitles.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Subtitles.Location = new System.Drawing.Point(0, 0); - this.Subtitles.Name = "Subtitles"; - this.Subtitles.Size = new System.Drawing.Size(722, 310); - this.Subtitles.TabIndex = 0; - // // tab_chapters // this.tab_chapters.BackColor = System.Drawing.Color.Transparent; + this.tab_chapters.Controls.Add(this.btn_export); this.tab_chapters.Controls.Add(this.btn_importChapters); this.tab_chapters.Controls.Add(this.label31); this.tab_chapters.Controls.Add(this.data_chpt); @@ -1056,16 +1019,6 @@ namespace Handbrake this.tab_advanced.Text = "Advanced"; this.tab_advanced.UseVisualStyleBackColor = true; // - // x264Panel - // - this.x264Panel.BackColor = System.Drawing.Color.Transparent; - this.x264Panel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.x264Panel.Location = new System.Drawing.Point(0, 0); - this.x264Panel.Name = "x264Panel"; - this.x264Panel.Size = new System.Drawing.Size(720, 306); - this.x264Panel.TabIndex = 0; - this.x264Panel.X264Query = ""; - // // tab_query // this.tab_query.Controls.Add(this.btn_clear); @@ -1623,6 +1576,69 @@ namespace Handbrake // this.File_ChapterImport.Filter = "CSV Files|*.csv"; // + // btn_export + // + this.btn_export.AutoSize = true; + this.btn_export.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_export.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); + this.btn_export.Location = new System.Drawing.Point(625, 28); + this.btn_export.Name = "btn_export"; + this.btn_export.Size = new System.Drawing.Size(75, 23); + this.btn_export.TabIndex = 15; + this.btn_export.Text = "Export"; + this.ToolTip.SetToolTip(this.btn_export, resources.GetString("btn_export.ToolTip")); + this.btn_export.UseVisualStyleBackColor = true; + this.btn_export.Click += new System.EventHandler(this.btn_export_Click); + // + // PictureSettings + // + this.PictureSettings.BackColor = System.Drawing.Color.Transparent; + this.PictureSettings.CurrentlySelectedPreset = null; + this.PictureSettings.Enabled = false; + this.PictureSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.PictureSettings.Location = new System.Drawing.Point(0, 0); + this.PictureSettings.Name = "PictureSettings"; + this.PictureSettings.PresetMaximumResolution = new System.Drawing.Size(0, 0); + this.PictureSettings.Size = new System.Drawing.Size(666, 279); + this.PictureSettings.TabIndex = 0; + // + // Filters + // + this.Filters.BackColor = System.Drawing.Color.Transparent; + this.Filters.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Filters.Location = new System.Drawing.Point(0, 0); + this.Filters.Name = "Filters"; + this.Filters.Size = new System.Drawing.Size(713, 310); + this.Filters.TabIndex = 0; + // + // AudioSettings + // + this.AudioSettings.BackColor = System.Drawing.Color.Transparent; + this.AudioSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.AudioSettings.Location = new System.Drawing.Point(0, 0); + this.AudioSettings.Name = "AudioSettings"; + this.AudioSettings.Size = new System.Drawing.Size(715, 310); + this.AudioSettings.TabIndex = 0; + // + // Subtitles + // + this.Subtitles.BackColor = System.Drawing.Color.Transparent; + this.Subtitles.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Subtitles.Location = new System.Drawing.Point(0, 0); + this.Subtitles.Name = "Subtitles"; + this.Subtitles.Size = new System.Drawing.Size(722, 310); + this.Subtitles.TabIndex = 0; + // + // x264Panel + // + this.x264Panel.BackColor = System.Drawing.Color.Transparent; + this.x264Panel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.x264Panel.Location = new System.Drawing.Point(0, 0); + this.x264Panel.Name = "x264Panel"; + this.x264Panel.Size = new System.Drawing.Size(720, 306); + this.x264Panel.TabIndex = 0; + this.x264Panel.X264Query = ""; + // // frmMain // this.AllowDrop = true; @@ -1823,5 +1839,6 @@ namespace Handbrake private ToolStripMenuItem pmnu_import; private ToolStripSeparator toolStripSeparator2; internal ComboBox drop_mode; + private Button btn_export; } } \ No newline at end of file diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 0b89a573..bfa40541 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -1605,6 +1605,19 @@ namespace Handbrake } } + private void btn_export_Click(object sender, EventArgs e) + { + SaveFileDialog saveFileDialog = new SaveFileDialog(); + saveFileDialog.Filter = "Csv File|*.csv"; + saveFileDialog.DefaultExt = "csv"; + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + string filename = saveFileDialog.FileName; + + Main.SaveChapterMarkersToCsv(this, filename); + } + } + private void mnu_resetChapters_Click(object sender, EventArgs e) { data_chpt.Rows.Clear(); @@ -2075,6 +2088,7 @@ namespace Handbrake #endregion + // This is the END of the road **************************************** } } \ No newline at end of file diff --git a/win/C#/frmMain.resx b/win/C#/frmMain.resx index a3662bdb..56640387 100644 --- a/win/C#/frmMain.resx +++ b/win/C#/frmMain.resx @@ -169,6 +169,16 @@ Note: Currently, if you wish to use a , in your chapter name, you must escape it 392, 54 + + Import a comma separated file containing the chapter information. +The CSV should be formatted as follows: + +1,Chapter 1 Name +2,Chapter 2 Name +3,Chapter 3 Name + +Note: Currently, if you wish to use a , in your chapter name, you must escape it with a \ + 265, 54 -- 2.11.0