summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices
diff options
context:
space:
mode:
authorsr55 <[email protected]>2014-11-29 17:59:31 +0000
committersr55 <[email protected]>2014-11-29 17:59:31 +0000
commit7c0af498a9d5f7aae1e5c8d06b939c8189edcfbe (patch)
tree74d348fb0cd83d48d13d4ae1007909e032a5a807 /win/CS/HandBrake.ApplicationServices
parentd364449a2ec863db317422645d5c7a927d294654 (diff)
WinGui: Re-factoring the services library.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6567 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs126
-rw-r--r--win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj4
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/AppcastReader.cs123
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PList.cs155
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs2
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/Win7.cs80
6 files changed, 0 insertions, 490 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs b/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs
deleted file mode 100644
index 15ac8a7c0..000000000
--- a/win/CS/HandBrake.ApplicationServices/Collections/SerializableDictionary.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="SerializableDictionary.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A Serializable Dictionary
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Collections
-{
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Xml.Serialization;
-
- /// <summary>
- /// A Serializable Dictionary
- /// </summary>
- /// <typeparam name="TKey">
- /// The Key Type
- /// </typeparam>
- /// <typeparam name="TValue">
- /// The Value Type
- /// </typeparam>
- [XmlRoot("dictionary")]
- public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IXmlSerializable
- {
- #region IXmlSerializable Members
-
- /// <summary>
- /// Get the Schema
- /// </summary>
- /// <returns>
- /// Nothing. We don't use this.
- /// </returns>
- public System.Xml.Schema.XmlSchema GetSchema()
- {
- return null;
- }
-
- /// <summary>
- /// Deserialize some XML into a dictionary
- /// </summary>
- /// <param name="reader">
- /// The reader.
- /// </param>
- public void ReadXml(System.Xml.XmlReader reader)
- {
- XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));
- XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));
-
- bool wasEmpty = reader.IsEmptyElement;
- reader.Read();
-
- if (wasEmpty)
- return;
-
- while (reader.NodeType != System.Xml.XmlNodeType.EndElement)
- {
- reader.ReadStartElement("item");
-
- reader.ReadStartElement("key");
- TKey key = (TKey)keySerializer.Deserialize(reader);
- reader.ReadEndElement();
-
- reader.ReadStartElement("value");
- TValue value;
- if (reader.Name.Contains("ArrayOfString"))
- {
- XmlSerializer scSerializer = new XmlSerializer(typeof(StringCollection));
- value = (TValue)scSerializer.Deserialize(reader);
- }
- else
- {
- value = (TValue)valueSerializer.Deserialize(reader);
- }
- reader.ReadEndElement();
-
- this.Add(key, value);
-
- reader.ReadEndElement();
- reader.MoveToContent();
- }
- reader.ReadEndElement();
- }
-
- /// <summary>
- /// Write the Dictionary out to XML
- /// </summary>
- /// <param name="writer">
- /// The writer.
- /// </param>
- public void WriteXml(System.Xml.XmlWriter writer)
- {
- XmlSerializer keySerializer = new XmlSerializer(typeof(TKey));
- XmlSerializer valueSerializer = new XmlSerializer(typeof(TValue));
-
- foreach (TKey key in this.Keys)
- {
- writer.WriteStartElement("item");
-
- writer.WriteStartElement("key");
- keySerializer.Serialize(writer, key);
- writer.WriteEndElement();
-
- writer.WriteStartElement("value");
- TValue value = this[key];
-
- if (value.GetType() == typeof(StringCollection))
- {
- XmlSerializer scSerializer = new XmlSerializer(typeof(StringCollection));
- scSerializer.Serialize(writer, value);
- writer.WriteEndElement();
- }
- else
- {
- valueSerializer.Serialize(writer, value);
- writer.WriteEndElement();
- }
-
- writer.WriteEndElement();
- }
- }
- #endregion
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
index 8d86c4e57..d3d229d67 100644
--- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
+++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj
@@ -97,7 +97,6 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Collections\SerializableDictionary.cs" />
<Compile Include="Converters\EnumToDescConverter.cs" />
<Compile Include="EventArgs\QueueCompletedEventArgs.cs" />
<Compile Include="EventArgs\SettingChangedEventArgs.cs" />
@@ -125,11 +124,9 @@
<Compile Include="Utilities\Converters.cs" />
<Compile Include="Utilities\EnumHelper.cs" />
<Compile Include="Utilities\InteropModelCreator.cs" />
- <Compile Include="Utilities\PList.cs" />
<Compile Include="Utilities\SystemInfo.cs" />
<Compile Include="Utilities\VersionHelper.cs" />
<Compile Include="Utilities\Win32.cs" />
- <Compile Include="Utilities\Win7.cs" />
<Compile Include="Model\DriveInformation.cs" />
<Compile Include="Model\Encoding\AllowedPassthru.cs" />
<Compile Include="Model\Encoding\AudioTrack.cs" />
@@ -162,7 +159,6 @@
<Compile Include="Services\LibEncode.cs" />
<Compile Include="Services\LibScan.cs" />
<Compile Include="Services\QueueProcessor.cs" />
- <Compile Include="Utilities\AppcastReader.cs" />
<Compile Include="Utilities\CharCodesUtilities.cs" />
<Compile Include="Utilities\GeneralUtilities.cs" />
<Compile Include="Utilities\LanguageUtilities.cs" />
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/AppcastReader.cs b/win/CS/HandBrake.ApplicationServices/Utilities/AppcastReader.cs
deleted file mode 100644
index 0a3fac109..000000000
--- a/win/CS/HandBrake.ApplicationServices/Utilities/AppcastReader.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="AppcastReader.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Appcast Reader - Used for parsing HandBrakes update file
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- 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 GetUpdateInfo(string input)
- {
- try
- {
- // Get the correct Appcast and set 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]*))\""");
-
- 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;
- }
- }
-
- /// <summary>
- /// Read the RSS file.
- /// </summary>
- /// <param name="rssReader">
- /// The RSS reader
- /// </param>
- /// <returns>
- /// The read rss.
- /// </returns>
- private static XmlNode ReadRss(XmlReader rssReader)
- {
- XmlNode nodeItem = null;
- XmlNode nodeChannel = null;
- XmlNode nodeRss = null;
-
- XmlDocument rssDoc = new XmlDocument();
- rssDoc.Load(rssReader);
-
- 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;
- }
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PList.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PList.cs
deleted file mode 100644
index 78320f1fe..000000000
--- a/win/CS/HandBrake.ApplicationServices/Utilities/PList.cs
+++ /dev/null
@@ -1,155 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="PList.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A Helper class to parse plist files.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Xml.Linq;
-
- /// <summary>
- /// A Helper class to parse plist files.
- /// </summary>
- public class PList : Dictionary<string, dynamic>
- {
- #region Constructors and Destructors
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PList"/> class.
- /// </summary>
- public PList()
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="PList"/> class.
- /// </summary>
- /// <param name="file">
- /// The file.
- /// </param>
- public PList(string file)
- {
- this.Load(file);
- }
-
- #endregion
-
- #region Public Methods
-
- /// <summary>
- /// Load a plist file.
- /// </summary>
- /// <param name="file">
- /// The file name / path
- /// </param>
- /// <returns>
- /// True if successful, false otherwise.
- /// </returns>
- public bool Load(string file)
- {
- this.Clear();
-
- XDocument doc = XDocument.Load(file);
- XElement plist = doc.Element("plist");
- if (plist != null)
- {
- XElement array = plist.Element("array");
- if (array != null)
- {
- XElement dict = array.Element("dict");
-
- if (dict != null)
- {
- IEnumerable<XElement> dictElements = dict.Elements();
- this.Parse(this, dictElements);
- return true;
- }
- }
- }
-
- return false;
- }
-
- #endregion
-
- #region Methods
-
- /// <summary>
- /// Parse a list of elements
- /// </summary>
- /// <param name="dict">
- /// The dict.
- /// </param>
- /// <param name="elements">
- /// The elements.
- /// </param>
- private void Parse(PList dict, IEnumerable<XElement> elements)
- {
- for (int i = 0; i < elements.Count(); i += 2)
- {
- XElement key = elements.ElementAt(i);
- XElement val = elements.ElementAt(i + 1);
-
- dict[key.Value] = this.ParseValue(val);
- }
- }
-
- /// <summary>
- /// The parse array.
- /// </summary>
- /// <param name="elements">
- /// The elements.
- /// </param>
- /// <returns>
- /// The <see cref="List"/>.
- /// </returns>
- private List<dynamic> ParseArray(IEnumerable<XElement> elements)
- {
- return elements.Select(e => this.ParseValue(e)).ToList();
- }
-
- /// <summary>
- /// The parse value.
- /// </summary>
- /// <param name="val">
- /// The XElement.
- /// </param>
- /// <returns>
- /// The parsed value object.
- /// </returns>
- private dynamic ParseValue(XElement val)
- {
- switch (val.Name.ToString())
- {
- case "string":
- return val.Value;
- case "integer":
- return int.Parse(val.Value);
- case "real":
- return float.Parse(val.Value);
- case "true":
- return true;
- case "false":
- return false;
- case "dict":
- var plist = new PList();
- this.Parse(plist, val.Elements());
- return plist;
- case "array":
- List<dynamic> list = this.ParseArray(val.Elements());
- return list;
- default:
- throw new ArgumentException("This plist file is not supported.");
- }
- }
-
- #endregion
- }
-} \ No newline at end of file
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs b/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs
index f7e0ae0ed..df1211528 100644
--- a/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs
+++ b/win/CS/HandBrake.ApplicationServices/Utilities/SystemInfo.cs
@@ -11,10 +11,8 @@ namespace HandBrake.ApplicationServices.Utilities
{
using System;
using System.Collections.Generic;
- using System.Globalization;
using System.Management;
using System.Text.RegularExpressions;
- using System.Windows.Documents;
using System.Windows.Forms;
using HandBrake.Interop.HbLib;
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/Win7.cs b/win/CS/HandBrake.ApplicationServices/Utilities/Win7.cs
deleted file mode 100644
index 10ae1f296..000000000
--- a/win/CS/HandBrake.ApplicationServices/Utilities/Win7.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="Win7.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// A class implimenting Windows 7 Specific features
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrake.ApplicationServices.Utilities
-{
- using System.Windows.Shell;
-
- /// <summary>
- /// A class implementing Windows 7 Specific features
- /// </summary>
- public class Win7
- {
- /// <summary>
- /// The Windows Taskbar
- /// </summary>
- public static TaskbarItemInfo WindowsTaskbar;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Win7"/> class.
- /// </summary>
- public Win7()
- {
- if (WindowsTaskbar == null)
- WindowsTaskbar = new TaskbarItemInfo();
- }
-
- /// <summary>
- /// Gets a value indicating whether is windows seven.
- /// </summary>
- public bool IsWindowsSeven
- {
- get
- {
- return true;
- }
- }
-
- /// <summary>
- /// The get task bar.
- /// </summary>
- /// <returns>
- /// The <see cref="TaskbarItemInfo"/>.
- /// </returns>
- public TaskbarItemInfo GetTaskBar()
- {
- return WindowsTaskbar;
- }
-
- /// <summary>
- /// Set the Task Bar Percentage.
- /// </summary>
- /// <param name="percentage">
- /// The percentage.
- /// </param>
- public void SetTaskBarProgress(int percentage)
- {
- // Update the taskbar progress indicator. The normal state shows a green progress bar.
- Caliburn.Micro.Execute.OnUIThread(
- () =>
- {
- WindowsTaskbar.ProgressState = TaskbarItemProgressState.Normal;
- WindowsTaskbar.ProgressValue = (double)percentage / 100;
- });
- }
-
- /// <summary>
- /// Disable Task Bar Progress
- /// </summary>
- public void SetTaskBarProgressToNoProgress()
- {
- Caliburn.Micro.Execute.OnUIThread(() => WindowsTaskbar.ProgressState = TaskbarItemProgressState.None);
- }
- }
-} \ No newline at end of file