summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
authorsr55 <[email protected]>2011-03-27 20:08:33 +0000
committersr55 <[email protected]>2011-03-27 20:08:33 +0000
commitabd251048b392e86041325c1561e7a9dcd8067c3 (patch)
tree6f18df3389db6994e5f454e423880f73c7a5e8d6 /win/CS/HandBrake.ApplicationServices
parent5b0977cc04f8d6471905f4090c7f18e6240988da (diff)
WinGui:
- Some move re factoring to push the logic code into the service library. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3885 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Extensions/StringExtensions.cs34
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj13
-rw-r--r--win/CS/HandBrake.ApplicationServices/Parsing/Title.cs20
-rw-r--r--win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs26
-rw-r--r--win/CS/HandBrake.ApplicationServices/Properties/Settings.settings6
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/Encode.cs4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Services/ScanService.cs4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs (renamed from win/CS/HandBrake.ApplicationServices/Utilities/UtilityService.cs)3
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs210
9 files changed, 314 insertions, 6 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Extensions/StringExtensions.cs b/win/CS/HandBrake.ApplicationServices/Extensions/StringExtensions.cs
new file mode 100644
index 000000000..42f40c13b
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Extensions/StringExtensions.cs
@@ -0,0 +1,34 @@
+/* StringExtensions.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.ApplicationServices.Extensions
+{
+ using System.Text;
+
+ public static class StringExtensions
+ {
+ /// <summary>
+ /// Change the input string to title case
+ /// </summary>
+ /// <param name="input">the input string</param>
+ /// <returns>the input string in title case</returns>
+ public static string ToTitleCase(this string input)
+ {
+ string[] tokens = input.Split(' ');
+ StringBuilder sb = new StringBuilder(input.Length);
+ foreach (string s in tokens)
+ {
+ if (!string.IsNullOrEmpty(s))
+ {
+ sb.Append(s[0].ToString().ToUpper());
+ sb.Append(s.Substring(1).ToLower());
+ sb.Append(" ");
+ }
+ }
+
+ return sb.ToString().Trim();
+ }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 14dd50094..4edad2011 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -88,6 +88,7 @@
<Compile Include="EventArgs\QueueProgressEventArgs.cs" />
<Compile Include="EventArgs\ScanCompletedEventArgs.cs" />
<Compile Include="EventArgs\ScanProgressEventArgs.cs" />
+ <Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Functions\Converters.cs" />
<Compile Include="Functions\EnumHelper.cs" />
<Compile Include="Functions\GrowlCommunicator.cs" />
@@ -130,6 +131,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ <DependentUpon>Settings.settings</DependentUpon>
+ </Compile>
<Compile Include="Services\Encode.cs" />
<Compile Include="Services\Interfaces\IEncode.cs" />
<Compile Include="Services\Interfaces\IQueueManager.cs" />
@@ -143,10 +149,11 @@
<Compile Include="Services\ScanService.cs" />
<Compile Include="Services\UpdateService.cs" />
<Compile Include="Utilities\AppcastReader.cs" />
+ <Compile Include="Utilities\GeneralUtilities.cs" />
+ <Compile Include="Utilities\LanguageUtilities.cs" />
<Compile Include="Utilities\PlistUtility.cs" />
<Compile Include="Utilities\QueryGeneratorUtility.cs" />
<Compile Include="Utilities\QueryParserUtility.cs" />
- <Compile Include="Utilities\UtilityService.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -161,6 +168,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
<None Include="Resources\logo64.png" />
</ItemGroup>
<ItemGroup />
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
index 3a9e6a56a..7f4bf9b78 100644
--- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
+++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs
@@ -223,6 +223,26 @@ namespace HandBrake.ApplicationServices.Parsing
}
/// <summary>
+ /// Calcuate the Duration
+ /// </summary>
+ /// <param name="startPoint">The Start Point (Chapters)</param>
+ /// <param name="endPoint">The End Point (Chapters)</param>
+ /// <returns>A Timespan</returns>
+ public TimeSpan CalculateDuration(int startPoint, int endPoint)
+ {
+ TimeSpan duration = TimeSpan.FromSeconds(0.0);
+ startPoint++;
+ endPoint++;
+ if (startPoint != 0 && endPoint != 0 && endPoint <= this.Chapters.Count)
+ {
+ for (int i = startPoint; i <= endPoint; i++)
+ duration += this.Chapters[i - 1].Duration;
+ }
+
+ return duration;
+ }
+
+ /// <summary>
/// Override of the ToString method to provide an easy way to use this object in the UI
/// </summary>
/// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>
diff --git a/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs b/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs
new file mode 100644
index 000000000..dab4d168f
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.1
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace HandBrake.ApplicationServices.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings b/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings
new file mode 100644
index 000000000..15034e76c
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Properties/Settings.settings
@@ -0,0 +1,6 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+</SettingsFile>
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
index c7a00dda5..d64a4479e 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/Encode.cs
@@ -60,7 +60,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// The Log File Header
/// </summary>
- StringBuilder header = UtilityService.CreateCliLogHeader(null);
+ StringBuilder header = GeneralUtilities.CreateCliLogHeader(null);
#endregion
@@ -410,7 +410,7 @@ namespace HandBrake.ApplicationServices.Services
if (File.Exists(logFile2)) File.Delete(logFile2);
fileWriter = new StreamWriter(logFile) { AutoFlush = true };
- fileWriter.WriteLine(UtilityService.CreateCliLogHeader(encodeQueueTask));
+ fileWriter.WriteLine(GeneralUtilities.CreateCliLogHeader(encodeQueueTask));
}
catch (Exception)
{
diff --git a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
index 091b4478c..38dddd2d6 100644
--- a/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Services/ScanService.cs
@@ -42,7 +42,7 @@ namespace HandBrake.ApplicationServices.Services
/// <summary>
/// The Log File Header
/// </summary>
- StringBuilder header = UtilityService.CreateCliLogHeader(null);
+ StringBuilder header = GeneralUtilities.CreateCliLogHeader(null);
#endregion
@@ -223,7 +223,7 @@ namespace HandBrake.ApplicationServices.Services
// Only write the log file to disk if it's less than 100MB.
if (this.readData.Buffer.Length < 100000000)
{
- scanLog.WriteLine(UtilityService.CreateCliLogHeader(null));
+ scanLog.WriteLine(GeneralUtilities.CreateCliLogHeader(null));
scanLog.Write(this.readData.Buffer);
logBuffer.AppendLine(this.readData.Buffer.ToString());
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/UtilityService.cs b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
index 948567138..3f56213e8 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/UtilityService.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/GeneralUtilities.cs
@@ -18,7 +18,7 @@ namespace HandBrake.ApplicationServices.Utilities
/// <summary>
/// A Set of Static Utilites
/// </summary>
- public class UtilityService
+ public class GeneralUtilities
{
/// <summary>
/// The Default Log Directory
@@ -139,5 +139,6 @@ namespace HandBrake.ApplicationServices.Utilities
{
return string.Format("[{0}] {1}", DateTime.Now.TimeOfDay, message);
}
+
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs
new file mode 100644
index 000000000..d879afd27
--- /dev/null
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs
@@ -0,0 +1,210 @@
+/* LanguageUtilities.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.Collections.Generic;
+
+namespace HandBrake.ApplicationServices.Utilities
+{
+ public class LanguageUtilities
+ {
+ /// <summary>
+ /// Map languages and their iso639_2 value into a IDictionary
+ /// </summary>
+ /// <returns>A Dictionary containing the language and iso code</returns>
+ public static IDictionary<string, string> MapLanguages()
+ {
+ IDictionary<string, string> languageMap = new Dictionary<string, string>
+ {
+ {"Any", "und"},
+ {"Afar", "aar"},
+ {"Abkhazian", "abk"},
+ {"Afrikaans", "afr"},
+ {"Akan", "aka"},
+ {"Albanian", "sqi"},
+ {"Amharic", "amh"},
+ {"Arabic", "ara"},
+ {"Aragonese", "arg"},
+ {"Armenian", "hye"},
+ {"Assamese", "asm"},
+ {"Avaric", "ava"},
+ {"Avestan", "ave"},
+ {"Aymara", "aym"},
+ {"Azerbaijani", "aze"},
+ {"Bashkir", "bak"},
+ {"Bambara", "bam"},
+ {"Basque", "eus"},
+ {"Belarusian", "bel"},
+ {"Bengali", "ben"},
+ {"Bihari", "bih"},
+ {"Bislama", "bis"},
+ {"Bosnian", "bos"},
+ {"Breton", "bre"},
+ {"Bulgarian", "bul"},
+ {"Burmese", "mya"},
+ {"Catalan", "cat"},
+ {"Chamorro", "cha"},
+ {"Chechen", "che"},
+ {"Chinese", "zho"},
+ {"Church Slavic", "chu"},
+ {"Chuvash", "chv"},
+ {"Cornish", "cor"},
+ {"Corsican", "cos"},
+ {"Cree", "cre"},
+ {"Czech", "ces"},
+ {"Dansk", "dan"},
+ {"Divehi", "div"},
+ {"Nederlands", "nld"},
+ {"Dzongkha", "dzo"},
+ {"English", "eng"},
+ {"Esperanto", "epo"},
+ {"Estonian", "est"},
+ {"Ewe", "ewe"},
+ {"Faroese", "fao"},
+ {"Fijian", "fij"},
+ {"Suomi", "fin"},
+ {"Francais", "fra"},
+ {"Western Frisian", "fry"},
+ {"Fulah", "ful"},
+ {"Georgian", "kat"},
+ {"Deutsch", "deu"},
+ {"Gaelic (Scots)", "gla"},
+ {"Irish", "gle"},
+ {"Galician", "glg"},
+ {"Manx", "glv"},
+ {"Greek Modern", "ell"},
+ {"Guarani", "grn"},
+ {"Gujarati", "guj"},
+ {"Haitian", "hat"},
+ {"Hausa", "hau"},
+ {"Hebrew", "heb"},
+ {"Herero", "her"},
+ {"Hindi", "hin"},
+ {"Hiri Motu", "hmo"},
+ {"Magyar", "hun"},
+ {"Igbo", "ibo"},
+ {"Islenska", "isl"},
+ {"Ido", "ido"},
+ {"Sichuan Yi", "iii"},
+ {"Inuktitut", "iku"},
+ {"Interlingue", "ile"},
+ {"Interlingua", "ina"},
+ {"Indonesian", "ind"},
+ {"Inupiaq", "ipk"},
+ {"Italiano", "ita"},
+ {"Javanese", "jav"},
+ {"Japanese", "jpn"},
+ {"Kalaallisut", "kal"},
+ {"Kannada", "kan"},
+ {"Kashmiri", "kas"},
+ {"Kanuri", "kau"},
+ {"Kazakh", "kaz"},
+ {"Central Khmer", "khm"},
+ {"Kikuyu", "kik"},
+ {"Kinyarwanda", "kin"},
+ {"Kirghiz", "kir"},
+ {"Komi", "kom"},
+ {"Kongo", "kon"},
+ {"Korean", "kor"},
+ {"Kuanyama", "kua"},
+ {"Kurdish", "kur"},
+ {"Lao", "lao"},
+ {"Latin", "lat"},
+ {"Latvian", "lav"},
+ {"Limburgan", "lim"},
+ {"Lingala", "lin"},
+ {"Lithuanian", "lit"},
+ {"Luxembourgish", "ltz"},
+ {"Luba-Katanga", "lub"},
+ {"Ganda", "lug"},
+ {"Macedonian", "mkd"},
+ {"Marshallese", "mah"},
+ {"Malayalam", "mal"},
+ {"Maori", "mri"},
+ {"Marathi", "mar"},
+ {"Malay", "msa"},
+ {"Malagasy", "mlg"},
+ {"Maltese", "mlt"},
+ {"Moldavian", "mol"},
+ {"Mongolian", "mon"},
+ {"Nauru", "nau"},
+ {"Navajo", "nav"},
+ {"Ndebele, South", "nbl"},
+ {"Ndebele, North", "nde"},
+ {"Ndonga", "ndo"},
+ {"Nepali", "nep"},
+ {"Norwegian Nynorsk", "nno"},
+ {"Norwegian Bokmål", "nob"},
+ {"Norsk", "nor"},
+ {"Chichewa; Nyanja", "nya"},
+ {"Occitan", "oci"},
+ {"Ojibwa", "oji"},
+ {"Oriya", "ori"},
+ {"Oromo", "orm"},
+ {"Ossetian", "oss"},
+ {"Panjabi", "pan"},
+ {"Persian", "fas"},
+ {"Pali", "pli"},
+ {"Polish", "pol"},
+ {"Portugues", "por"},
+ {"Pushto", "pus"},
+ {"Quechua", "que"},
+ {"Romansh", "roh"},
+ {"Romanian", "ron"},
+ {"Rundi", "run"},
+ {"Russian", "rus"},
+ {"Sango", "sag"},
+ {"Sanskrit", "san"},
+ {"Serbian", "srp"},
+ {"Hrvatski", "hrv"},
+ {"Sinhala", "sin"},
+ {"Slovak", "slk"},
+ {"Slovenian", "slv"},
+ {"Northern Sami", "sme"},
+ {"Samoan", "smo"},
+ {"Shona", "sna"},
+ {"Sindhi", "snd"},
+ {"Somali", "som"},
+ {"Sotho Southern", "sot"},
+ {"Espanol", "spa"},
+ {"Sardinian", "srd"},
+ {"Swati", "ssw"},
+ {"Sundanese", "sun"},
+ {"Swahili", "swa"},
+ {"Svenska", "swe"},
+ {"Tahitian", "tah"},
+ {"Tamil", "tam"},
+ {"Tatar", "tat"},
+ {"Telugu", "tel"},
+ {"Tajik", "tgk"},
+ {"Tagalog", "tgl"},
+ {"Thai", "tha"},
+ {"Tibetan", "bod"},
+ {"Tigrinya", "tir"},
+ {"Tonga", "ton"},
+ {"Tswana", "tsn"},
+ {"Tsonga", "tso"},
+ {"Turkmen", "tuk"},
+ {"Turkish", "tur"},
+ {"Twi", "twi"},
+ {"Uighur", "uig"},
+ {"Ukrainian", "ukr"},
+ {"Urdu", "urd"},
+ {"Uzbek", "uzb"},
+ {"Venda", "ven"},
+ {"Vietnamese", "vie"},
+ {"Volapük", "vol"},
+ {"Welsh", "cym"},
+ {"Walloon", "wln"},
+ {"Wolof", "wol"},
+ {"Xhosa", "xho"},
+ {"Yiddish", "yid"},
+ {"Yoruba", "yor"},
+ {"Zhuang", "zha"},
+ {"Zulu", "zul"}
+ };
+ return languageMap;
+ }
+ }
+}