diff options
author | sr55 <[email protected]> | 2014-11-29 17:59:31 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2014-11-29 17:59:31 +0000 |
commit | 7c0af498a9d5f7aae1e5c8d06b939c8189edcfbe (patch) | |
tree | 74d348fb0cd83d48d13d4ae1007909e032a5a807 /win/CS/HandBrake.ApplicationServices/Utilities | |
parent | d364449a2ec863db317422645d5c7a927d294654 (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/Utilities')
4 files changed, 0 insertions, 360 deletions
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 |