From 0a08b6778fa3dc2c38379d72252f23671e02e3c7 Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 22 Feb 2010 21:23:28 +0000 Subject: WinGui: - Some more cleanup git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3134 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Parsing/Parser.cs | 88 ++++++------ win/C#/Parsing/Subtitle.cs | 90 ++++++++---- win/C#/Parsing/Title.cs | 169 ++++++++++++++-------- win/C#/Settings.StyleCop | 10 ++ win/C#/frmActivityWindow.Designer.cs | 10 +- win/C#/frmActivityWindow.cs | 272 ++++++++++++++++++++++++++--------- win/C#/frmMain.Designer.cs | 2 +- win/C#/frmMain.cs | 2 +- 8 files changed, 433 insertions(+), 210 deletions(-) (limited to 'win/C#') diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs index e643d3bd9..3dd2fdeb4 100644 --- a/win/C#/Parsing/Parser.cs +++ b/win/C#/Parsing/Parser.cs @@ -1,8 +1,7 @@ /* Parser.cs $ - - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ namespace Handbrake.Parsing { @@ -15,31 +14,29 @@ namespace Handbrake.Parsing /// /// A delegate to handle custom events regarding data being parsed from the buffer /// - /// The object which raised this delegate - /// The data parsed from the stream - public delegate void DataReadEventHandler(object Sender, string Data); + /// The object which raised this delegate + /// The data parsed from the stream + public delegate void DataReadEventHandler(object sender, string data); /// /// A delegate to handle events regarding progress during DVD scanning /// - /// The object who's raising the event - /// The title number currently being processed - /// The total number of titiles to be processed - public delegate void ScanProgressEventHandler(object Sender, int CurrentTitle, int TitleCount); + /// The object who's raising the event + /// The title number currently being processed + /// The total number of titiles to be processed + public delegate void ScanProgressEventHandler(object sender, int currentTitle, int titleCount); /// /// A delegate to handle encode progress updates // EXPERIMENTAL /// - /// The object which raised the event - /// The current task being processed from the queue - /// The total number of tasks in queue - /// The percentage this task is complete - /// The current encoding fps - /// The average encoding fps for this task - /// The estimated time remaining for this task to complete - public delegate void EncodeProgressEventHandler( - object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, - TimeSpan TimeRemaining); + /// The object which raised the event + /// The current task being processed from the queue + /// The total number of tasks in queue + /// The percentage this task is complete + /// The current encoding fps + /// The average encoding fps for this task + /// The estimated time remaining for this task to complete + public delegate void EncodeProgressEventHandler(object sender, int currentTask, int taskCount, float percentComplete, float currentFps, float averageFps, TimeSpan timeRemaining); /// @@ -47,14 +44,20 @@ namespace Handbrake.Parsing /// internal class Parser : StreamReader { - private StringBuilder _buffer = new StringBuilder(string.Empty); + /// + /// The Buffer StringBuilder + /// + private StringBuilder buffer = new StringBuilder(string.Empty); /// - /// The output from the CLI process + /// Initializes a new instance of the class. + /// Default constructor for this object /// - public string Buffer + /// + /// The stream to parse from + /// + public Parser(Stream baseStream) : base(baseStream) { - get { return _buffer.ToString(); } } /// @@ -72,32 +75,30 @@ namespace Handbrake.Parsing /// public event ScanProgressEventHandler OnScanProgress; - #region Experimetnal Code - /// /// Raised upon the catching of a "Scanning title # of #..." in the stream /// public event EncodeProgressEventHandler OnEncodeProgress; - #endregion - /// - /// Initializes a new instance of the class. - /// Default constructor for this object + /// Gets the buffer of data that came from the CLI standard input/error /// - /// - /// The stream to parse from - /// - public Parser(Stream baseStream) - : base(baseStream) + public string Buffer { + get { return buffer.ToString(); } } + /// + /// Read a line from standard in/err + /// + /// + /// The read line + /// public override string ReadLine() { string tmp = base.ReadLine(); - _buffer.Append(tmp + Environment.NewLine); + buffer.Append(tmp + Environment.NewLine); Match m = null; if (tmp.Contains("Scanning title")) @@ -113,11 +114,17 @@ namespace Handbrake.Parsing return tmp; } + /// + /// Read to the end of the input stream + /// + /// + /// A string of the input data + /// public override string ReadToEnd() { string tmp = base.ReadToEnd(); - _buffer.Append(tmp + Environment.NewLine); + buffer.Append(tmp + Environment.NewLine); if (OnReadToEnd != null) OnReadToEnd(this, tmp); @@ -128,13 +135,12 @@ namespace Handbrake.Parsing /// /// Pase the CLI status output (from standard output) /// - public void readEncodeStatus() + public void ReadEncodeStatus() { CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US"); string tmp = base.ReadLine(); - Match m = Regex.Match(tmp, - @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?"); + Match m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?"); if (m.Success && OnEncodeProgress != null) { int currentTask = int.Parse(m.Groups[1].Value); diff --git a/win/C#/Parsing/Subtitle.cs b/win/C#/Parsing/Subtitle.cs index 178e4470d..a21040be5 100644 --- a/win/C#/Parsing/Subtitle.cs +++ b/win/C#/Parsing/Subtitle.cs @@ -1,8 +1,7 @@ /* Subtitle.cs $ - - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ namespace Handbrake.Parsing { @@ -15,54 +14,67 @@ namespace Handbrake.Parsing /// public class Subtitle { - private string m_language; - private int m_trackNumber; - private string m_type; - private string m_typecode; + /// + /// The Language + /// + private string language; + + /// + /// The Track Number + /// + private int trackNumber; + + /// + /// The type of subtitle + /// + private string type; /// - /// The track number of this Subtitle + /// The typecode + /// + private string typecode; + + /// + /// Gets the track number of this Subtitle /// public int TrackNumber { - get { return m_trackNumber; } + get { return trackNumber; } } /// - /// The language (if detected) of this Subtitle + /// Gets the The language (if detected) of this Subtitle /// public string Language { - get { return m_language; } + get { return language; } } /// - /// Langauage Code + /// Gets the Langauage Code /// public string LanguageCode { - get { return m_typecode; } + get { return typecode; } } - /// - /// Subtitle Type + /// Gets the Subtitle Type /// public string Type { - get { return m_type; } + get { return type; } } - /// - /// Override of the ToString method to make this object easier to use in the UI + /// Parse the input strings related to subtitles /// - /// A string formatted as: {track #} {language} - public override string ToString() - { - return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_type); - } - + /// + /// The output. + /// + /// + /// A Subitle object + /// public static Subtitle Parse(StringReader output) { string curLine = output.ReadLine(); @@ -72,17 +84,26 @@ namespace Handbrake.Parsing { var thisSubtitle = new Subtitle { - m_trackNumber = int.Parse(m.Groups[1].Value.Trim()), - m_language = m.Groups[2].Value, - m_typecode = m.Groups[3].Value, - m_type = m.Groups[4].Value + trackNumber = int.Parse(m.Groups[1].Value.Trim()), + language = m.Groups[2].Value, + typecode = m.Groups[3].Value, + type = m.Groups[4].Value }; return thisSubtitle; } return null; } - public static Subtitle[] ParseList(StringReader output) + /// + /// Parse a list of Subtitle tracks from an input string. + /// + /// + /// The output. + /// + /// + /// An array of Subtitle objects + /// + public static IEnumerable ParseList(StringReader output) { var subtitles = new List(); while ((char) output.Peek() != '+') @@ -96,5 +117,14 @@ namespace Handbrake.Parsing } return subtitles.ToArray(); } + + /// + /// Override of the ToString method to make this object easier to use in the UI + /// + /// A string formatted as: {track #} {language} + public override string ToString() + { + return string.Format("{0} {1} ({2})", trackNumber, language, type); + } } } \ No newline at end of file diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index 764c7cdbd..0494f5be5 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -1,8 +1,7 @@ /* Title.cs $ - - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ namespace Handbrake.Parsing { @@ -18,19 +17,70 @@ namespace Handbrake.Parsing /// public class Title { + /// + /// The Culture Info + /// private static readonly CultureInfo Culture = new CultureInfo("en-US", false); - private readonly List m_audioTracks; - private readonly List m_chapters; - private readonly List m_subtitles; - private List m_angles = new List(); - private float m_aspectRatio; - private float m_fps; - private int[] m_autoCrop; + + /// + /// A collection of Audio Tracks + /// + private readonly List audioTracks; + + /// + /// A Collection of Chapters + /// + private readonly List chapters; + + /// + /// A Collection of Subtitles + /// + private readonly List subtitles; + + /// + /// A collection of angles + /// + private List angles = new List(); + + /// + /// The source aspect ratio + /// + private float aspectRatio; + + /// + /// The source framerate + /// + private float fps; + + /// + /// Source autocrop values + /// + private int[] autoCrop; + + /// + /// Source name + /// private string source; - private TimeSpan m_duration; - private Size m_resolution; - private int m_titleNumber; - private Size m_parVal; + + /// + /// The duration of the source + /// + private TimeSpan duration; + + /// + /// The source resolution + /// + private Size resolution; + + /// + /// The Title number + /// + private int titleNumber; + + /// + /// The par values for this title. + /// + private Size parVal; /// /// Initializes a new instance of the class. @@ -38,33 +88,33 @@ namespace Handbrake.Parsing /// public Title() { - m_audioTracks = new List(); - m_chapters = new List(); - m_subtitles = new List(); + audioTracks = new List(); + chapters = new List(); + subtitles = new List(); } /// - /// Collection of chapters in this Title + /// Gets a Collection of chapters in this Title /// public List Chapters { - get { return m_chapters; } + get { return chapters; } } /// - /// Collection of audio tracks associated with this Title + /// Gets a Collection of audio tracks associated with this Title /// public List AudioTracks { - get { return m_audioTracks; } + get { return audioTracks; } } /// - /// Collection of subtitles associated with this Title + /// Gets aCollection of subtitles associated with this Title /// public List Subtitles { - get { return m_subtitles; } + get { return subtitles; } } /// @@ -72,11 +122,11 @@ namespace Handbrake.Parsing /// public int TitleNumber { - get { return m_titleNumber; } + get { return titleNumber; } } /// - /// Source Name + /// Gets the Source Name /// public string SourceName { @@ -84,39 +134,39 @@ namespace Handbrake.Parsing } /// - /// The length in time of this Title + /// Gets the length in time of this Title /// public TimeSpan Duration { - get { return m_duration; } + get { return duration; } } /// - /// The resolution (width/height) of this Title + /// Gets the resolution (width/height) of this Title /// public Size Resolution { - get { return m_resolution; } + get { return resolution; } } /// - /// The aspect ratio of this Title + /// Gets the aspect ratio of this Title /// public float AspectRatio { - get { return m_aspectRatio; } + get { return aspectRatio; } } /// - /// Par Value + /// Gets Par Value /// public Size ParVal { - get { return m_parVal; } + get { return parVal; } } /// - /// The automatically detected crop region for this Title. + /// Gets the automatically detected crop region for this Title. /// This is an int array with 4 items in it as so: /// 0: /// 1: @@ -125,23 +175,24 @@ namespace Handbrake.Parsing /// public int[] AutoCropDimensions { - get { return m_autoCrop; } + get { return autoCrop; } } /// - /// Collection of Angles in this Title + /// Gets a Collection of Angles in this Title /// public List Angles { - get { return m_angles; } + get { return angles; } } + /// - /// Collection of Angles in this Title + /// Gets the FPS of the source. /// public float Fps { - get { return m_fps; } + get { return fps; } } /// @@ -150,15 +201,14 @@ namespace Handbrake.Parsing /// A string representing this track in the format: {title #} (00:00:00) public override string ToString() { - return string.Format("{0} ({1:00}:{2:00}:{3:00})", m_titleNumber, m_duration.Hours, - m_duration.Minutes, m_duration.Seconds); + return string.Format("{0} ({1:00}:{2:00}:{3:00})", titleNumber, duration.Hours, duration.Minutes, duration.Seconds); } /// /// Parse the Title Information /// - /// - /// + /// A stingreader of output data + /// A Title public static Title Parse(StringReader output) { var thisTitle = new Title(); @@ -166,7 +216,7 @@ namespace Handbrake.Parsing Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):"); // Match track number for this title if (m.Success) - thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim()); + thisTitle.titleNumber = int.Parse(m.Groups[1].Value.Trim()); // If we are scanning a groupd of files, we'll want to get the source name. string path = output.ReadLine(); @@ -185,42 +235,39 @@ namespace Handbrake.Parsing int.TryParse(angleList, out angleCount); for (int i = 1; i <= angleCount; i++) - thisTitle.m_angles.Add(i.ToString()); + thisTitle.angles.Add(i.ToString()); } } // Get duration for this title m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})"); if (m.Success) - thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value); + thisTitle.duration = TimeSpan.Parse(m.Groups[1].Value); // Get resolution, aspect ratio and FPS for this title - m = Regex.Match(output.ReadLine(), - @"^ \+ size: ([0-9]*)x([0-9]*), pixel aspect: ([0-9]*)/([0-9]*), display aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps"); - // size: 720x576, pixel aspect: 16/15, display aspect: 1.33, 25.000 fps - + m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), pixel aspect: ([0-9]*)/([0-9]*), display aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps"); if (m.Success) { - thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); - thisTitle.m_parVal = new Size(int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)); - thisTitle.m_aspectRatio = float.Parse(m.Groups[5].Value, Culture); - thisTitle.m_fps = float.Parse(m.Groups[6].Value, Culture); + thisTitle.resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); + thisTitle.parVal = new Size(int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)); + thisTitle.aspectRatio = float.Parse(m.Groups[5].Value, Culture); + thisTitle.fps = float.Parse(m.Groups[6].Value, Culture); } // Get autocrop region for this title m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)"); if (m.Success) - thisTitle.m_autoCrop = new[] + thisTitle.autoCrop = new[] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) }; - thisTitle.m_chapters.AddRange(Chapter.ParseList(output)); + thisTitle.chapters.AddRange(Chapter.ParseList(output)); - thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output)); + thisTitle.audioTracks.AddRange(AudioTrack.ParseList(output)); - thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output)); + thisTitle.subtitles.AddRange(Subtitle.ParseList(output)); return thisTitle; } @@ -228,8 +275,8 @@ namespace Handbrake.Parsing /// /// Return a list of parsed titles /// - /// - /// + /// The Output + /// A List of titles public static Title[] ParseList(string output) { var titles = new List(); diff --git a/win/C#/Settings.StyleCop b/win/C#/Settings.StyleCop index ded06b4b9..d6aed5926 100644 --- a/win/C#/Settings.StyleCop +++ b/win/C#/Settings.StyleCop @@ -143,5 +143,15 @@ </Rules> <AnalyzerSettings /> </Analyzer> + <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.OrderingRules"> + <Rules> + <Rule Name="ElementsMustBeOrderedByAccess"> + <RuleSettings> + <BooleanProperty Name="Enabled">False</BooleanProperty> + </RuleSettings> + </Rule> + </Rules> + <AnalyzerSettings /> + </Analyzer> </Analyzers> </StyleCopSettings> \ No newline at end of file diff --git a/win/C#/frmActivityWindow.Designer.cs b/win/C#/frmActivityWindow.Designer.cs index eeb5e358c..4d2d081b0 100644 --- a/win/C#/frmActivityWindow.Designer.cs +++ b/win/C#/frmActivityWindow.Designer.cs @@ -78,7 +78,7 @@ namespace Handbrake this.mnu_copy_log.Name = "mnu_copy_log"; this.mnu_copy_log.Size = new System.Drawing.Size(253, 22); this.mnu_copy_log.Text = "Copy"; - this.mnu_copy_log.Click += new System.EventHandler(this.mnu_copy_log_Click); + this.mnu_copy_log.Click += new System.EventHandler(this.MnuCopyLogClick); // // mnu_openLogFolder // @@ -86,7 +86,7 @@ namespace Handbrake this.mnu_openLogFolder.Name = "mnu_openLogFolder"; this.mnu_openLogFolder.Size = new System.Drawing.Size(253, 22); this.mnu_openLogFolder.Text = "Open Individual Log File Directory"; - this.mnu_openLogFolder.Click += new System.EventHandler(this.mnu_openLogFolder_Click); + this.mnu_openLogFolder.Click += new System.EventHandler(this.MnuOpenLogFolderClick); // // ToolTip // @@ -124,7 +124,7 @@ namespace Handbrake this.btn_encode_log.Name = "btn_encode_log"; this.btn_encode_log.Size = new System.Drawing.Size(152, 22); this.btn_encode_log.Text = "Encode Log"; - this.btn_encode_log.Click += new System.EventHandler(this.btn_encode_log_Click); + this.btn_encode_log.Click += new System.EventHandler(this.BtnEncodeLogClick); // // btn_scan_log // @@ -132,7 +132,7 @@ namespace Handbrake this.btn_scan_log.Name = "btn_scan_log"; this.btn_scan_log.Size = new System.Drawing.Size(152, 22); this.btn_scan_log.Text = "Scan Log"; - this.btn_scan_log.Click += new System.EventHandler(this.btn_scan_log_Click); + this.btn_scan_log.Click += new System.EventHandler(this.BtnScanLogClick); // // btn_copy // @@ -142,7 +142,7 @@ namespace Handbrake this.btn_copy.Name = "btn_copy"; this.btn_copy.Size = new System.Drawing.Size(122, 22); this.btn_copy.Text = "Copy to clipboard"; - this.btn_copy.Click += new System.EventHandler(this.btn_copy_Click); + this.btn_copy.Click += new System.EventHandler(this.BtnCopyClick); // // panel1 // diff --git a/win/C#/frmActivityWindow.cs b/win/C#/frmActivityWindow.cs index 07e8f3dc8..879dd54a5 100644 --- a/win/C#/frmActivityWindow.cs +++ b/win/C#/frmActivityWindow.cs @@ -1,8 +1,7 @@ /* frmActivityWindow.cs $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.fr>. - It may be used under the terms of the GNU General Public License. */ + This file is part of the HandBrake source code. + Homepage: <http://handbrake.fr>. + It may be used under the terms of the GNU General Public License. */ namespace Handbrake { @@ -16,51 +15,141 @@ namespace Handbrake using Functions; using Timer = System.Threading.Timer; + /// <summary> + /// The Activity Log Window + /// </summary> public partial class frmActivityWindow : Form { - private delegate void SetTextCallback(StringBuilder text); + /// <summary> + /// The current position in the log file + /// </summary> + private int position; - private delegate void SetTextClearCallback(); + /// <summary> + /// The previous mode + /// </summary> + private string lastMode; - private int Position; - private string LastMode; - private string CurrentMode; - private Timer WindowTimer; + /// <summary> + /// The current mode + /// </summary> + private string currentMode; + /// <summary> + /// A Timer for this window + /// </summary> + private Timer windowTimer; + + /// <summary> + /// Initializes a new instance of the <see cref="frmActivityWindow"/> class. + /// </summary> + /// <param name="mode"> + /// The mode. + /// </param> public frmActivityWindow(string mode) { InitializeComponent(); - Position = 0; + position = 0; if (mode == "scan") SetScanMode(); else SetEncodeMode(); } + /// <summary> + /// A callback function for updating the ui + /// </summary> + /// <param name="text"> + /// The text. + /// </param> + private delegate void SetTextCallback(StringBuilder text); + + /// <summary> + /// Clear text callback + /// </summary> + private delegate void SetTextClearCallback(); + + // Public + + /// <summary> + /// Gets or sets SetLogFile. + /// </summary> + public string SetLogFile + { + get { return string.IsNullOrEmpty(currentMode) ? string.Empty : currentMode; } + set { currentMode = value; } + } + + /// <summary> + /// Set the window to scan mode + /// </summary> + public void SetScanMode() + { + Reset(); + SetLogFile = "last_scan_log.txt"; + this.Text = "Activity Window (Scan Log)"; + } + + /// <summary> + /// Set the window to encode mode + /// </summary> + public void SetEncodeMode() + { + Reset(); + SetLogFile = "last_encode_log.txt"; + this.Text = "Activity Window (Enocde Log)"; + } + + // Logging + + /// <summary> + /// On Window load, start a new timer + /// </summary> + /// <param name="sender"> + /// The sender. + /// </param> + /// <param name="e"> + /// The e. + /// </param> private void NewActivityWindow_Load(object sender, EventArgs e) { - WindowTimer = new Timer(new TimerCallback(LogMonitor), null, 1000, 1000); + windowTimer = new Timer(new TimerCallback(LogMonitor), null, 1000, 1000); } + /// <summary> + /// Append new text to the window + /// </summary> + /// <param name="n"> + /// The n. + /// </param> private void LogMonitor(object n) { - if (SetLogFile != LastMode) Reset(); + if (SetLogFile != lastMode) Reset(); // Perform the window update switch (SetLogFile) { case "last_scan_log.txt": AppendWindowText(ReadFile("last_scan_log.txt")); - LastMode = "last_scan_log.txt"; + lastMode = "last_scan_log.txt"; break; case "last_encode_log.txt": AppendWindowText(ReadFile("last_encode_log.txt")); - LastMode = "last_encode_log.txt"; + lastMode = "last_encode_log.txt"; break; } } + /// <summary> + /// Read the log file + /// </summary> + /// <param name="file"> + /// The file. + /// </param> + /// <returns> + /// A string builder containing the log data + /// </returns> private StringBuilder ReadFile(string file) { StringBuilder appendText = new StringBuilder(); @@ -85,7 +174,7 @@ namespace Handbrake else { appendText.AppendFormat("Waiting for the log file to be generated ...\n"); - Position = 0; + position = 0; ClearWindowText(); PrintLogHeader(); return appendText; @@ -98,10 +187,10 @@ namespace Handbrake int i = 1; while ((line = sr.ReadLine()) != null) { - if (i > Position) + if (i > position) { appendText.AppendLine(line); - Position++; + position++; } i++; } @@ -112,13 +201,18 @@ namespace Handbrake { Reset(); appendText = new StringBuilder(); - appendText.AppendFormat( - "\nThe Log file is currently in use. Waiting for the log file to become accessible ...\n"); + appendText.AppendLine("\nThe Log file is currently in use. Waiting for the log file to become accessible ...\n"); } } return appendText; } + /// <summary> + /// Append text to the RTF box + /// </summary> + /// <param name="text"> + /// The text. + /// </param> private void AppendWindowText(StringBuilder text) { try @@ -127,7 +221,7 @@ namespace Handbrake { if (rtf_actLog.InvokeRequired) { - IAsyncResult invoked = BeginInvoke(new SetTextCallback(AppendWindowText), new object[] {text}); + IAsyncResult invoked = BeginInvoke(new SetTextCallback(AppendWindowText), new object[] { text }); EndInvoke(invoked); } else @@ -141,6 +235,9 @@ namespace Handbrake } } + /// <summary> + /// Clear the contents of the log window + /// </summary> private void ClearWindowText() { try @@ -163,6 +260,9 @@ namespace Handbrake } } + /// <summary> + /// Display the log header + /// </summary> private void PrintLogHeader() { try @@ -179,19 +279,19 @@ namespace Handbrake lock (rtf_actLog) { // Print the log header. This function will be re-implimented later. Do not delete. - rtf_actLog.AppendText(String.Format("### Windows GUI {1} {0} \n", - Properties.Settings.Default.hb_build, - Properties.Settings.Default.hb_version)); - rtf_actLog.AppendText(String.Format("### Running: {0} \n###\n", Environment.OSVersion)); - rtf_actLog.AppendText(String.Format("### CPU: {0} \n", SystemInfo.GetCpuCount)); - rtf_actLog.AppendText(String.Format("### Ram: {0} MB \n", SystemInfo.TotalPhysicalMemory)); - rtf_actLog.AppendText(String.Format("### Screen: {0}x{1} \n", - SystemInfo.ScreenBounds.Bounds.Width, - SystemInfo.ScreenBounds.Bounds.Height)); - rtf_actLog.AppendText(String.Format("### Temp Dir: {0} \n", Path.GetTempPath())); - rtf_actLog.AppendText(String.Format("### Install Dir: {0} \n", Application.StartupPath)); - rtf_actLog.AppendText(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath)); - rtf_actLog.AppendText("#########################################\n\n"); + StringBuilder header = new StringBuilder(); + + header.AppendLine(String.Format("### Windows GUI {1} {0} \n", Properties.Settings.Default.hb_build, Properties.Settings.Default.hb_version)); + header.AppendLine(String.Format("### Running: {0} \n###\n", Environment.OSVersion)); + header.AppendLine(String.Format("### CPU: {0} \n", SystemInfo.GetCpuCount)); + header.AppendLine(String.Format("### Ram: {0} MB \n", SystemInfo.TotalPhysicalMemory)); + header.AppendLine(String.Format("### Screen: {0}x{1} \n", SystemInfo.ScreenBounds.Bounds.Width, SystemInfo.ScreenBounds.Bounds.Height)); + header.AppendLine(String.Format("### Temp Dir: {0} \n", Path.GetTempPath())); + header.AppendLine(String.Format("### Install Dir: {0} \n", Application.StartupPath)); + header.AppendLine(String.Format("### Data Dir: {0} \n", Application.UserAppDataPath)); + header.AppendLine("#########################################\n\n"); + + rtf_actLog.AppendText(header.ToString()); } } } @@ -202,48 +302,45 @@ namespace Handbrake } } + /// <summary> + /// Reset Everything + /// </summary> private void Reset() { - if (WindowTimer != null) - WindowTimer.Dispose(); - Position = 0; + if (windowTimer != null) + windowTimer.Dispose(); + position = 0; ClearWindowText(); PrintLogHeader(); - WindowTimer = new Timer(new TimerCallback(LogMonitor), null, 1000, 1000); - } - - #region Public - - public string SetLogFile - { - get { return string.IsNullOrEmpty(CurrentMode) ? string.Empty : CurrentMode; } - set { CurrentMode = value; } - } - - public void SetScanMode() - { - Reset(); - SetLogFile = "last_scan_log.txt"; - this.Text = "Activity Window (Scan Log)"; - } - - public void SetEncodeMode() - { - Reset(); - SetLogFile = "last_encode_log.txt"; - this.Text = "Activity Window (Enocde Log)"; + windowTimer = new Timer(new TimerCallback(LogMonitor), null, 1000, 1000); } - #endregion - - #region User Interface + // Menus and Buttons - private void mnu_copy_log_Click(object sender, EventArgs e) + /// <summary> + /// Copy log to clipboard + /// </summary> + /// <param name="sender"> + /// The sender. + /// </param> + /// <param name="e"> + /// The e. + /// </param> + private void MnuCopyLogClick(object sender, EventArgs e) { Clipboard.SetDataObject(rtf_actLog.SelectedText != string.Empty ? rtf_actLog.SelectedText : rtf_actLog.Text, true); } - private void mnu_openLogFolder_Click(object sender, EventArgs e) + /// <summary> + /// Open the log folder + /// </summary> + /// <param name="sender"> + /// The sender. + /// </param> + /// <param name="e"> + /// The e. + /// </param> + private void MnuOpenLogFolderClick(object sender, EventArgs e) { string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs"; string windir = Environment.GetEnvironmentVariable("WINDIR"); @@ -251,33 +348,66 @@ namespace Handbrake { StartInfo = { - FileName = windir + @"\explorer.exe", + FileName = windir + @"\explorer.exe", Arguments = logDir } }; prc.Start(); } - private void btn_copy_Click(object sender, EventArgs e) + /// <summary> + /// Copy the log + /// </summary> + /// <param name="sender"> + /// The sender. + /// </param> + /// <param name="e"> + /// The e. + /// </param> + private void BtnCopyClick(object sender, EventArgs e) { Clipboard.SetDataObject(rtf_actLog.SelectedText != string.Empty ? rtf_actLog.SelectedText : rtf_actLog.Text, true); } - private void btn_scan_log_Click(object sender, EventArgs e) + /// <summary> + /// Set scan mode + /// </summary> + /// <param name="sender"> + /// The sender. + /// </param> + /// <param name="e"> + /// The e. + /// </param> + private void BtnScanLogClick(object sender, EventArgs e) { SetScanMode(); } - private void btn_encode_log_Click(object sender, EventArgs e) + /// <summary> + /// Set the encode mode + /// </summary> + /// <param name="sender"> + /// The sender. + /// </param> + /// <param name="e"> + /// The e. + /// </param> + private void BtnEncodeLogClick(object sender, EventArgs e) { SetEncodeMode(); } - #endregion + // Overrides + /// <summary> + /// override onclosing + /// </summary> + /// <param name="e"> + /// The e. + /// </param> protected override void OnClosing(CancelEventArgs e) { - WindowTimer.Dispose(); + windowTimer.Dispose(); e.Cancel = true; this.Dispose(); base.OnClosing(e); diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index dad2201f2..505b49a47 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -1077,7 +1077,7 @@ namespace Handbrake this.x264Panel.Name = "x264Panel"; this.x264Panel.Size = new System.Drawing.Size(720, 306); this.x264Panel.TabIndex = 0; - this.x264Panel.X264Query = " -x "; + this.x264Panel.X264Query = " -x -x "; // // tab_query // diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index ca36cb9fa..8dd436c9b 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -2001,7 +2001,7 @@ namespace Handbrake Parser encode = new Parser(encodeQueue.HbProcess.StandardOutput.BaseStream); encode.OnEncodeProgress += EncodeOnEncodeProgress; while (!encode.EndOfStream) - encode.readEncodeStatus(); + encode.ReadEncodeStatus(); } catch (Exception exc) { -- cgit v1.2.3