From: sr55 Date: Sun, 14 Jun 2009 12:00:46 +0000 (+0000) Subject: WinGui: X-Git-Tag: 0.9.4~430 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=729ff4e83ad9c402fd322922e38c6b75f55508e0;p=handbrake WinGui: - Missed the new subtitle files in the last check-in. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2532 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/C#/Controls/Subtitles.Designer.cs b/win/C#/Controls/Subtitles.Designer.cs new file mode 100644 index 000000000..86e60febb --- /dev/null +++ b/win/C#/Controls/Subtitles.Designer.cs @@ -0,0 +1,242 @@ +namespace Handbrake.Controls +{ + partial class Subtitles + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.drp_subtitleTracks = new System.Windows.Forms.ComboBox(); + this.AudioTrackGroup = new System.Windows.Forms.GroupBox(); + this.label1 = new System.Windows.Forms.Label(); + this.check_default = new System.Windows.Forms.CheckBox(); + this.check_burned = new System.Windows.Forms.CheckBox(); + this.check_forced = new System.Windows.Forms.CheckBox(); + this.btn_addSubTrack = new System.Windows.Forms.Button(); + this.btn_RemoveSubTrack = new System.Windows.Forms.Button(); + this.lv_subList = new System.Windows.Forms.ListView(); + this.id = new System.Windows.Forms.ColumnHeader(); + this.col_Source = new System.Windows.Forms.ColumnHeader(); + this.forced = new System.Windows.Forms.ColumnHeader(); + this.burned = new System.Windows.Forms.ColumnHeader(); + this.defaultTrack = new System.Windows.Forms.ColumnHeader(); + this.label68 = new System.Windows.Forms.Label(); + this.AudioTrackGroup.SuspendLayout(); + this.SuspendLayout(); + // + // drp_subtitleTracks + // + this.drp_subtitleTracks.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.drp_subtitleTracks.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.drp_subtitleTracks.FormattingEnabled = true; + this.drp_subtitleTracks.Location = new System.Drawing.Point(57, 20); + this.drp_subtitleTracks.Name = "drp_subtitleTracks"; + this.drp_subtitleTracks.Size = new System.Drawing.Size(194, 20); + this.drp_subtitleTracks.TabIndex = 50; + this.drp_subtitleTracks.SelectedIndexChanged += new System.EventHandler(this.drp_subtitleTracks_SelectedIndexChanged); + // + // AudioTrackGroup + // + this.AudioTrackGroup.BackColor = System.Drawing.Color.Transparent; + this.AudioTrackGroup.Controls.Add(this.label1); + this.AudioTrackGroup.Controls.Add(this.check_default); + this.AudioTrackGroup.Controls.Add(this.check_burned); + this.AudioTrackGroup.Controls.Add(this.check_forced); + this.AudioTrackGroup.Controls.Add(this.drp_subtitleTracks); + this.AudioTrackGroup.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.AudioTrackGroup.ForeColor = System.Drawing.Color.Black; + this.AudioTrackGroup.Location = new System.Drawing.Point(16, 32); + this.AudioTrackGroup.Name = "AudioTrackGroup"; + this.AudioTrackGroup.Size = new System.Drawing.Size(689, 50); + this.AudioTrackGroup.TabIndex = 71; + this.AudioTrackGroup.TabStop = false; + this.AudioTrackGroup.Text = "Selected Track: New Track"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(6, 22); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(44, 13); + this.label1.TabIndex = 72; + this.label1.Text = "Track:"; + // + // check_default + // + this.check_default.AutoSize = true; + this.check_default.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.check_default.Location = new System.Drawing.Point(446, 21); + this.check_default.Name = "check_default"; + this.check_default.Size = new System.Drawing.Size(67, 17); + this.check_default.TabIndex = 71; + this.check_default.Text = "Default"; + this.check_default.UseVisualStyleBackColor = true; + this.check_default.CheckedChanged += new System.EventHandler(this.check_default_CheckedChanged); + // + // check_burned + // + this.check_burned.AutoSize = true; + this.check_burned.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.check_burned.Location = new System.Drawing.Point(357, 21); + this.check_burned.Name = "check_burned"; + this.check_burned.Size = new System.Drawing.Size(83, 17); + this.check_burned.TabIndex = 70; + this.check_burned.Text = "Burned In"; + this.check_burned.UseVisualStyleBackColor = true; + this.check_burned.CheckedChanged += new System.EventHandler(this.check_burned_CheckedChanged); + // + // check_forced + // + this.check_forced.AutoSize = true; + this.check_forced.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.check_forced.Location = new System.Drawing.Point(257, 21); + this.check_forced.Name = "check_forced"; + this.check_forced.Size = new System.Drawing.Size(94, 17); + this.check_forced.TabIndex = 69; + this.check_forced.Text = "Forced Only"; + this.check_forced.UseVisualStyleBackColor = true; + this.check_forced.CheckedChanged += new System.EventHandler(this.check_forced_CheckedChanged); + // + // btn_addSubTrack + // + this.btn_addSubTrack.BackColor = System.Drawing.Color.Transparent; + this.btn_addSubTrack.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_addSubTrack.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); + this.btn_addSubTrack.Location = new System.Drawing.Point(16, 274); + this.btn_addSubTrack.Name = "btn_addSubTrack"; + this.btn_addSubTrack.Size = new System.Drawing.Size(111, 23); + this.btn_addSubTrack.TabIndex = 68; + this.btn_addSubTrack.Text = "Add Track"; + this.btn_addSubTrack.UseVisualStyleBackColor = false; + this.btn_addSubTrack.Click += new System.EventHandler(this.btn_addSubTrack_Click); + // + // btn_RemoveSubTrack + // + this.btn_RemoveSubTrack.BackColor = System.Drawing.Color.Transparent; + this.btn_RemoveSubTrack.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btn_RemoveSubTrack.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0))))); + this.btn_RemoveSubTrack.Location = new System.Drawing.Point(133, 274); + this.btn_RemoveSubTrack.Name = "btn_RemoveSubTrack"; + this.btn_RemoveSubTrack.Size = new System.Drawing.Size(111, 23); + this.btn_RemoveSubTrack.TabIndex = 69; + this.btn_RemoveSubTrack.Text = "Remove"; + this.btn_RemoveSubTrack.UseVisualStyleBackColor = false; + this.btn_RemoveSubTrack.Click += new System.EventHandler(this.btn_RemoveSubTrack_Click); + // + // lv_subList + // + this.lv_subList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.id, + this.col_Source, + this.forced, + this.burned, + this.defaultTrack}); + this.lv_subList.FullRowSelect = true; + this.lv_subList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.lv_subList.HideSelection = false; + this.lv_subList.LabelWrap = false; + this.lv_subList.Location = new System.Drawing.Point(17, 88); + this.lv_subList.MultiSelect = false; + this.lv_subList.Name = "lv_subList"; + this.lv_subList.Size = new System.Drawing.Size(688, 180); + this.lv_subList.TabIndex = 70; + this.lv_subList.UseCompatibleStateImageBehavior = false; + this.lv_subList.View = System.Windows.Forms.View.Details; + this.lv_subList.SelectedIndexChanged += new System.EventHandler(this.lb_subList_SelectedIndexChanged); + // + // id + // + this.id.Text = "Track ID"; + this.id.Width = 70; + // + // col_Source + // + this.col_Source.Text = "Track"; + this.col_Source.Width = 250; + // + // forced + // + this.forced.Text = "Forced Only"; + this.forced.Width = 88; + // + // burned + // + this.burned.Text = "Burned In"; + this.burned.Width = 100; + // + // defaultTrack + // + this.defaultTrack.Text = "Default"; + this.defaultTrack.Width = 100; + // + // label68 + // + this.label68.AutoSize = true; + this.label68.BackColor = System.Drawing.Color.Transparent; + this.label68.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label68.Location = new System.Drawing.Point(13, 13); + this.label68.Name = "label68"; + this.label68.Size = new System.Drawing.Size(64, 13); + this.label68.TabIndex = 67; + this.label68.Text = "Subtitles"; + // + // Subtitles + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.BackColor = System.Drawing.Color.Transparent; + this.Controls.Add(this.AudioTrackGroup); + this.Controls.Add(this.btn_RemoveSubTrack); + this.Controls.Add(this.lv_subList); + this.Controls.Add(this.label68); + this.Controls.Add(this.btn_addSubTrack); + this.Name = "Subtitles"; + this.Size = new System.Drawing.Size(719, 300); + this.AudioTrackGroup.ResumeLayout(false); + this.AudioTrackGroup.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + internal System.Windows.Forms.ComboBox drp_subtitleTracks; + private System.Windows.Forms.GroupBox AudioTrackGroup; + private System.Windows.Forms.Button btn_RemoveSubTrack; + private System.Windows.Forms.Button btn_addSubTrack; + internal System.Windows.Forms.ListView lv_subList; + private System.Windows.Forms.ColumnHeader id; + private System.Windows.Forms.ColumnHeader col_Source; + private System.Windows.Forms.ColumnHeader forced; + private System.Windows.Forms.ColumnHeader burned; + internal System.Windows.Forms.Label label68; + private System.Windows.Forms.ColumnHeader defaultTrack; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox check_default; + private System.Windows.Forms.CheckBox check_burned; + private System.Windows.Forms.CheckBox check_forced; + } +} diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs new file mode 100644 index 000000000..4fa1186a3 --- /dev/null +++ b/win/C#/Controls/Subtitles.cs @@ -0,0 +1,217 @@ +using System; +using System.Windows.Forms; + +namespace Handbrake.Controls +{ + public partial class Subtitles : UserControl + { + + // TODO + // - Right click menu for adding/removal of tracks. + // - Multi-select for removal. + + public Subtitles() + { + InitializeComponent(); + } + public int setContainer { get; set; } + + // Controls + private void btn_addSubTrack_Click(object sender, EventArgs e) + { + string forcedVal = "No"; + string burnedVal = "No"; + string defaultSub = "No"; + + if (check_forced.Checked) + forcedVal = "Yes"; + + if (check_burned.Checked) + { + if (!drp_subtitleTracks.Text.Contains("Text")) + { + burnedVal = "Yes"; + setNoBurned(); + } + } + + if (check_default.Checked) + { + defaultSub = "Yes"; + setNoDefault(); + } + + Boolean addTrack = true; + if (setContainer == 0 || setContainer == 1) + { + burnedVal = "Yes"; // MP4 must have bitmap subs burned in. + + // Make sure we only have 1 bitmap track. + if (drp_subtitleTracks.SelectedItem.ToString().Contains("Bitmap")) + foreach (ListViewItem item in lv_subList.Items) + { + if (item.SubItems[1].Text.Contains("Bitmap")) + { + MessageBox.Show(this, + "MP4 files can only have 1 bitmap track. If you wish to have multiple bitmap tracks you should consider using MKV if suitable.", + "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + addTrack = false; + } + } + } + + // Add the track if allowed. + if (addTrack) + { + ListViewItem newTrack = new ListViewItem(getNewID().ToString()); + + newTrack.SubItems.Add(drp_subtitleTracks.SelectedItem.ToString()); + newTrack.SubItems.Add(forcedVal); + newTrack.SubItems.Add(burnedVal); + newTrack.SubItems.Add(defaultSub); + + lv_subList.Items.Add(newTrack); + } + } + private void btn_RemoveSubTrack_Click(object sender, EventArgs e) + { + removeTrack(); + } + private void lb_subList_SelectedIndexChanged(object sender, EventArgs e) + { + // Set the dropdown controls based on the selected item in the List. + if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0) + { + // Reset the checkboxes + check_forced.CheckState = CheckState.Unchecked; + check_burned.CheckState = CheckState.Unchecked; + check_default.CheckState = CheckState.Unchecked; + + // Setup the controls + int c = 0; + foreach (var item in drp_subtitleTracks.Items) + { + if (item.ToString() == lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[1].Text) + drp_subtitleTracks.SelectedIndex = c; + c++; + } + drp_subtitleTracks.SelectedItem = lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[1]; + + if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[2].Text == "Yes") + check_forced.CheckState = CheckState.Checked; + + if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[3].Text == "Yes") + check_burned.CheckState = CheckState.Checked; + + if (lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[4].Text == "Yes") + check_default.CheckState = CheckState.Checked; + + AudioTrackGroup.Text = "Selected Track: " + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[0].Text; + } + else + AudioTrackGroup.Text = "Selected Track: None (Click \"Add Track\" to add)"; + } + + private void drp_subtitleTracks_SelectedIndexChanged(object sender, EventArgs e) + { + // Update an item in the list if required. + if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0) + { + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[1].Text = drp_subtitleTracks.SelectedItem.ToString(); + lv_subList.Select(); + } + } + private void check_forced_CheckedChanged(object sender, EventArgs e) + { + // Update an item in the list if required. + if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0) + { + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[2].Text = check_forced.Checked ? "Yes" : "No"; + lv_subList.Select(); + } + } + private void check_burned_CheckedChanged(object sender, EventArgs e) + { + // Update an item in the list if required. + if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0) + { + if (check_burned.Checked) // Make sure we only have 1 burned track + setNoBurned(); + + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[3].Text = check_burned.Checked ? "Yes" : "No"; + lv_subList.Select(); + } + } + private void check_default_CheckedChanged(object sender, EventArgs e) + { + // Update an item in the list if required. + if (lv_subList.Items.Count != 0 && lv_subList.SelectedIndices.Count != 0) + { + if (check_default.Checked) // Make sure we only have 1 default track + setNoDefault(); + + lv_subList.Items[lv_subList.SelectedIndices[0]].SubItems[4].Text = check_default.Checked ? "Yes" : "No"; + lv_subList.Select(); + } + } + + // Functions + private void setNoDefault() + { + foreach (ListViewItem item in lv_subList.Items) + { + if (item.SubItems[4].Text == "Yes") + item.SubItems[4].Text = "No"; + } + } + private void setNoBurned() + { + foreach (ListViewItem item in lv_subList.Items) + { + if (item.SubItems[3].Text == "Yes") + item.SubItems[3].Text = "No"; + } + } + private void removeTrack() + { + // Remove the Item and reselect the control if the following conditions are met. + if (lv_subList.SelectedItems.Count != 0) + { + // Record the current selected index. + int currentPosition = lv_subList.SelectedIndices[0]; + + lv_subList.Items.RemoveAt(lv_subList.SelectedIndices[0]); + + // Now reslect the correct item and give focus to the list. + if (lv_subList.Items.Count != 0) + { + if (currentPosition <= (lv_subList.Items.Count - 1)) + lv_subList.Items[currentPosition].Selected = true; + else if (currentPosition > (lv_subList.Items.Count - 1)) + lv_subList.Items[lv_subList.Items.Count - 1].Selected = true; + + lv_subList.Select(); + } + + // Regenerate the ID numers + reGenerateListIDs(); + } + } + + // Helper Functions + private int getNewID() + { + return lv_subList.Items.Count + 1; + } + private void reGenerateListIDs() + { + int i = 1; + foreach (ListViewItem item in lv_subList.Items) + { + item.SubItems[0].Text = i.ToString(); + i++; + } + } + + } +} diff --git a/win/C#/Controls/Subtitles.resx b/win/C#/Controls/Subtitles.resx new file mode 100644 index 000000000..ff31a6db5 --- /dev/null +++ b/win/C#/Controls/Subtitles.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file