Пример #1
0
        public static int GetMagicStringResourceID(string proc)
        {
            string str1 = proc;

            if (str1 != null && str1.StartsWith("#"))
            {
                string str2 = str1.Substring(1);
                if (str2.StartsWith("#"))
                {
                    return(-1);
                }
                if (MediaCenterUtil.stringIdHashes == null)
                {
                    Type type = Assembly.LoadFile(Path.Combine(MediaCenterUtil.MediaCenterPath, "ehshell.dll")).GetType("Microsoft.MediaCenter.Utilities.StringResourceTables", true);
                    MediaCenterUtil.stringIdHashes = (int[])type.GetField("StringIdentifierHashes").GetValue((object)null);
                    MediaCenterUtil.stringIds      = (ushort[])type.GetField("StringIdentifiers").GetValue((object)null);
                }
                int index = Array.BinarySearch <int>(MediaCenterUtil.stringIdHashes, MediaCenterUtil.GetStringHashCode(str2));
                if (index >= 0)
                {
                    return((int)MediaCenterUtil.stringIds[index]);
                }
            }
            return(-1);
        }
Пример #2
0
 public ImageSource this[string id]
 {
     get
     {
         ImageSource imageResource;
         if (!this.images.TryGetValue(id, out imageResource))
         {
             string uri;
             if (this.imageSources.TryGetValue(id, out uri))
             {
                 imageResource   = MediaCenterUtil.GetImageResource(this.cache, uri);
                 this.images[id] = imageResource;
                 if (imageResource == null)
                 {
                     Trace.TraceWarning("Could not find image set resource. Image set: {0} Image ID: {1} Resource: {2}", (object)this.setName, (object)id, (object)uri);
                 }
             }
             else if (this.setName != "Radio.FM.Preset" && id != "Default")
             {
                 Trace.TraceWarning("Could not find image set resource. Image set: {0} Image ID: {1}", (object)this.setName, (object)id);
             }
         }
         return(imageResource);
     }
 }
Пример #3
0
 public static ImageSource GetImageResource(IResourceLibraryCache cache, string uri, out string resourceName)
 {
     byte[] resource = MediaCenterUtil.GetResource(cache, uri, 10, out resourceName);
     if (resource == null)
     {
         return((ImageSource)null);
     }
     else
     {
         return((ImageSource)BitmapDecoder.Create((Stream) new MemoryStream(resource), BitmapCreateOptions.None, BitmapCacheOption.Default).Frames[0]);
     }
 }
Пример #4
0
 public static XmlReader GetXml(this IResource res)
 {
     byte[] bytes = ResourceExtensions.GetBytes(res);
     if (bytes != null)
     {
         return(MediaCenterUtil.GetXmlResource(bytes));
     }
     else
     {
         return((XmlReader)null);
     }
 }
Пример #5
0
 public static XmlReader GetXmlResource(IResourceLibraryCache cache, string uri, out string resourceName)
 {
     byte[] resource = MediaCenterUtil.GetResource(cache, uri, 23, out resourceName);
     if (resource != null)
     {
         return(MediaCenterUtil.GetXmlResource(resource));
     }
     else
     {
         return((XmlReader)null);
     }
 }
Пример #6
0
        public static XmlReader GetXmlResource(IResourceLibrary lib, string name, int type)
        {
            IResource resource = lib.GetResource(name, (object)type);

            if (resource != null)
            {
                return(MediaCenterUtil.GetXml(resource));
            }
            else
            {
                return((XmlReader)null);
            }
        }
Пример #7
0
        public static McmlDocument GetMcml(this IResource res)
        {
            XmlReader xml = MediaCenterUtil.GetXml(res);

            if (xml != null)
            {
                return(new McmlDocument(XDocument.Load(xml)));
            }
            else
            {
                return((McmlDocument)null);
            }
        }
Пример #8
0
 public static string GetMagicString(IResourceLibraryCache cache, string proc, out int resourceID)
 {
     resourceID = MediaCenterUtil.GetMagicStringResourceID(proc);
     if (resourceID >= 0)
     {
         string stringResource = ResourceExtensions.GetStringResource(cache["ehres.dll"], resourceID);
         if (stringResource != null)
         {
             return(stringResource);
         }
     }
     return(proc);
 }
Пример #9
0
        public static byte[] GetResource(IResourceLibraryCache cache, string uri, int resourceType, out string resourceName)
        {
            string dll;

            if (MediaCenterUtil.TryParseResourceUri(uri, out dll, out resourceName))
            {
                return(ResourceExtensions.GetBytes(cache[dll].GetResource(resourceName, (object)resourceType)));
            }
            else
            {
                throw new Exception("Could not find resource: " + uri);
            }
        }
Пример #10
0
        public static string GetStringResource(IResourceLibraryCache cache, string uri, bool throwIfNotFound)
        {
            string dll;
            string resource;

            if (MediaCenterUtil.TryParseResourceUri(uri, out dll, out resource))
            {
                return(ResourceExtensions.GetStringResource(cache[dll], MediaCenterUtil.GetMagicStringResourceID("#" + resource)));
            }
            if (throwIfNotFound)
            {
                throw new Exception("Could not find string resource: " + uri);
            }
            else
            {
                return((string)null);
            }
        }
Пример #11
0
 public static Process LaunchMediaCenter(bool forceFullScreen, bool forceWideScreen, bool gdi)
 {
     return(MediaCenterUtil.LaunchMediaCenter(new ProcessStartInfo(), forceFullScreen, forceWideScreen, gdi));
 }
Пример #12
0
        public static string GetMagicString(IResourceLibraryCache cache, string proc)
        {
            int resourceID;

            return(MediaCenterUtil.GetMagicString(cache, proc, out resourceID));
        }
Пример #13
0
 public static void SaveXmlResource(IResourceLibrary lib, string name, int type, XmlDocument doc)
 {
     MediaCenterUtil.UpdateXml(lib.GetResource(name, (object)type), doc);
 }
Пример #14
0
 public static void UpdateMcml(this IResource res, McmlDocument doc)
 {
     MediaCenterUtil.UpdateXml(res, doc.Xml);
 }
Пример #15
0
        public static ImageSource GetImageResource(IResourceLibraryCache cache, string uri)
        {
            string resourceName;

            return(MediaCenterUtil.GetImageResource(cache, uri, out resourceName));
        }
Пример #16
0
 public static string GetStringResource(IResourceLibraryCache cache, string uri)
 {
     return(MediaCenterUtil.GetStringResource(cache, uri, true));
 }
Пример #17
0
        public static XmlReader GetXmlResource(IResourceLibraryCache cache, string uri)
        {
            string resourceName;

            return(MediaCenterUtil.GetXmlResource(cache, uri, out resourceName));
        }