From ad88ce530b12ba093a3756b36645dfb269fb5d42 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 9 Jan 2010 14:52:47 +0000 Subject: [PATCH] WinGui: - Implemented the point to point - seconds mode. git-svn-id: svn://localhost/HandBrake/trunk@3055 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Controls/Subtitles.cs | 2 +- win/C#/EncodeQueue/EncodeAndQueueHandler.cs | 2 +- win/C#/Functions/Main.cs | 24 +++---- win/C#/Functions/QueryGenerator.cs | 2 +- win/C#/frmMain.Designer.cs | 104 ++++++++++++++-------------- win/C#/frmMain.cs | 69 +++++++++++++----- win/C#/frmOptions.cs | 4 +- 7 files changed, 122 insertions(+), 85 deletions(-) diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs index 44159db5..4fac297e 100644 --- a/win/C#/Controls/Subtitles.cs +++ b/win/C#/Controls/Subtitles.cs @@ -16,7 +16,7 @@ namespace Handbrake.Controls { InitializeComponent(); - LangMap = Main.mapLanguages(); + LangMap = Main.MapLanguages(); foreach (string key in LangMap.Keys) srt_lang.Items.Add(key); diff --git a/win/C#/EncodeQueue/EncodeAndQueueHandler.cs b/win/C#/EncodeQueue/EncodeAndQueueHandler.cs index 17db7529..fce6729c 100644 --- a/win/C#/EncodeQueue/EncodeAndQueueHandler.cs +++ b/win/C#/EncodeQueue/EncodeAndQueueHandler.cs @@ -388,7 +388,7 @@ namespace Handbrake.EncodeQueue Process[] before = Process.GetProcesses(); // Get a list of running processes before starting. hbProcess = Process.Start(cliStart); - processID = Main.getCliProcess(before); + processID = Main.GetCliProcess(before); currentQuery = query; if (hbProcess != null) processHandle = hbProcess.MainWindowHandle; // Set the process Handle diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 9d2489f9..5cdbf520 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -20,12 +20,12 @@ namespace Handbrake.Functions static class Main { // Private Variables - private static readonly XmlSerializer ser = new XmlSerializer(typeof(List)); + private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List)); /// /// Calculate the duration of the selected title and chapters /// - public static TimeSpan calculateDuration(int chapterStart, int chapterEnd, Parsing.Title selectedTitle) + public static TimeSpan CalculateDuration(int chapterStart, int chapterEnd, Parsing.Title selectedTitle) { TimeSpan duration = TimeSpan.FromSeconds(0.0); chapterStart++; chapterEnd++; @@ -41,7 +41,7 @@ namespace Handbrake.Functions /// /// Select the longest title in the DVD title dropdown menu on frmMain /// - public static Parsing.Title selectLongestTitle(Parsing.DVD thisDvd) + public static Parsing.Title SelectLongestTitle(Parsing.DVD thisDvd) { TimeSpan longestDurationFound = TimeSpan.FromSeconds(0.0); Parsing.Title returnTitle = null; @@ -60,7 +60,7 @@ namespace Handbrake.Functions /// /// Set's up the DataGridView on the Chapters tab (frmMain) /// - public static DataGridView chapterNaming(DataGridView dataChpt, string chapterEnd) + public static DataGridView ChapterNaming(DataGridView dataChpt, string chapterEnd) { int i = 0, finish = 0; @@ -86,7 +86,7 @@ namespace Handbrake.Functions /// /// /// - public static DataGridView importChapterNames(DataGridView dataChpt, string filename) + public static DataGridView ImportChapterNames(DataGridView dataChpt, string filename) { IDictionary chapterMap = new Dictionary(); try @@ -124,7 +124,7 @@ namespace Handbrake.Functions /// Function which generates the filename and path automatically based on /// the Source Name, DVD title and DVD Chapters /// - public static string autoName(frmMain mainWindow) //ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters) + public static string AutoName(frmMain mainWindow) //ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters) { string AutoNamePath = string.Empty; if (mainWindow.drp_dvdtitle.Text != "Automatic") @@ -191,7 +191,7 @@ namespace Handbrake.Functions /// Get's HandBrakes version data from the CLI. /// /// Arraylist of Version Data. 0 = hb_version 1 = hb_build - public static void setCliVersionData() + public static void SetCliVersionData() { String line; @@ -259,7 +259,7 @@ namespace Handbrake.Functions /// If it does, it means the last queue did not complete before HandBrake closed. /// So, return a boolean if true. /// - public static Boolean checkQueueRecovery() + public static Boolean CheckQueueRecovery() { try { @@ -268,7 +268,7 @@ namespace Handbrake.Functions { using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read)) { - List list = ser.Deserialize(strm) as List; + List list = Ser.Deserialize(strm) as List; if (list != null) if (list.Count != 0) return true; @@ -287,7 +287,7 @@ namespace Handbrake.Functions /// /// List of processes before the new process was started /// Int - Process ID - public static int getCliProcess(Process[] before) + public static int GetCliProcess(Process[] before) { // This is a bit of a cludge. Maybe someone has a better idea on how to impliment this. // Since we used CMD to start HandBrakeCLI, we don't get the process ID from hbProc. @@ -334,7 +334,7 @@ namespace Handbrake.Functions /// /// Clear all the encode log files. /// - public static void clearLogs() + public static void ClearLogs() { string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs"; if (Directory.Exists(logDir)) @@ -441,7 +441,7 @@ namespace Handbrake.Functions /// Map languages and their iso639_2 value into a IDictionary /// /// - public static IDictionary mapLanguages() + public static IDictionary MapLanguages() { IDictionary languageMap = new Dictionary { diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs index bfe456dc..37e5b66b 100644 --- a/win/C#/Functions/QueryGenerator.cs +++ b/win/C#/Functions/QueryGenerator.cs @@ -384,7 +384,7 @@ namespace Handbrake.Functions #region Subtitles Tab if (mainWindow.Subtitles.lv_subList.Items.Count != 0) // If we have subtitle tracks { - IDictionary langMap = Main.mapLanguages(); + IDictionary langMap = Main.MapLanguages(); // BitMap and CC's string subtitleTracks = String.Empty; diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index 85619246..1b23506f 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -100,6 +100,7 @@ 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.lbl_qualityValue = new System.Windows.Forms.Label(); @@ -112,13 +113,17 @@ 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(); @@ -171,11 +176,6 @@ 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.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(); @@ -805,6 +805,15 @@ 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; @@ -953,6 +962,16 @@ namespace Handbrake this.tab_picture.Text = "Picture"; this.tab_picture.UseVisualStyleBackColor = true; // + // PictureSettings + // + this.PictureSettings.BackColor = System.Drawing.Color.Transparent; + 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.Size = new System.Drawing.Size(666, 279); + this.PictureSettings.TabIndex = 0; + // // Check_ChapterMarkers // this.Check_ChapterMarkers.AutoSize = true; @@ -992,6 +1011,15 @@ 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); @@ -1003,6 +1031,15 @@ 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; @@ -1040,6 +1077,16 @@ 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); @@ -1604,53 +1651,6 @@ namespace Handbrake // this.File_ChapterImport.Filter = "CSV Files|*.csv"; // - // PictureSettings - // - this.PictureSettings.BackColor = System.Drawing.Color.Transparent; - 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.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; diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index f165bbb0..47d9f060 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -57,7 +57,7 @@ namespace Handbrake // Update the users config file with the CLI version data. lblStatus.Text = "Setting Version Data ..."; Application.DoEvents(); - Main.setCliVersionData(); + Main.SetCliVersionData(); // Show the form, but leave disabled until preloading is complete then show the main form this.Enabled = false; @@ -167,7 +167,7 @@ namespace Handbrake // Startup Functions private void queueRecovery() { - if (Main.checkQueueRecovery()) + if (Main.CheckQueueRecovery()) { DialogResult 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); @@ -943,10 +943,10 @@ namespace Handbrake if (!string.IsNullOrEmpty(selectedTitle.SourceName)) labelSource.Text = labelSource.Text = Path.GetFileName(selectedTitle.SourceName); - // Run the autoName & chapterNaming functions + // Run the AutoName & ChapterNaming functions if (Properties.Settings.Default.autoNaming) { - string autoPath = Main.autoName(this); + string autoPath = Main.AutoName(this); if (autoPath != null) text_destination.Text = autoPath; else @@ -956,7 +956,7 @@ namespace Handbrake data_chpt.Rows.Clear(); if (selectedTitle.Chapters.Count != 1) { - DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text); + DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text); if (chapterGridView != null) data_chpt = chapterGridView; } @@ -1020,11 +1020,11 @@ namespace Handbrake } // Update the Duration - lbl_duration.Text = Main.calculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString(); + lbl_duration.Text = Main.CalculateDuration(drop_chapterStart.SelectedIndex, drop_chapterFinish.SelectedIndex, selectedTitle).ToString(); // Run the Autonaming function if (Properties.Settings.Default.autoNaming) - text_destination.Text = Main.autoName(this); + text_destination.Text = Main.AutoName(this); // Disable chapter markers if only 1 chapter is selected. if (chapterStart == chapterEnd) @@ -1043,15 +1043,52 @@ namespace Handbrake } } } - private void drop_mode_SelectedIndexChanged(object sender, EventArgs e) + private void SecondsOrFramesChanged(object sender, EventArgs e) { - if (drop_mode.SelectedIndex == 0) return; + int start, end; + int.TryParse(drop_chapterStart.Text, out start); + int.TryParse(drop_chapterFinish.Text, out end); - if (drop_mode.SelectedIndex != 0) - drop_mode.SelectedIndex = 0; + int duration = end - start; + TimeSpan dur = TimeSpan.FromSeconds(duration); + lbl_duration.Text = dur.ToString(); + } + private void drop_mode_SelectedIndexChanged(object sender, EventArgs e) + { + // Reset + this.drop_chapterFinish.TextChanged -= new System.EventHandler(this.SecondsOrFramesChanged); + this.drop_chapterStart.TextChanged -= new System.EventHandler(this.SecondsOrFramesChanged); - MessageBox.Show("This feature is not implemented yet! Switching Back to Chapters Mode.", "", - MessageBoxButtons.OK, MessageBoxIcon.Error); + // Do Work + switch (drop_mode.SelectedIndex) + { + case 0: + drop_chapterStart.DropDownStyle = ComboBoxStyle.DropDownList; + drop_chapterFinish.DropDownStyle = ComboBoxStyle.DropDownList; + if (drop_chapterStart.Items.Count != 0) + { + drop_chapterStart.SelectedIndex = 0; + drop_chapterFinish.SelectedIndex = drop_chapterFinish.Items.Count - 1; + } + else + lbl_duration.Text = "--:--:--"; + return; + case 1: + this.drop_chapterStart.TextChanged += new System.EventHandler(this.SecondsOrFramesChanged); + this.drop_chapterFinish.TextChanged += new System.EventHandler(this.SecondsOrFramesChanged); + drop_chapterStart.DropDownStyle = ComboBoxStyle.Simple; + drop_chapterFinish.DropDownStyle = ComboBoxStyle.Simple; + if (selectedTitle != null) + { + drop_chapterStart.Text = "0"; + drop_chapterFinish.Text = selectedTitle.Duration.TotalSeconds.ToString(); + } + return; + case 2: + MessageBox.Show("This feature is not implemented yet! Switching Back to Chapters Mode.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); + drop_mode.SelectedIndex = 0; + return; + } } //Destination @@ -1381,7 +1418,7 @@ namespace Handbrake if (File_ChapterImport.ShowDialog() == DialogResult.OK) { String filename = File_ChapterImport.FileName; - DataGridView imported = Main.importChapterNames(data_chpt, filename); + DataGridView imported = Main.ImportChapterNames(data_chpt, filename); if (imported != null) data_chpt = imported; } @@ -1389,7 +1426,7 @@ namespace Handbrake private void mnu_resetChapters_Click(object sender, EventArgs e) { data_chpt.Rows.Clear(); - DataGridView chapterGridView = Main.chapterNaming(data_chpt, drop_chapterFinish.Text); + DataGridView chapterGridView = Main.ChapterNaming(data_chpt, drop_chapterFinish.Text); if (chapterGridView != null) { data_chpt = chapterGridView; @@ -1485,7 +1522,7 @@ namespace Handbrake // Now select the longest title if (thisDVD.Titles.Count != 0) - drp_dvdtitle.SelectedItem = Main.selectLongestTitle(thisDVD); + drp_dvdtitle.SelectedItem = Main.SelectLongestTitle(thisDVD); // Enable the creation of chapter markers if the file is an image of a dvd. if (sourcePath.ToLower().Contains(".iso") || sourcePath.Contains("VIDEO_TS")) diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs index 5f5977ac..790c20ec 100644 --- a/win/C#/frmOptions.cs +++ b/win/C#/frmOptions.cs @@ -21,7 +21,7 @@ namespace Handbrake InitializeComponent(); mainWindow = mw; - IDictionary langList = Main.mapLanguages(); + IDictionary langList = Main.MapLanguages(); foreach (string item in langList.Keys) drop_preferredLang.Items.Add(item); @@ -352,7 +352,7 @@ namespace Handbrake DialogResult result = MessageBox.Show("Are you sure you wish to clear the log file directory?", "Clear Logs", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { - Main.clearLogs(); + Main.ClearLogs(); MessageBox.Show(this, "HandBrake's Log file directory has been cleared!", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information); } -- 2.11.0