summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsr55 <[email protected]>2010-02-22 21:23:28 +0000
committersr55 <[email protected]>2010-02-22 21:23:28 +0000
commit0a08b6778fa3dc2c38379d72252f23671e02e3c7 (patch)
tree08fc187f64054693c8d2055d5592fd096980a265
parentb1b9be20c1efd855723109051cacdf9e307f996f (diff)
WinGui:
- Some more cleanup git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3134 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--win/C#/Parsing/Parser.cs88
-rw-r--r--win/C#/Parsing/Subtitle.cs90
-rw-r--r--win/C#/Parsing/Title.cs169
-rw-r--r--win/C#/Settings.StyleCop10
-rw-r--r--win/C#/frmActivityWindow.Designer.cs10
-rw-r--r--win/C#/frmActivityWindow.cs272
-rw-r--r--win/C#/frmMain.Designer.cs2
-rw-r--r--win/C#/frmMain.cs2
8 files changed, 433 insertions, 210 deletions
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: <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.Parsing
{
@@ -15,31 +14,29 @@ namespace Handbrake.Parsing
/// <summary>
/// A delegate to handle custom events regarding data being parsed from the buffer
/// </summary>
- /// <param name="Sender">The object which raised this delegate</param>
- /// <param name="Data">The data parsed from the stream</param>
- public delegate void DataReadEventHandler(object Sender, string Data);
+ /// <param name="sender">The object which raised this delegate</param>
+ /// <param name="data">The data parsed from the stream</param>
+ public delegate void DataReadEventHandler(object sender, string data);
/// <summary>
/// A delegate to handle events regarding progress during DVD scanning
/// </summary>
- /// <param name="Sender">The object who's raising the event</param>
- /// <param name="CurrentTitle">The title number currently being processed</param>
- /// <param name="TitleCount">The total number of titiles to be processed</param>
- public delegate void ScanProgressEventHandler(object Sender, int CurrentTitle, int TitleCount);
+ /// <param name="sender">The object who's raising the event</param>
+ /// <param name="currentTitle">The title number currently being processed</param>
+ /// <param name="titleCount">The total number of titiles to be processed</param>
+ public delegate void ScanProgressEventHandler(object sender, int currentTitle, int titleCount);
/// <summary>
/// A delegate to handle encode progress updates // EXPERIMENTAL
/// </summary>
- /// <param name="Sender">The object which raised the event</param>
- /// <param name="CurrentTask">The current task being processed from the queue</param>
- /// <param name="TaskCount">The total number of tasks in queue</param>
- /// <param name="PercentComplete">The percentage this task is complete</param>
- /// <param name="CurrentFps">The current encoding fps</param>
- /// <param name="AverageFps">The average encoding fps for this task</param>
- /// <param name="TimeRemaining">The estimated time remaining for this task to complete</param>
- public delegate void EncodeProgressEventHandler(
- object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps,
- TimeSpan TimeRemaining);
+ /// <param name="sender">The object which raised the event</param>
+ /// <param name="currentTask">The current task being processed from the queue</param>
+ /// <param name="taskCount">The total number of tasks in queue</param>
+ /// <param name="percentComplete">The percentage this task is complete</param>
+ /// <param name="currentFps">The current encoding fps</param>
+ /// <param name="averageFps">The average encoding fps for this task</param>
+ /// <param name="timeRemaining">The estimated time remaining for this task to complete</param>
+ public delegate void EncodeProgressEventHandler(object sender, int currentTask, int taskCount, float percentComplete, float currentFps, float averageFps, TimeSpan timeRemaining);
/// <summary>
@@ -47,14 +44,20 @@ namespace Handbrake.Parsing
/// </summary>
internal class Parser : StreamReader
{
- private StringBuilder _buffer = new StringBuilder(string.Empty);
+ /// <summary>
+ /// The Buffer StringBuilder
+ /// </summary>
+ private StringBuilder buffer = new StringBuilder(string.Empty);
/// <summary>
- /// The output from the CLI process
+ /// Initializes a new instance of the <see cref="Parser"/> class.
+ /// Default constructor for this object
/// </summary>
- public string Buffer
+ /// <param name="baseStream">
+ /// The stream to parse from
+ /// </param>
+ public Parser(Stream baseStream) : base(baseStream)
{
- get { return _buffer.ToString(); }
}
/// <summary>
@@ -72,32 +75,30 @@ namespace Handbrake.Parsing
/// </summary>
public event ScanProgressEventHandler OnScanProgress;
- #region Experimetnal Code
-
/// <summary>
/// Raised upon the catching of a "Scanning title # of #..." in the stream
/// </summary>
public event EncodeProgressEventHandler OnEncodeProgress;
- #endregion
-
/// <summary>
- /// Initializes a new instance of the <see cref="Parser"/> class.
- /// Default constructor for this object
+ /// Gets the buffer of data that came from the CLI standard input/error
/// </summary>
- /// <param name="baseStream">
- /// The stream to parse from
- /// </param>
- public Parser(Stream baseStream)
- : base(baseStream)
+ public string Buffer
{
+ get { return buffer.ToString(); }
}
+ /// <summary>
+ /// Read a line from standard in/err
+ /// </summary>
+ /// <returns>
+ /// The read line
+ /// </returns>
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;
}
+ /// <summary>
+ /// Read to the end of the input stream
+ /// </summary>
+ /// <returns>
+ /// A string of the input data
+ /// </returns>
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
/// <summary>
/// Pase the CLI status output (from standard output)
/// </summary>
- 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: <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.Parsing
{
@@ -15,54 +14,67 @@ namespace Handbrake.Parsing
/// </summary>
public class Subtitle
{
- private string m_language;
- private int m_trackNumber;
- private string m_type;
- private string m_typecode;
+ /// <summary>
+ /// The Language
+ /// </summary>
+ private string language;
+
+ /// <summary>
+ /// The Track Number
+ /// </summary>
+ private int trackNumber;
+
+ /// <summary>
+ /// The type of subtitle
+ /// </summary>
+ private string type;
/// <summary>
- /// The track number of this Subtitle
+ /// The typecode
+ /// </summary>
+ private string typecode;
+
+ /// <summary>
+ /// Gets the track number of this Subtitle
/// </summary>
public int TrackNumber
{
- get { return m_trackNumber; }
+ get { return trackNumber; }
}
/// <summary>
- /// The language (if detected) of this Subtitle
+ /// Gets the The language (if detected) of this Subtitle
/// </summary>
public string Language
{
- get { return m_language; }
+ get { return language; }
}
/// <summary>
- /// Langauage Code
+ /// Gets the Langauage Code
/// </summary>
public string LanguageCode
{
- get { return m_typecode; }
+ get { return typecode; }
}
-
/// <summary>
- /// Subtitle Type
+ /// Gets the Subtitle Type
/// </summary>
public string Type
{
- get { return m_type; }
+ get { return type; }
}
-
/// <summary>
- /// Override of the ToString method to make this object easier to use in the UI
+ /// Parse the input strings related to subtitles
/// </summary>
- /// <returns>A string formatted as: {track #} {language}</returns>
- public override string ToString()
- {
- return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_type);
- }
-
+ /// <param name="output">
+ /// The output.
+ /// </param>
+ /// <returns>
+ /// A Subitle object
+ /// </returns>
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)
+ /// <summary>
+ /// Parse a list of Subtitle tracks from an input string.
+ /// </summary>
+ /// <param name="output">
+ /// The output.
+ /// </param>
+ /// <returns>
+ /// An array of Subtitle objects
+ /// </returns>
+ public static IEnumerable<Subtitle> ParseList(StringReader output)
{
var subtitles = new List<Subtitle>();
while ((char) output.Peek() != '+')
@@ -96,5 +117,14 @@ namespace Handbrake.Parsing
}
return subtitles.ToArray();
}
+
+ /// <summary>
+ /// Override of the ToString method to make this object easier to use in the UI
+ /// </summary>
+ /// <returns>A string formatted as: {track #} {language}</returns>
+ 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: <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.Parsing
{
@@ -18,19 +17,70 @@ namespace Handbrake.Parsing
/// </summary>
public class Title
{
+ /// <summary>
+ /// The Culture Info
+ /// </summary>
private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
- private readonly List<AudioTrack> m_audioTracks;
- private readonly List<Chapter> m_chapters;
- private readonly List<Subtitle> m_subtitles;
- private List<string> m_angles = new List<string>();
- private float m_aspectRatio;
- private float m_fps;
- private int[] m_autoCrop;
+
+ /// <summary>
+ /// A collection of Audio Tracks
+ /// </summary>
+ private readonly List<AudioTrack> audioTracks;
+
+ /// <summary>
+ /// A Collection of Chapters
+ /// </summary>
+ private readonly List<Chapter> chapters;
+
+ /// <summary>
+ /// A Collection of Subtitles
+ /// </summary>
+ private readonly List<Subtitle> subtitles;
+
+ /// <summary>
+ /// A collection of angles
+ /// </summary>
+ private List<string> angles = new List<string>();
+
+ /// <summary>
+ /// The source aspect ratio
+ /// </summary>
+ private float aspectRatio;
+
+ /// <summary>
+ /// The source framerate
+ /// </summary>
+ private float fps;
+
+ /// <summary>
+ /// Source autocrop values
+ /// </summary>
+ private int[] autoCrop;
+
+ /// <summary>
+ /// Source name
+ /// </summary>
private string source;
- private TimeSpan m_duration;
- private Size m_resolution;
- private int m_titleNumber;
- private Size m_parVal;
+
+ /// <summary>
+ /// The duration of the source
+ /// </summary>
+ private TimeSpan duration;
+
+ /// <summary>
+ /// The source resolution
+ /// </summary>
+ private Size resolution;
+
+ /// <summary>
+ /// The Title number
+ /// </summary>
+ private int titleNumber;
+
+ /// <summary>
+ /// The par values for this title.
+ /// </summary>
+ private Size parVal;
/// <summary>
/// Initializes a new instance of the <see cref="Title"/> class.
@@ -38,33 +88,33 @@ namespace Handbrake.Parsing
/// </summary>
public Title()
{
- m_audioTracks = new List<AudioTrack>();
- m_chapters = new List<Chapter>();
- m_subtitles = new List<Subtitle>();
+ audioTracks = new List<AudioTrack>();
+ chapters = new List<Chapter>();
+ subtitles = new List<Subtitle>();
}
/// <summary>
- /// Collection of chapters in this Title
+ /// Gets a Collection of chapters in this Title
/// </summary>
public List<Chapter> Chapters
{
- get { return m_chapters; }
+ get { return chapters; }
}
/// <summary>
- /// Collection of audio tracks associated with this Title
+ /// Gets a Collection of audio tracks associated with this Title
/// </summary>
public List<AudioTrack> AudioTracks
{
- get { return m_audioTracks; }
+ get { return audioTracks; }
}
/// <summary>
- /// Collection of subtitles associated with this Title
+ /// Gets aCollection of subtitles associated with this Title
/// </summary>
public List<Subtitle> Subtitles
{
- get { return m_subtitles; }
+ get { return subtitles; }
}
/// <summary>
@@ -72,11 +122,11 @@ namespace Handbrake.Parsing
/// </summary>
public int TitleNumber
{
- get { return m_titleNumber; }
+ get { return titleNumber; }
}
/// <summary>
- /// Source Name
+ /// Gets the Source Name
/// </summary>
public string SourceName
{
@@ -84,39 +134,39 @@ namespace Handbrake.Parsing
}
/// <summary>
- /// The length in time of this Title
+ /// Gets the length in time of this Title
/// </summary>
public TimeSpan Duration
{
- get { return m_duration; }
+ get { return duration; }
}
/// <summary>
- /// The resolution (width/height) of this Title
+ /// Gets the resolution (width/height) of this Title
/// </summary>
public Size Resolution
{
- get { return m_resolution; }
+ get { return resolution; }
}
/// <summary>
- /// The aspect ratio of this Title
+ /// Gets the aspect ratio of this Title
/// </summary>
public float AspectRatio
{
- get { return m_aspectRatio; }
+ get { return aspectRatio; }
}
/// <summary>
- /// Par Value
+ /// Gets Par Value
/// </summary>
public Size ParVal
{
- get { return m_parVal; }
+ get { return parVal; }
}
/// <summary>
- /// 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
/// </summary>
public int[] AutoCropDimensions
{
- get { return m_autoCrop; }
+ get { return autoCrop; }
}
/// <summary>
- /// Collection of Angles in this Title
+ /// Gets a Collection of Angles in this Title
/// </summary>
public List<string> Angles
{
- get { return m_angles; }
+ get { return angles; }
}
+
/// <summary>
- /// Collection of Angles in this Title
+ /// Gets the FPS of the source.
/// </summary>
public float Fps
{
- get { return m_fps; }
+ get { return fps; }
}
/// <summary>
@@ -150,15 +201,14 @@ namespace Handbrake.Parsing
/// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>
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);
}
/// <summary>
/// Parse the Title Information
/// </summary>
- /// <param name="output"></param>
- /// <returns></returns>
+ /// <param name="output">A stingreader of output data</param>
+ /// <returns>A Title</returns>
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
/// <summary>
/// Return a list of parsed titles
/// </summary>
- /// <param name="output"></param>
- /// <returns></returns>
+ /// <param name="output">The Output</param>
+ /// <returns>A List of titles</returns>
public static Title[] ParseList(string output)
{
var titles = new List<Title>();
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)
{