diff options
author | sr55 <sr55.hb@outlook.com> | 2010-02-20 18:08:41 +0000 |
---|---|---|
committer | sr55 <sr55.hb@outlook.com> | 2010-02-20 18:08:41 +0000 |
commit | b9d00019295781bed79eca280bac798b7bb7c64f (patch) | |
tree | 341aac9ec87d84d71be18a42afe0ee52ef497d3f /win/C# | |
parent | e5d5bc94b2217a9eb65857d83d31138d126947e4 (diff) |
WinGui:
- Tied Microsoft StyleCop into the build process.
- Included a settings file for StyleCop so anyone who picks up the project can use the global project settings.
- Started Clearing up Warnings generated by stylecop.
- Also included Resharper 5 config files that users can use.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3129 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#')
-rw-r--r-- | win/C#/Controls/Subtitles.cs | 5 | ||||
-rw-r--r-- | win/C#/Functions/AppcastReader.cs | 96 | ||||
-rw-r--r-- | win/C#/Functions/GrowlCommunicator.cs | 49 | ||||
-rw-r--r-- | win/C#/Functions/Main.cs | 271 | ||||
-rw-r--r-- | win/C#/Functions/PresetLoader.cs | 45 | ||||
-rw-r--r-- | win/C#/Functions/QueryGenerator.cs | 133 | ||||
-rw-r--r-- | win/C#/Functions/Scan.cs | 132 | ||||
-rw-r--r-- | win/C#/Functions/System.cs | 31 | ||||
-rw-r--r-- | win/C#/Functions/UpdateCheckInformation.cs | 70 | ||||
-rw-r--r-- | win/C#/Functions/Win32.cs | 54 | ||||
-rw-r--r-- | win/C#/HandBrakeCS.5.0.ReSharper | 109 | ||||
-rw-r--r-- | win/C#/HandBrakeCS.csproj | 1 | ||||
-rw-r--r-- | win/C#/HandBrakeCS.csproj.ReSharper | 3 | ||||
-rw-r--r-- | win/C#/Settings.StyleCop | 130 |
14 files changed, 808 insertions, 321 deletions
diff --git a/win/C#/Controls/Subtitles.cs b/win/C#/Controls/Subtitles.cs index 45a21475f..34e2cddf3 100644 --- a/win/C#/Controls/Subtitles.cs +++ b/win/C#/Controls/Subtitles.cs @@ -311,12 +311,15 @@ namespace Handbrake.Controls }
}
+ /// <summary>
+ /// Set all subtitle tracks so that they have no default.
+ /// </summary>
private void SetNoSrtDefault()
{
int c = 0;
foreach (ListViewItem item in lv_subList.Items)
{
- if (subList[c].SrtPath != "-")
+ if (!subList[c].IsSrtSubtitle)
{
if (item.SubItems[3].Text == "Yes")
{
diff --git a/win/C#/Functions/AppcastReader.cs b/win/C#/Functions/AppcastReader.cs index ea9cac112..7248ffa78 100644 --- a/win/C#/Functions/AppcastReader.cs +++ b/win/C#/Functions/AppcastReader.cs @@ -1,39 +1,64 @@ /* RssReader.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. */
-
-using System;
-using System.Xml;
-using System.Text.RegularExpressions;
-using System.IO;
+ 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.Functions
{
+ using System;
+ using System.IO;
+ using System.Text.RegularExpressions;
+ using System.Xml;
+
+ /// <summary>
+ /// Appcast Reader - Used for parsing HandBrakes update file
+ /// </summary>
public class AppcastReader
{
/// <summary>
+ /// Gets Information about an update to HandBrake
+ /// </summary>
+ public Uri DescriptionUrl { get; private set; }
+
+ /// <summary>
+ /// Gets HandBrake's version from the appcast.xml file.
+ /// </summary>
+ public string Version { get; private set; }
+
+ /// <summary>
+ /// Gets HandBrake's Build from the appcast.xml file.
+ /// </summary>
+ public string Build { get; private set; }
+
+ /// <summary>
+ /// Gets the URL for update file.
+ /// </summary>
+ public string DownloadFile { get; private set; }
+
+ /// <summary>
/// Get the build information from the required appcasts. Run before accessing the public vars.
/// </summary>
+ /// <param name="input">
+ /// The input.
+ /// </param>
public void GetInfo(string input)
{
try
{
// Get the correct Appcast and set input.
- XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input)));
+ XmlNode nodeItem = ReadRss(new XmlTextReader(new StringReader(input)));
string result = nodeItem.InnerXml;
// Regular Expressions
Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\""");
Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\""");
- Build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", "");
- Version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", "");
- DownloadFile = nodeItem["windows"].InnerText;
- DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
- }
- catch( Exception)
+ this.Build = ver.ToString().Replace("sparkle:version=", string.Empty).Replace("\"", string.Empty);
+ this.Version = verShort.ToString().Replace("sparkle:shortVersionString=", string.Empty).Replace("\"", string.Empty);
+ this.DownloadFile = nodeItem["windows"].InnerText;
+ this.DescriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText);
+ }
+ catch (Exception)
{
return;
}
@@ -42,8 +67,13 @@ namespace Handbrake.Functions /// <summary>
/// Read the RSS file.
/// </summary>
- /// <param name="rssReader"></param>
- private static XmlNode readRss(XmlReader rssReader)
+ /// <param name="rssReader">
+ /// The RSS reader
+ /// </param>
+ /// <returns>
+ /// The read rss.
+ /// </returns>
+ private static XmlNode ReadRss(XmlReader rssReader)
{
XmlNode nodeItem = null;
XmlNode nodeChannel = null;
@@ -55,44 +85,34 @@ namespace Handbrake.Functions foreach (XmlNode t in rssDoc.ChildNodes)
{
if (t.Name == "rss")
+ {
nodeRss = t;
+ }
}
if (nodeRss != null)
+ {
foreach (XmlNode t in nodeRss.ChildNodes)
{
if (t.Name == "channel")
+ {
nodeChannel = t;
+ }
}
+ }
if (nodeChannel != null)
+ {
foreach (XmlNode t in nodeChannel.ChildNodes)
{
if (t.Name == "item")
+ {
nodeItem = t;
+ }
}
+ }
return nodeItem;
}
-
- /// <summary>
- /// Get Information about an update to HandBrake
- /// </summary>
- public Uri DescriptionUrl { get; set; }
-
- /// <summary>
- /// Get HandBrake's version from the appcast.xml file.
- /// </summary>
- public string Version { get; set; }
-
- /// <summary>
- /// Get HandBrake's Build from the appcast.xml file.
- /// </summary>
- public string Build { get; set; }
-
- /// <summary>
- /// Get's the URL for update file.
- /// </summary>
- public string DownloadFile { get; set; }
}
}
\ No newline at end of file diff --git a/win/C#/Functions/GrowlCommunicator.cs b/win/C#/Functions/GrowlCommunicator.cs index 507ebd5ac..04450eefc 100644 --- a/win/C#/Functions/GrowlCommunicator.cs +++ b/win/C#/Functions/GrowlCommunicator.cs @@ -1,17 +1,16 @@ /* GrowlCommunicator.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. */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Growl.Connector;
-using Growl.CoreLibrary;
+ 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.Functions
{
+ using System;
+ using System.Collections.Generic;
+ using System.Text;
+ using Growl.Connector;
+ using Growl.CoreLibrary;
+
/// <summary>
/// Provides all functionality for communicating with Growl for Windows.
/// </summary>
@@ -36,7 +35,7 @@ namespace Handbrake.Functions /// <summary>
/// Notification shown upon completion of encoding
/// </summary>
- public static NotificationType EncodeOrQueueCompleted = new NotificationType("EncodeOrQueue", "HandBrake Status");
+ private static NotificationType encodeOrQueueCompleted = new NotificationType("EncodeOrQueue", "HandBrake Status");
/// <summary>
/// Checks to see if Growl is currently running on the local machine.
@@ -61,16 +60,22 @@ namespace Handbrake.Functions public static void Register()
{
Initialize();
- growl.Register(application, new NotificationType[] { EncodeOrQueueCompleted });
+ growl.Register(application, new NotificationType[] { encodeOrQueueCompleted });
}
/// <summary>
/// Sends a notification to Growl. (Since Handbrake currently only supports one type of notification with
/// static text, this is a shortcut method).
/// </summary>
+ /// <param name="title">
+ /// The title.
+ /// </param>
+ /// <param name="text">
+ /// The text to display.
+ /// </param>
public static void Notify(string title, string text)
{
- Notification notification = new Notification(application.Name, EncodeOrQueueCompleted.Name, String.Empty, title, text);
+ Notification notification = new Notification(application.Name, encodeOrQueueCompleted.Name, String.Empty, title, text);
growl.Notify(notification);
}
@@ -84,8 +89,10 @@ namespace Handbrake.Functions /// <param name="imageUrl">The notification image as a url</param>
public static void Notify(NotificationType notificationType, string title, string text, string imageUrl)
{
- Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title, text);
- notification.Icon = imageUrl;
+ Notification notification = new Notification(application.Name, notificationType.Name, String.Empty, title, text)
+ {
+ Icon = imageUrl
+ };
growl.Notify(notification);
}
@@ -97,11 +104,15 @@ namespace Handbrake.Functions {
if (growl == null)
{
- growl = new GrowlConnector();
- growl.EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText;
+ growl = new GrowlConnector
+ {
+ EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText
+ };
- application = new Application("Handbrake");
- application.Icon = global::Handbrake.Properties.Resources.logo64;
+ application = new Application("Handbrake")
+ {
+ Icon = Properties.Resources.logo64
+ };
}
}
}
diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index 3071cf5d0..96550706a 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -1,35 +1,52 @@ /* Main.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. */
-
-using System;
-using System.Windows.Forms;
-using System.IO;
-using System.Diagnostics;
-using System.Text.RegularExpressions;
-using System.Collections.Generic;
-using System.Xml.Serialization;
-using System.Threading;
-using Handbrake.EncodeQueue;
-using System.Net;
-using Handbrake.Model;
+ 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.Functions
{
- static class Main
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Net;
+ using System.Text.RegularExpressions;
+ using System.Threading;
+ using System.Windows.Forms;
+ using System.Xml.Serialization;
+ using EncodeQueue;
+ using Model;
+
+ /// <summary>
+ /// Useful functions which various screens can use.
+ /// </summary>
+ public static class Main
{
- // Private Variables
+ /// <summary>
+ /// The XML Serializer
+ /// </summary>
private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Job>));
/// <summary>
/// Calculate the duration of the selected title and chapters
/// </summary>
+ /// <param name="chapterStart">
+ /// The chapter Start.
+ /// </param>
+ /// <param name="chapterEnd">
+ /// The chapter End.
+ /// </param>
+ /// <param name="selectedTitle">
+ /// The selected Title.
+ /// </param>
+ /// <returns>
+ /// The calculated duration.
+ /// </returns>
public static TimeSpan CalculateDuration(int chapterStart, int chapterEnd, Parsing.Title selectedTitle)
{
TimeSpan duration = TimeSpan.FromSeconds(0.0);
- chapterStart++; chapterEnd++;
+ chapterStart++;
+ chapterEnd++;
if (chapterStart != 0 && chapterEnd != 0 && chapterEnd <= selectedTitle.Chapters.Count)
{
for (int i = chapterStart; i <= chapterEnd; i++)
@@ -42,12 +59,18 @@ namespace Handbrake.Functions /// <summary>
/// Select the longest title in the DVD title dropdown menu on frmMain
/// </summary>
- public static Parsing.Title SelectLongestTitle(Parsing.DVD thisDvd)
+ /// <param name="source">
+ /// The Source.
+ /// </param>
+ /// <returns>
+ /// The longest title.
+ /// </returns>
+ public static Parsing.Title SelectLongestTitle(Parsing.DVD source)
{
TimeSpan longestDurationFound = TimeSpan.FromSeconds(0.0);
Parsing.Title returnTitle = null;
- foreach (Parsing.Title item in thisDvd.Titles)
+ foreach (Parsing.Title item in source.Titles)
{
if (item.Duration > longestDurationFound)
{
@@ -61,6 +84,15 @@ namespace Handbrake.Functions /// <summary>
/// Set's up the DataGridView on the Chapters tab (frmMain)
/// </summary>
+ /// <param name="dataChpt">
+ /// The DataGridView Control
+ /// </param>
+ /// <param name="chapterEnd">
+ /// The chapter End.
+ /// </param>
+ /// <returns>
+ /// The chapter naming.
+ /// </returns>
public static DataGridView ChapterNaming(DataGridView dataChpt, string chapterEnd)
{
int i = 0, finish = 0;
@@ -71,7 +103,7 @@ namespace Handbrake.Functions while (i < finish)
{
int n = dataChpt.Rows.Add();
- dataChpt.Rows[n].Cells[0].Value = (i + 1);
+ dataChpt.Rows[n].Cells[0].Value = i + 1;
dataChpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1);
dataChpt.Rows[n].Cells[0].ValueType = typeof(int);
dataChpt.Rows[n].Cells[1].ValueType = typeof(string);
@@ -84,9 +116,13 @@ namespace Handbrake.Functions /// <summary>
/// Import a CSV file which contains Chapter Names
/// </summary>
- /// <param name="dataChpt"></param>
- /// <param name="filename"></param>
- /// <returns></returns>
+ /// <param name="dataChpt">
+ /// The DataGridView Control
+ /// </param>
+ /// <param name="filename">
+ /// The filepath and name
+ /// </param>
+ /// <returns>A Populated DataGridView</returns>
public static DataGridView ImportChapterNames(DataGridView dataChpt, string filename)
{
IDictionary<int, string> chapterMap = new Dictionary<int, string>();
@@ -96,7 +132,7 @@ namespace Handbrake.Functions string csv = sr.ReadLine();
while (csv != null)
{
- if (csv.Trim() != "")
+ if (csv.Trim() != string.Empty)
{
csv = csv.Replace("\\,", "<!comma!>");
string[] contents = csv.Split(',');
@@ -126,9 +162,15 @@ namespace Handbrake.Functions /// Function which generates the filename and path automatically based on
/// the Source Name, DVD title and DVD Chapters
/// </summary>
+ /// <param name="mainWindow">
+ /// The main Window.
+ /// </param>
+ /// <returns>
+ /// The Generated FileName
+ /// </returns>
public static string AutoName(frmMain mainWindow)
{
- string AutoNamePath = string.Empty;
+ string autoNamePath = string.Empty;
if (mainWindow.drp_dvdtitle.Text != "Automatic")
{
// Get the Source Name
@@ -136,18 +178,18 @@ namespace Handbrake.Functions // Get the Selected Title Number
string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');
- string dvdTitle = titlesplit[0].Replace("Automatic", "");
+ string dvdTitle = titlesplit[0].Replace("Automatic", string.Empty);
// Get the Chapter Start and Chapter End Numbers
- string chapterStart = mainWindow.drop_chapterStart.Text.Replace("Auto", "");
- string chapterFinish = mainWindow.drop_chapterFinish.Text.Replace("Auto", "");
+ string chapterStart = mainWindow.drop_chapterStart.Text.Replace("Auto", string.Empty);
+ string chapterFinish = mainWindow.drop_chapterFinish.Text.Replace("Auto", string.Empty);
string combinedChapterTag = chapterStart;
- if (chapterFinish != chapterStart && chapterFinish != "")
+ if (chapterFinish != chapterStart && chapterFinish != string.Empty)
combinedChapterTag = chapterStart + "-" + chapterFinish;
// Get the destination filename.
string destinationFilename;
- if (Properties.Settings.Default.autoNameFormat != "")
+ if (Properties.Settings.Default.autoNameFormat != string.Empty)
{
destinationFilename = Properties.Settings.Default.autoNameFormat;
destinationFilename = destinationFilename.Replace("{source}", sourceName).Replace("{title}", dvdTitle).Replace("{chapters}", combinedChapterTag);
@@ -171,83 +213,87 @@ namespace Handbrake.Functions if (!mainWindow.text_destination.Text.Contains(Path.DirectorySeparatorChar.ToString()))
{
// If there is an auto name path, use it...
- if (Properties.Settings.Default.autoNamePath.Trim() != "" && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
- AutoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destinationFilename);
+ if (Properties.Settings.Default.autoNamePath.Trim() != string.Empty && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
+ autoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destinationFilename);
else // ...otherwise, output to the source directory
- AutoNamePath = null;
+ autoNamePath = null;
}
else // Otherwise, use the path that is already there.
{
// Use the path and change the file extension to match the previous destination
- AutoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);
+ autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);
if (Path.HasExtension(mainWindow.text_destination.Text))
- AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(mainWindow.text_destination.Text));
+ autoNamePath = Path.ChangeExtension(autoNamePath, Path.GetExtension(mainWindow.text_destination.Text));
}
}
- return AutoNamePath;
+ return autoNamePath;
}
/// <summary>
/// Get's HandBrakes version data from the CLI.
/// </summary>
- /// <returns>Arraylist of Version Data. 0 = hb_version 1 = hb_build</returns>
public static void SetCliVersionData()
{
- String line;
+ string line;
// 0 = SVN Build / Version
// 1 = Build Date
-
DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");
-
if (Properties.Settings.Default.cliLastModified == lastModified && Properties.Settings.Default.hb_build != 0)
return;
Properties.Settings.Default.cliLastModified = lastModified;
Process cliProcess = new Process();
- ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")
+ ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")
{
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
CreateNoWindow = true
};
- cliProcess.StartInfo = handBrakeCLI;
+ cliProcess.StartInfo = handBrakeCli;
try
{
cliProcess.Start();
+
// Retrieve standard output and report back to parent thread until the process is complete
TextReader stdOutput = cliProcess.StandardError;
while (!cliProcess.HasExited)
{
- line = stdOutput.ReadLine() ?? "";
+ line = stdOutput.ReadLine() ?? string.Empty;
Match m = Regex.Match(line, @"HandBrake ([svnM0-9.]*) \([0-9]*\)");
Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -");
if (m.Success)
{
- string data = line.Replace("(", "").Replace(")", "").Replace("HandBrake ", "");
+ string data = line.Replace("(", string.Empty).Replace(")", string.Empty).Replace("HandBrake ", string.Empty);
string[] arr = data.Split(' ');
Properties.Settings.Default.hb_build = int.Parse(arr[1]);
Properties.Settings.Default.hb_version = arr[0];
}
+
if (platform.Success)
- Properties.Settings.Default.hb_platform = platform.Value.Replace("-", "").Trim();
+ {
+ Properties.Settings.Default.hb_platform = platform.Value.Replace("-", string.Empty).Trim();
+ }
if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
{
Process cli = Process.GetProcessById(cliProcess.Id);
if (!cli.HasExited)
+ {
cli.Kill();
+ }
}
}
+
Properties.Settings.Default.Save();
}
catch (Exception e)
@@ -261,7 +307,10 @@ namespace Handbrake.Functions /// If it does, it means the last queue did not complete before HandBrake closed.
/// So, return a boolean if true.
/// </summary>
- public static Boolean CheckQueueRecovery()
+ /// <returns>
+ /// True if there is a queue to recover.
+ /// </returns>
+ public static bool CheckQueueRecovery()
{
try
{
@@ -312,7 +361,7 @@ namespace Handbrake.Functions Process hbProcess = null;
foreach (Process process in hbProcesses)
{
- Boolean found = false;
+ bool found = false;
// Check if the current CLI instance was running before we started the current one
foreach (Process bprocess in before)
{
@@ -347,7 +396,6 @@ namespace Handbrake.Functions {
if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") && !file.Name.Contains("tmp_appReadable_log.txt"))
File.Delete(file.FullName);
-
}
}
}
@@ -369,7 +417,6 @@ namespace Handbrake.Functions {
if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") && !file.Name.Contains("tmp_appReadable_log.txt"))
File.Delete(file.FullName);
-
}
}
}
@@ -383,54 +430,76 @@ namespace Handbrake.Functions public static void BeginCheckForUpdates(AsyncCallback callback, bool debug)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
- {
- try
- {
- // Is this a stable or unstable build?
- string url = Properties.Settings.Default.hb_build.ToString().EndsWith("1") ? Properties.Settings.Default.appcast_unstable : Properties.Settings.Default.appcast;
-
- // Initialize variables
- WebRequest request = WebRequest.Create(url);
- WebResponse response = request.GetResponse();
- AppcastReader reader = new AppcastReader();
-
- // Get the data, convert it to a string, and parse it into the AppcastReader
- reader.GetInfo(new StreamReader(response.GetResponseStream()).ReadToEnd());
-
- // Further parse the information
- string build = reader.Build;
-
- int latest = int.Parse(build);
- int current = Properties.Settings.Default.hb_build;
- int skip = Properties.Settings.Default.skipversion;
-
- // If the user wanted to skip this version, don't report the update
- if (latest == skip)
- {
- UpdateCheckInformation info = new UpdateCheckInformation() { NewVersionAvailable = false, BuildInformation = null };
- callback(new UpdateCheckResult(debug, info));
- return;
- }
-
- // Set when the last update was
- Properties.Settings.Default.lastUpdateCheckDate = DateTime.Now;
- Properties.Settings.Default.Save();
-
- UpdateCheckInformation info2 = new UpdateCheckInformation() { NewVersionAvailable = latest > current, BuildInformation = reader };
- callback(new UpdateCheckResult(debug, info2));
- }
- catch (Exception exc)
- {
- callback(new UpdateCheckResult(debug, new UpdateCheckInformation() { Error = exc }));
- }
- }));
+ {
+ try
+ {
+ // Is this a stable or unstable build?
+ string url =
+ Properties.Settings.Default.hb_build.ToString()
+ .EndsWith("1")
+ ? Properties.Settings.Default.
+ appcast_unstable
+ : Properties.Settings.Default.appcast;
+
+ // Initialize variables
+ WebRequest request = WebRequest.Create(url);
+ WebResponse response = request.GetResponse();
+ AppcastReader reader = new AppcastReader();
+
+ // Get the data, convert it to a string, and parse it into the AppcastReader
+ reader.GetInfo(
+ new StreamReader(response.GetResponseStream())
+ .ReadToEnd());
+
+ // Further parse the information
+ string build = reader.Build;
+
+ int latest = int.Parse(build);
+ int current = Properties.Settings.Default.hb_build;
+ int skip = Properties.Settings.Default.skipversion;
+
+ // If the user wanted to skip this version, don't report the update
+ if (latest == skip)
+ {
+ UpdateCheckInformation info =
+ new UpdateCheckInformation
+ {
+ NewVersionAvailable = false,
+ BuildInformation = null
+ };
+ callback(new UpdateCheckResult(debug, info));
+ return;
+ }
+
+ // Set when the last update was
+ Properties.Settings.Default.lastUpdateCheckDate =
+ DateTime.Now;
+ Properties.Settings.Default.Save();
+
+ UpdateCheckInformation info2 =
+ new UpdateCheckInformation
+ {
+ NewVersionAvailable = latest > current,
+ BuildInformation = reader
+ };
+ callback(new UpdateCheckResult(debug, info2));
+ }
+ catch (Exception exc)
+ {
+ callback(new UpdateCheckResult(debug, new UpdateCheckInformation{Error = exc}));
+ }
+ }));
}
/// <summary>
- ///
+ /// End Check for Updates
/// </summary>
- /// <param name="result"></param>
- /// <returns></returns>
+ /// <param name="result">
+ /// The result.
+ /// </param>
+ /// <returns>
+ /// Update Check information
+ /// </returns>
public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)
{
UpdateCheckResult checkResult = (UpdateCheckResult)result;
@@ -440,7 +509,7 @@ namespace Handbrake.Functions /// <summary>
/// Map languages and their iso639_2 value into a IDictionary
/// </summary>
- /// <returns></returns>
+ /// <returns>A Dictionary containing the language and iso code</returns>
public static IDictionary<string, string> MapLanguages()
{
IDictionary<string, string> languageMap = new Dictionary<string, string>
@@ -638,7 +707,7 @@ namespace Handbrake.Functions /// <summary>
/// Get a list of available DVD drives which are ready and contain DVD content.
/// </summary>
- /// <returns></returns>
+ /// <returns>A List of Drives with their details</returns>
public static List<DriveInformation> GetDrives()
{
List<DriveInformation> drives = new List<DriveInformation>();
@@ -648,10 +717,10 @@ namespace Handbrake.Functions if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady && File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))
{
drives.Add(new DriveInformation
- {
- VolumeLabel = curDrive.VolumeLabel,
- RootDirectory = curDrive.RootDirectory + "VIDEO_TS"
- });
+ {
+ VolumeLabel = curDrive.VolumeLabel,
+ RootDirectory = curDrive.RootDirectory + "VIDEO_TS"
+ });
}
}
return drives;
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs index a6614b99c..a550bfa1d 100644 --- a/win/C#/Functions/PresetLoader.cs +++ b/win/C#/Functions/PresetLoader.cs @@ -1,27 +1,36 @@ /* PresetLoader.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. */
-
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using Handbrake.Model;
+ 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.Functions
{
- class PresetLoader
+ using System;
+ using System.Drawing;
+ using System.Windows.Forms;
+
+ /// <summary>
+ /// Load a preset into the main Window
+ /// </summary>
+ public class PresetLoader
{
/// <summary>
/// This function takes in a Query which has been parsed by QueryParser and
/// set's all the GUI widgets correctly.
/// </summary>
- /// <param name="mainWindow"></param>
- /// <param name="presetQuery">The Parsed CLI Query</param>
- /// <param name="name">Name of the preset</param>
- /// <param name="pictureSettings">Save picture settings in the preset</param>
- public static void LoadPreset(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)
+ /// <param name="mainWindow">
+ /// FrmMain window
+ /// </param>
+ /// <param name="presetQuery">
+ /// The Parsed CLI Query
+ /// </param>
+ /// <param name="name">
+ /// Name of the preset
+ /// </param>
+ /// <param name="pictureSettings">
+ /// Save picture settings in the preset
+ /// </param>
+ public static void LoadPreset(frmMain mainWindow, QueryParser presetQuery, string name, bool pictureSettings)
{
#region Source
// Reset some vaules to stock first to prevent errors.
@@ -163,12 +172,12 @@ namespace Handbrake.Functions {
double cqStep = Properties.Settings.Default.x264cqstep;
int value;
- double x264step = cqStep;
+ double x264Step = cqStep;
double presetValue = presetQuery.VideoQuality;
- double x = 51 / x264step;
+ double x = 51 / x264Step;
- double calculated = presetValue / x264step;
+ double calculated = presetValue / x264Step;
calculated = x - calculated;
int.TryParse(calculated.ToString(), out value);
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs index 1aaef8f46..592640f79 100644 --- a/win/C#/Functions/QueryGenerator.cs +++ b/win/C#/Functions/QueryGenerator.cs @@ -1,36 +1,47 @@ /* QueryGenerator.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. */
-
-using System;
-using System.Windows.Forms;
-using System.Globalization;
-using System.IO;
-using System.Collections.Generic;
-using Handbrake.Model;
+ 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.Functions
{
- class QueryGenerator
+ using System;
+ using System.Collections.Generic;
+ using System.Globalization;
+ using System.IO;
+ using System.Windows.Forms;
+
+ /// <summary>
+ /// Generate a CLI Query for HandBrakeCLI
+ /// </summary>
+ public class QueryGenerator
{
/// <summary>
/// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined.
/// </summary>
- /// <param name="mainWindow">The Main Window</param>
- /// <param name="mode">What Mode. (Point to Point Encoding) Chapters, Seconds, Frames OR Preview Encode</param>
- /// <param name="duration">time in seconds for preview mode</param>
- /// <param name="preview"> --start-at-preview (int) </param>
- /// <returns>CLI Query </returns>
+ /// <param name="mainWindow">
+ /// The Main Window
+ /// </param>
+ /// <param name="mode">
+ /// What Mode. (Point to Point Encoding) Chapters, Seconds, Frames OR Preview Encode
+ /// </param>
+ /// <param name="duration">
+ /// Time in seconds for preview mode
+ /// </param>
+ /// <param name="preview">
+ /// Preview --start-at-preview (int)
+ /// </param>
+ /// <returns>
+ /// CLI Query
+ /// </returns>
public static string GenerateCliQuery(frmMain mainWindow, int mode, int duration, string preview)
{
- string query = "";
+ string query = string.Empty;
if (!string.IsNullOrEmpty(mainWindow.sourcePath) && mainWindow.sourcePath.Trim() != "Select \"Source\" to continue")
query = " -i " + '"' + mainWindow.sourcePath + '"';
- if (mainWindow.drp_dvdtitle.Text != "")
+ if (mainWindow.drp_dvdtitle.Text != string.Empty)
{
string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');
query += " -t " + titleInfo[0];
@@ -43,9 +54,9 @@ namespace Handbrake.Functions switch (mode)
{
case 0: // Chapters
- if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "")
+ if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != string.Empty)
query += string.Format(" -c {0}", mainWindow.drop_chapterStart.Text);
- else if (mainWindow.drop_chapterStart.Text != "" && mainWindow.drop_chapterFinish.Text != "")
+ else if (mainWindow.drop_chapterStart.Text != string.Empty && mainWindow.drop_chapterFinish.Text != string.Empty)
query += string.Format(" -c {0}-{1}", mainWindow.drop_chapterStart.Text, mainWindow.drop_chapterFinish.Text);
break;
case 1: // Seconds
@@ -68,7 +79,7 @@ namespace Handbrake.Functions query += " --start-at-preview " + preview;
query += " --stop-at duration:" + duration + " ";
- if (mainWindow.text_destination.Text != "")
+ if (mainWindow.text_destination.Text != string.Empty)
query += string.Format(" -o \"{0}\" ", mainWindow.text_destination.Text.Replace(".m", "_sample.m"));
break;
default:
@@ -85,14 +96,14 @@ namespace Handbrake.Functions /// <summary>
/// Generates part of the CLI query, for the tabbed components only.
/// </summary>
- /// <param name="mainWindow"></param>
- /// <returns></returns>
+ /// <param name="mainWindow">frmMain the main window</param>
+ /// <returns>The CLI Query for the Tab Screens on the main window</returns>
public static string GenerateTabbedComponentsQuery(frmMain mainWindow)
{
- string query = "";
+ string query = string.Empty;
#region Output Settings Box
- query += " -f " + mainWindow.drop_format.Text.ToLower().Replace(" file", "");
+ query += " -f " + mainWindow.drop_format.Text.ToLower().Replace(" file", string.Empty);
// These are output settings features
if (mainWindow.check_largeFile.Checked)
@@ -125,7 +136,7 @@ namespace Handbrake.Functions if (mainWindow.PictureSettings.PresetMaximumResolution.Height == 0)
{
if (mainWindow.PictureSettings.text_height.Value != 0)
- if (mainWindow.PictureSettings.text_height.Text != "")
+ if (mainWindow.PictureSettings.text_height.Text != string.Empty)
if (mainWindow.PictureSettings.drp_anamorphic.SelectedIndex == 0 || mainWindow.PictureSettings.drp_anamorphic.SelectedIndex == 3) // Prevent usage for strict anamorphic
query += " -l " + mainWindow.PictureSettings.text_height.Text;
}
@@ -182,7 +193,7 @@ namespace Handbrake.Functions query += " --keep-display-aspect ";
if (!mainWindow.PictureSettings.check_KeepAR.Checked)
- if (mainWindow.PictureSettings.updownParWidth.Text != "" && mainWindow.PictureSettings.updownParHeight.Text != "")
+ if (mainWindow.PictureSettings.updownParWidth.Text != string.Empty && mainWindow.PictureSettings.updownParHeight.Text != string.Empty)
query += " --pixel-aspect " + mainWindow.PictureSettings.updownParWidth.Text + ":" + mainWindow.PictureSettings.updownParHeight.Text + " ";
break;
}
@@ -298,78 +309,87 @@ namespace Handbrake.Functions }
// Audio Track (-a)
- String audioItems = "";
- Boolean firstLoop = true;
+ string audioItems = string.Empty;
+ bool firstLoop = true;
- foreach (String item in tracks)
+ foreach (string item in tracks)
{
if (firstLoop)
{
- audioItems = item; firstLoop = false;
+ audioItems = item;
+ firstLoop = false;
}
else
audioItems += "," + item;
}
if (audioItems.Trim() != String.Empty)
query += " -a " + audioItems;
- firstLoop = true; audioItems = ""; // Reset for another pass.
+ firstLoop = true;
+ audioItems = string.Empty; // Reset for another pass.
// Audio Codec (-E)
- foreach (String item in codecs)
+ foreach (string item in codecs)
{
-
if (firstLoop)
{
- audioItems = item; firstLoop = false;
+ audioItems = item;
+ firstLoop = false;
}
else
audioItems += "," + item;
}
if (audioItems.Trim() != String.Empty)
query += " -E " + audioItems;
- firstLoop = true; audioItems = ""; // Reset for another pass.
+ firstLoop = true;
+ audioItems = string.Empty; // Reset for another pass.
// Audio Mixdown (-6)
- foreach (String item in mixdowns)
+ foreach (string item in mixdowns)
{
if (firstLoop)
{
- audioItems = item; firstLoop = false;
+ audioItems = item;
+ firstLoop = false;
}
else
audioItems += "," + item;
}
if (audioItems.Trim() != String.Empty)
query += " -6 " + audioItems;
- firstLoop = true; audioItems = ""; // Reset for another pass.
+ firstLoop = true;
+ audioItems = string.Empty; // Reset for another pass.
// Sample Rate (-R)
- foreach (String item in samplerates)
+ foreach (string item in samplerates)
{
if (firstLoop)
{
- audioItems = item; firstLoop = false;
+ audioItems = item;
+ firstLoop = false;
}
else
audioItems += "," + item;
}
if (audioItems.Trim() != String.Empty)
query += " -R " + audioItems;
- firstLoop = true; audioItems = ""; // Reset for another pass.
+ firstLoop = true;
+ audioItems = string.Empty; // Reset for another pass.
// Audio Bitrate (-B)
- foreach (String item in bitrates)
+ foreach (string item in bitrates)
{
if (firstLoop)
{
- audioItems = item; firstLoop = false;
+ audioItems = item;
+ firstLoop = false;
}
else
audioItems += "," + item;
}
if (audioItems.Trim() != String.Empty)
query += " -B " + audioItems;
- firstLoop = true; audioItems = ""; // Reset for another pass.
+ firstLoop = true;
+ audioItems = string.Empty; // Reset for another pass.
// DRC (-D)
foreach (var itm in drcs)
@@ -377,7 +397,8 @@ namespace Handbrake.Functions string item = itm.ToString(new CultureInfo("en-US"));
if (firstLoop)
{
- audioItems = item; firstLoop = false;
+ audioItems = item;
+ firstLoop = false;
}
else
audioItems += "," + item;
@@ -411,7 +432,7 @@ namespace Handbrake.Functions ? Path.Combine(Path.GetTempPath(), dest_name + "-" + sourceTitle + "-chapters.csv")
: Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");
- if (ChapterCSVSave(mainWindow, path) == false)
+ if (ChapterCsvSave(mainWindow, path) == false)
query += " -m ";
else
query += " --markers=" + "\"" + path + "\"";
@@ -467,8 +488,12 @@ namespace Handbrake.Functions /// <summary>
/// Get the CLI Audio Encoder name
/// </summary>
- /// <param name="selectedEncoder">string The GUI Encode name</param>
- /// <returns>string CLI encoder name</returns>
+ /// <param name="selectedEncoder">
+ /// String The GUI Encode name
+ /// </param>
+ /// <returns>
+ /// String CLI encoder name
+ /// </returns>
private static string GetAudioEncoder(string selectedEncoder)
{
switch (selectedEncoder)
@@ -484,7 +509,7 @@ namespace Handbrake.Functions case "DTS Passthru":
return "dts";
default:
- return "";
+ return string.Empty;
}
}
@@ -494,17 +519,17 @@ namespace Handbrake.Functions /// <param name="mainWindow">Main Window</param>
/// <param name="filePathName">Path to save the csv file</param>
/// <returns>True if successful </returns>
- private static Boolean ChapterCSVSave(frmMain mainWindow, string filePathName)
+ private static bool ChapterCsvSave(frmMain mainWindow, string filePathName)
{
try
{
- string csv = "";
+ string csv = string.Empty;
foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)
{
csv += row.Cells[0].Value.ToString();
csv += ",";
- csv += row.Cells[1].Value.ToString().Replace(",","\\,");
+ csv += row.Cells[1].Value.ToString().Replace(",", "\\,");
csv += Environment.NewLine;
}
StreamWriter file = new StreamWriter(filePathName);
diff --git a/win/C#/Functions/Scan.cs b/win/C#/Functions/Scan.cs index 8395eeb28..124f2309b 100644 --- a/win/C#/Functions/Scan.cs +++ b/win/C#/Functions/Scan.cs @@ -1,24 +1,41 @@ /* Scan.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. */
-
-using System;
-using System.Windows.Forms;
-using System.IO;
-using System.Diagnostics;
-using System.Threading;
-using Handbrake.Parsing;
+ 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.Functions
{
+ using System;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Threading;
+ using System.Windows.Forms;
+ using Parsing;
+
+ /// <summary>
+ /// Scan a Source
+ /// </summary>
public class Scan
{
- private DVD ThisDvd;
- private Parser ReadData;
- private Process HbProc;
- private string ScanProgress;
+ /// <summary>
+ /// The information for this source
+ /// </summary>
+ private DVD thisDvd;
+
+ /// <summary>
+ /// The CLI data parser
+ /// </summary>
+ private Parser readData;
+
+ /// <summary>
+ /// The Process belonging to the CLI
+ /// </summary>
+ private Process hbProc;
+
+ /// <summary>
+ /// The Progress of the scan
+ /// </summary>
+ private string scanProgress;
/// <summary>
/// Scan has Started
@@ -43,57 +60,57 @@ namespace Handbrake.Functions /// <param name="title">int title number. 0 for scan all</param>
public void ScanSource(string sourcePath, int title)
{
- Thread t = new Thread(unused => RunScan(sourcePath, title));
+ Thread t = new Thread(unused => this.RunScan(sourcePath, title));
t.Start();
}
/// <summary>
/// Object containing the information parsed in the scan.
/// </summary>
- /// <returns></returns>
+ /// <returns>The DVD object containing the scan information</returns>
public DVD SouceData()
{
- return ThisDvd;
+ return this.thisDvd;
}
/// <summary>
/// Raw log output from HandBrake CLI
/// </summary>
- /// <returns></returns>
- public String LogData()
+ /// <returns>The Log Data</returns>
+ public string LogData()
{
- return ReadData.Buffer;
+ return this.readData.Buffer;
}
/// <summary>
/// Progress of the scan.
/// </summary>
- /// <returns></returns>
- public String ScanStatus()
+ /// <returns>The progress of the scan</returns>
+ public string ScanStatus()
{
- return ScanProgress;
+ return this.scanProgress;
}
/// <summary>
/// The Scan Process
/// </summary>
- /// <returns></returns>
+ /// <returns>The CLI process</returns>
public Process ScanProcess()
{
- return HbProc;
+ return this.hbProc;
}
/// <summary>
/// Start a scan for a given source path and title
/// </summary>
- /// <param name="sourcePath"></param>
- /// <param name="title"></param>
+ /// <param name="sourcePath">Path to the source file</param>
+ /// <param name="title">the title number to look at</param>
private void RunScan(object sourcePath, int title)
{
try
{
- if (ScanStared != null)
- ScanStared(this, new EventArgs());
+ if (this.ScanStared != null)
+ this.ScanStared(this, new EventArgs());
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
@@ -103,36 +120,37 @@ namespace Handbrake.Functions if (File.Exists(dvdInfoPath))
File.Delete(dvdInfoPath);
- String dvdnav = string.Empty;
+ string dvdnav = string.Empty;
if (Properties.Settings.Default.noDvdNav)
dvdnav = " --no-dvdnav";
- HbProc = new Process
- {
- StartInfo =
- {
- FileName = handbrakeCLIPath,
- Arguments = String.Format(@" -i ""{0}"" -t{1} {2} -v ", sourcePath, title, dvdnav),
- RedirectStandardOutput = true,
- RedirectStandardError = true,
- UseShellExecute = false,
- CreateNoWindow = true
- }
- };
- HbProc.Start();
-
- ReadData = new Parser(HbProc.StandardError.BaseStream);
- ReadData.OnScanProgress += new ScanProgressEventHandler(OnScanProgress);
- ThisDvd = DVD.Parse(ReadData);
+ this.hbProc = new Process
+ {
+ StartInfo =
+ {
+ FileName = handbrakeCLIPath,
+ Arguments =
+ String.Format(@" -i ""{0}"" -t{1} {2} -v ", sourcePath, title, dvdnav),
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ UseShellExecute = false,
+ CreateNoWindow = true
+ }
+ };
+ this.hbProc.Start();
+
+ this.readData = new Parser(this.hbProc.StandardError.BaseStream);
+ this.readData.OnScanProgress += new ScanProgressEventHandler(this.OnScanProgress);
+ this.thisDvd = DVD.Parse(this.readData);
// Write the Buffer out to file.
StreamWriter scanLog = new StreamWriter(dvdInfoPath);
- scanLog.Write(ReadData.Buffer);
+ scanLog.Write(this.readData.Buffer);
scanLog.Flush();
scanLog.Close();
- if (ScanCompleted != null)
- ScanCompleted(this, new EventArgs());
+ if (this.ScanCompleted != null)
+ this.ScanCompleted(this, new EventArgs());
}
catch (Exception exc)
{
@@ -143,14 +161,14 @@ namespace Handbrake.Functions /// <summary>
/// Fire an event when the scan process progresses
/// </summary>
- /// <param name="sender"></param>
- /// <param name="currentTitle"></param>
- /// <param name="titleCount"></param>
+ /// <param name="sender">the sender</param>
+ /// <param name="currentTitle">the current title being scanned</param>
+ /// <param name="titleCount">the total number of titles</param>
private void OnScanProgress(object sender, int currentTitle, int titleCount)
{
- ScanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);
- if (ScanStatusChanged != null)
- ScanStatusChanged(this, new EventArgs());
+ this.scanProgress = string.Format("Processing Title: {0} of {1}", currentTitle, titleCount);
+ if (this.ScanStatusChanged != null)
+ this.ScanStatusChanged(this, new EventArgs());
}
}
}
\ No newline at end of file diff --git a/win/C#/Functions/System.cs b/win/C#/Functions/System.cs index 83882fe4c..1af1170a2 100644 --- a/win/C#/Functions/System.cs +++ b/win/C#/Functions/System.cs @@ -1,21 +1,22 @@ /* System.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. */
-
-using System;
-using System.Windows.Forms;
-using Microsoft.Win32;
+ 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.Functions
{
- class SystemInfo
+ using System.Windows.Forms;
+ using Microsoft.Win32;
+
+ /// <summary>
+ /// The System Information.
+ /// </summary>
+ public class SystemInfo
{
/// <summary>
- /// Returns the total physical ram in a system
+ /// Gets the total physical ram in a system
/// </summary>
- /// <returns></returns>
+ /// <returns>The total memory in the system</returns>
public static uint TotalPhysicalMemory
{
get
@@ -24,17 +25,17 @@ namespace Handbrake.Functions Win32.GlobalMemoryStatus(ref memStatus);
uint memoryInfo = memStatus.dwTotalPhys;
- memoryInfo = memoryInfo/1024/1024;
+ memoryInfo = memoryInfo / 1024 / 1024;
return memoryInfo;
}
}
/// <summary>
- /// Get the number of CPU Cores
+ /// Gets the number of CPU Cores
/// </summary>
/// <returns>Object</returns>
- public static Object GetCpuCount
+ public static object GetCpuCount
{
get
{
@@ -45,7 +46,7 @@ namespace Handbrake.Functions }
/// <summary>
- /// Get the System screen size information.
+ /// Gets the System screen size information.
/// </summary>
/// <returns>System.Windows.Forms.Scree</returns>
public static Screen ScreenBounds
diff --git a/win/C#/Functions/UpdateCheckInformation.cs b/win/C#/Functions/UpdateCheckInformation.cs index c157f8a68..b3ed02b88 100644 --- a/win/C#/Functions/UpdateCheckInformation.cs +++ b/win/C#/Functions/UpdateCheckInformation.cs @@ -1,23 +1,38 @@ -using System;
-using System.Threading;
+/* UpdateCheckInformation.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. */
namespace Handbrake.Functions
{
+ using System;
+ using System.Threading;
+
/// <summary>
/// Provides information about an update check.
/// </summary>
public struct UpdateCheckInformation
{
+ /// <summary>
+ /// Gets or sets a value indicating whether a New Version is Available.
+ /// </summary>
public bool NewVersionAvailable { get; set; }
- public bool ErrorOccured { get { return Error != null; } }
/// <summary>
- /// Gets information about the new build, if any. This will be null if there is no new verison.
+ /// Gets a value indicating whether an Error Occured.
+ /// </summary>
+ public bool ErrorOccured
+ {
+ get { return this.Error != null; }
+ }
+
+ /// <summary>
+ /// Gets or sets information about the new build, if any. This will be null if there is no new verison.
/// </summary>
public AppcastReader BuildInformation { get; set; }
/// <summary>
- /// Gets the error that occurred, if any. This will be null if no error occured.
+ /// Gets or sets the error that occurred, if any. This will be null if no error occured.
/// </summary>
public Exception Error { get; set; }
}
@@ -27,10 +42,19 @@ namespace Handbrake.Functions /// </summary>
public class UpdateCheckResult : IAsyncResult
{
+ /// <summary>
+ /// Initializes a new instance of the <see cref="UpdateCheckResult"/> class.
+ /// </summary>
+ /// <param name="asyncState">
+ /// The async state.
+ /// </param>
+ /// <param name="info">
+ /// The info.
+ /// </param>
public UpdateCheckResult(object asyncState, UpdateCheckInformation info)
{
- AsyncState = asyncState;
- Result = info;
+ this.AsyncState = asyncState;
+ this.Result = info;
}
/// <summary>
@@ -43,8 +67,34 @@ namespace Handbrake.Functions /// </summary>
public UpdateCheckInformation Result { get; private set; }
- public WaitHandle AsyncWaitHandle { get { throw new NotImplementedException(); } }
- public bool CompletedSynchronously { get { throw new NotImplementedException(); } }
- public bool IsCompleted { get { throw new NotImplementedException(); } }
+ /// <summary>
+ /// Gets AsyncWaitHandle.
+ /// </summary>
+ /// <exception cref="NotImplementedException">
+ /// </exception>
+ public WaitHandle AsyncWaitHandle
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether CompletedSynchronously.
+ /// </summary>
+ /// <exception cref="NotImplementedException">
+ /// </exception>
+ public bool CompletedSynchronously
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ /// <summary>
+ /// Gets a value indicating whether IsCompleted.
+ /// </summary>
+ /// <exception cref="NotImplementedException">
+ /// </exception>
+ public bool IsCompleted
+ {
+ get { throw new NotImplementedException(); }
+ }
}
}
diff --git a/win/C#/Functions/Win32.cs b/win/C#/Functions/Win32.cs index b624a8342..b5ca77c06 100644 --- a/win/C#/Functions/Win32.cs +++ b/win/C#/Functions/Win32.cs @@ -1,26 +1,55 @@ /* win32.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. */
-using System;
-using System.Runtime.InteropServices;
-
namespace Handbrake.Functions
{
- class Win32
+ using System;
+ using System.Runtime.InteropServices;
+
+ /// <summary>
+ /// Win32 API calls
+ /// </summary>
+ public class Win32
{
+ /// <summary>
+ /// Set the Forground Window
+ /// </summary>
+ /// <param name="hWnd">
+ /// The h wnd.
+ /// </param>
+ /// <returns>
+ /// A Boolean true when complete.
+ /// </returns>
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(int hWnd);
+ /// <summary>
+ /// Lock the workstation
+ /// </summary>
[DllImport("user32.dll")]
public static extern void LockWorkStation();
+ /// <summary>
+ /// Exit Windows
+ /// </summary>
+ /// <param name="uFlags">
+ /// The u flags.
+ /// </param>
+ /// <param name="dwReason">
+ /// The dw reason.
+ /// </param>
+ /// <returns>
+ /// an integer
+ /// </returns>
[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
+ /// <summary>
+ /// System Memory Status
+ /// </summary>
public struct MEMORYSTATUS // Unused var's are required here.
{
public UInt32 dwLength;
@@ -33,6 +62,12 @@ namespace Handbrake.Functions public UInt32 dwAvailVirtual;
}
+ /// <summary>
+ /// Global Memory Status
+ /// </summary>
+ /// <param name="lpBuffer">
+ /// The lp buffer.
+ /// </param>
[DllImport("kernel32.dll")]
public static extern void GlobalMemoryStatus
(
@@ -42,6 +77,9 @@ namespace Handbrake.Functions [DllImport("kernel32.dll", SetLastError = true)]
public static extern bool GenerateConsoleCtrlEvent(ConsoleCtrlEvent sigevent, int dwProcessGroupId);
+ /// <summary>
+ /// Console Ctrl Event
+ /// </summary>
public enum ConsoleCtrlEvent
{
CTRL_C = 0,
diff --git a/win/C#/HandBrakeCS.5.0.ReSharper b/win/C#/HandBrakeCS.5.0.ReSharper new file mode 100644 index 000000000..8565476d6 --- /dev/null +++ b/win/C#/HandBrakeCS.5.0.ReSharper @@ -0,0 +1,109 @@ +<Configuration>
+ <CodeStyleSettings>
+ <ExternalPath IsNull="False">
+ </ExternalPath>
+ <Sharing>SOLUTION</Sharing>
+ <CSharp>
+ <FormatSettings>
+ <MODIFIERS_ORDER IsNull="False">
+ <Item>public</Item>
+ <Item>protected</Item>
+ <Item>internal</Item>
+ <Item>private</Item>
+ <Item>new</Item>
+ <Item>abstract</Item>
+ <Item>virtual</Item>
+ <Item>override</Item>
+ <Item>sealed</Item>
+ <Item>static</Item>
+ <Item>readonly</Item>
+ <Item>extern</Item>
+ <Item>unsafe</Item>
+ <Item>volatile</Item>
+ </MODIFIERS_ORDER>
+ </FormatSettings>
+ <UsingsSettings>
+ <AddImportsToDeepestScope>True</AddImportsToDeepestScope>
+ </UsingsSettings>
+ <Naming2>
+ <EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
+ <EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
+ <PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
+ <PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
+ <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
+ <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
+ </Naming2>
+ </CSharp>
+ <VB>
+ <FormatSettings />
+ <ImportsSettings />
+ <Naming2>
+ <EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
+ <EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
+ <PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
+ <PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
+ <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
+ <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
+ </Naming2>
+ </VB>
+ <Web>
+ <Naming2 />
+ </Web>
+ <Xaml>
+ <Naming2 />
+ </Xaml>
+ <XML>
+ <FormatSettings />
+ </XML>
+ <FileHeader><![CDATA[/* file.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. */]]></FileHeader>
+ <GenerateMemberBody />
+ <Naming2>
+ <EventHandlerPatternLong>$object$_On$event$</EventHandlerPatternLong>
+ <EventHandlerPatternShort>$event$Handler</EventHandlerPatternShort>
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
+ <PredefinedRule Inspect="True" Prefix="I" Suffix="" Style="AaBb" ElementKind="Interfaces" />
+ <PredefinedRule Inspect="True" Prefix="T" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PublicFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Constants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="StaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
+ <Abbreviation Text="CLI" />
+ </Naming2>
+ </CodeStyleSettings>
+</Configuration>
\ No newline at end of file diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index fd71c1161..8f02ff8fe 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -427,4 +427,5 @@ <Target Name="AfterBuild">
</Target>
-->
+ <Import Project="$(ProgramFiles)\MSBuild\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" />
</Project>
\ No newline at end of file diff --git a/win/C#/HandBrakeCS.csproj.ReSharper b/win/C#/HandBrakeCS.csproj.ReSharper new file mode 100644 index 000000000..9b0507870 --- /dev/null +++ b/win/C#/HandBrakeCS.csproj.ReSharper @@ -0,0 +1,3 @@ +<Configuration>
+ <Localizable>No</Localizable>
+</Configuration>
\ No newline at end of file diff --git a/win/C#/Settings.StyleCop b/win/C#/Settings.StyleCop new file mode 100644 index 000000000..e6b8a0684 --- /dev/null +++ b/win/C#/Settings.StyleCop @@ -0,0 +1,130 @@ +<StyleCopSettings Version="4.3">
+ <GlobalSettings>
+ <StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
+ </GlobalSettings>
+ <Analyzers>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
+ <Rules>
+ <Rule Name="FileHeaderMustShowCopyright">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="FileHeaderMustHaveCopyrightText">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="FileHeaderMustContainFileName">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="FileHeaderFileNameDocumentationMustMatchFileName">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="FileHeaderMustHaveValidCompanyText">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="FileMustHaveHeader">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="PropertyDocumentationMustHaveValueText">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">True</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="DocumentationTextMustMeetMinimumCharacterLength">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings>
+ <StringProperty Name="CompanyName">HandBrake Project</StringProperty>
+ <StringProperty Name="Copyright">Copyright 2010 HandBrake Team - It may be used under the terms of the GNU General Public License.</StringProperty>
+ </AnalyzerSettings>
+ </Analyzer>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.MaintainabilityRules">
+ <Rules>
+ <Rule Name="StatementMustNotUseUnnecessaryParenthesis">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.SpacingRules">
+ <Rules>
+ <Rule Name="OpeningCurlyBracketsMustBeSpacedCorrectly">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="ClosingCurlyBracketsMustBeSpacedCorrectly">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.LayoutRules">
+ <Rules>
+ <Rule Name="SingleLineCommentsMustNotBeFollowedByBlankLine">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="SingleLineCommentMustBePrecededByBlankLine">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="ClosingCurlyBracketMustBeFollowedByBlankLine">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="CurlyBracketsMustNotBeOmitted">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
+ <Rules>
+ <Rule Name="BlockStatementsMustNotContainEmbeddedComments">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="DoNotPlaceRegionsWithinElements">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ <Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules">
+ <Rules>
+ <Rule Name="FieldNamesMustNotUseHungarianNotation">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ </Rules>
+ <AnalyzerSettings />
+ </Analyzer>
+ </Analyzers>
+</StyleCopSettings>
\ No newline at end of file |