protected override void Dispose(bool isDisposing)
 {
     if (isDisposing && this.muiFile != null)
     {
         using (UnmanagedLibrary unmanagedLibrary = new UnmanagedLibrary(this.muiFile))
         {
             foreach (object index in unmanagedLibrary.ResourceTypes)
             {
                 string str = index as string;
                 if ((str == null || !(str == "MUI")) && (str != null || (int)index != 16))
                 {
                     foreach (Resource resource1 in unmanagedLibrary[index])
                     {
                         IResource resource2 = resource1.ID.HasValue ? this.GetResource(resource1.ID.Value, index) : this.GetResource(resource1.Name, index);
                         foreach (ushort num in resource1.Languages)
                             resource2.Update(resource1.GetBytes(new ushort?(num)), new ushort?(num));
                     }
                 }
             }
         }
     }
     base.Dispose(isDisposing);
     if (this.mode != UnmanagedLibraryAccess.Write)
         return;
     this.OnMediaCenterLibraryUpdated(new MediaCenterLibraryUpdatedEventArgs(this.File));
 }
Exemple #2
0
 private Resource(UnmanagedLibrary library)
 {
     if (library == null)
     {
         throw new ArgumentNullException("library");
     }
     this.library = library;
 }
Exemple #3
0
 internal Resource(UnmanagedLibrary library, int name, object type)
     : this(library)
 {
     if (type == null)
         throw new ArgumentNullException("type");
     this.intName = name;
     if (type is string)
         this.stringType = (string)type;
     else
         this.intType = (int)type;
 }
Exemple #4
0
 internal Resource(UnmanagedLibrary library, int name, object type)
     : this(library)
 {
     if (type == null)
     {
         throw new ArgumentNullException("type");
     }
     this.intName = name;
     if (type is string)
     {
         this.stringType = (string)type;
     }
     else
     {
         this.intType = (int)type;
     }
 }
Exemple #5
0
 protected override void Load()
 {
     string attribute = this.LinkElement.GetAttribute("ResourceProviderId");
     this.titleId = this.GetTitleId();
     int.TryParse(this.titleId, out this.titleID);
     this.imageBaseName = this.LinkElement.GetAttribute("ImageBaseName");
     if (attribute == "Spotlight")
         this.resourceFile = PackageQuickLink.GetPackagePath("MCESpotlight", "MCESpotlight", "SpotlightResources.dll");
     else if (attribute == "NetTV")
     {
         this.resourceFile = PackageQuickLink.GetPackagePath("NetTV", "Browse", "NetTVResources.dll");
     }
     else
     {
         if (!(attribute == "NetOpSM"))
             throw new ArgumentException("Unknown provider: " + attribute);
         this.resourceFile = PackageQuickLink.GetPackagePath("MCEClientUX", "NetOp", "SMResources.dll");
     }
     if (File.Exists(this.resourceFile))
     {
         using (UnmanagedLibrary unmanagedLibrary = new UnmanagedLibrary(this.resourceFile))
         {
             this.Title = ResourceExtensions.GetStringResource((IResourceLibrary)unmanagedLibrary, this.titleID);
             byte[] bytes1 = ResourceExtensions.GetBytes(unmanagedLibrary.GetResource(this.imageBaseName + ".NoFocus.png", (object)10));
             if (bytes1 != null)
             {
                 BitmapDecoder bitmapDecoder = BitmapDecoder.Create((Stream)new MemoryStream(bytes1), BitmapCreateOptions.None, BitmapCacheOption.Default);
                 this.SetValue(XmlQuickLink.NonFocusImageProperty, (object)bitmapDecoder.Frames[0]);
             }
             byte[] bytes2 = ResourceExtensions.GetBytes(unmanagedLibrary.GetResource(this.imageBaseName + ".Focus.png", (object)10));
             if (bytes2 != null)
             {
                 BitmapDecoder bitmapDecoder = BitmapDecoder.Create((Stream)new MemoryStream(bytes2), BitmapCreateOptions.None, BitmapCacheOption.Default);
                 this.SetValue(XmlQuickLink.ImageProperty, (object)bitmapDecoder.Frames[0]);
             }
         }
     }
     this.SetValue(XmlQuickLink.IsValidPropertyKey, (object)(string.IsNullOrEmpty(this.Title) ? false : (this.Image != null ? true : false)));
 }
Exemple #6
0
        internal Game(System.Management.ManagementBaseObject game)
        {
            this.name = game.GetPropertyValue("Name") as string;
            this.instanceID = game.GetPropertyValue("InstanceID") as string;
            this.gameID = game.GetPropertyValue("GameID") as string;
            this.gdfPath = game.GetPropertyValue("GDFBinaryPath") as string;
            string str1 = this.gdfPath;
            this.installPath = game.GetPropertyValue("GameInstallPath") as string;
            this.gdfResourceID = game.GetPropertyValue("ResourceIDForGDFInfo") as string;
            this.installScope = (Game.GameInstallScope)game.GetPropertyValue("InstallScope");
            this.RefreshTasks();
            if (this.gdfPath != null)
            {
                try
                {
                    using (UnmanagedLibrary unmanagedLibrary = new UnmanagedLibrary(this.gdfPath))
                    {
                        try
                        {
                            byte[] bytes = ResourceExtensions.GetBytes(unmanagedLibrary.GetResource("__GDF_THUMBNAIL", (object)"DATA"));
                            if (bytes != null)
                            {
                                try
                                {
                                    this.image = (ImageSource)BitmapDecoder.Create((Stream)new MemoryStream(bytes), BitmapCreateOptions.None, BitmapCacheOption.Default).Frames[0];
                                }
                                catch (Exception ex)
                                {
                                    Trace.TraceWarning("Image for " + this.name + "could not be loaded: " + ex .Message);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Trace.TraceWarning("Error attempting to get image resource for " + this.name + "could not be loaded: " + ex.Message);
                        }
                        using (RegistryKey registryKey1 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\GameUX\\"))
                        {
                            if (registryKey1 != null)
                            {
                                foreach (object obj in registryKey1.GetSubKeyNames())
                                {
                                    string name = string.Format("{0}\\{1}", obj, (object)this.instanceID);
                                    RegistryKey registryKey2 = registryKey1.OpenSubKey(name);
                                    if (registryKey2 != null)
                                    {
                                        using (registryKey2)
                                        {
                                            if (this.image == null)
                                            {
                                                string uriString = registryKey2.GetValue("BoxArt") as string;
                                                if (uriString != null)
                                                {
                                                    try
                                                    {
                                                        this.image = (ImageSource)BitmapDecoder.Create(new Uri(uriString), BitmapCreateOptions.None, BitmapCacheOption.Default).Frames[0];
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Trace.TraceWarning("Image for legacy game " + this.name + "could not be loaded: " + ex.Message);
                                                    }
                                                }
                                            }
                                            this.description = registryKey2.GetValue("Description") as string;
                                            if (this.playTasks.Count == 0)
                                            {
                                                string str2 = registryKey2.GetValue("AppExePath") as string;
                                                if (str2 != null)
                                                {
                                                    this.playTasks.Add(str2);
                                                    str1 = str2;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        string name1 = this.gdfResourceID ?? "__GDF_XML";
                        byte[] bytes1 = ResourceExtensions.GetBytes(unmanagedLibrary.GetResource(name1, (object)"DATA"));
                        if (bytes1 != null)
                        {
                            XmlDocument xmlDocument = new XmlDocument();
                            xmlDocument.Load((XmlReader)new XmlTextReader((Stream)new MemoryStream(bytes1)));
                            foreach (XmlNode xmlNode in xmlDocument.DocumentElement.FirstChild.ChildNodes)
                            {
                                XmlElement xmlElement = xmlNode as XmlElement;
                                if (xmlElement != null && xmlElement.Name == "Description")
                                    this.description = xmlElement.InnerXml;
                            }
                        }
                        else
                            Trace.TraceWarning("GDF resource not found for " + this.Name + ".");
                    }
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning("Error getting GDF data for " + this.name + "could not be loaded: " + ex.Message);
                }
            }
            if (this.playTasks.Count == 0)
            {
                this.IsValid = false;
                this.InvalidReason = "Could not find a play task for " + this.name + ".";
                return;
            }
            if (this.image != null)
                return;
            string filename = (string)null;
            if (this.playTasks.Count > 0)
            {
                try
                {
                    WshShell shell = new WshShell();
                    filename = ((IWshShortcut)shell.CreateShortcut(this.playTasks[0])).TargetPath;
                }
                catch
                {

                }
            }
            if (string.IsNullOrEmpty(filename))
                filename = str1;
            if (string.IsNullOrEmpty(filename))
                return;
            this.image = Shell.GenerateThumbnail(filename);
        }
Exemple #7
0
 internal ResourceCollection(UnmanagedLibrary lib, object resType)
 {
     this.library = lib;
     this.resType = resType;
 }
Exemple #8
0
 private Resource(UnmanagedLibrary library)
 {
     if (library == null)
         throw new ArgumentNullException("library");
     this.library = library;
 }
Exemple #9
0
 public void AddResourceFileDifferences(string baseResourcesPath, string modifiedResourcesPath)
 {
     using (UnmanagedLibrary unmanagedLibrary1 = new UnmanagedLibrary(baseResourcesPath))
     {
         using (UnmanagedLibrary unmanagedLibrary2 = new UnmanagedLibrary(modifiedResourcesPath))
         {
             string fileName = Path.GetFileName(baseResourcesPath);
             foreach (IResource resource in Enumerable.Where<IResource>(unmanagedLibrary2[(object)10], (Func<IResource, bool>)(o => o.Name.EndsWith(".png", StringComparison.OrdinalIgnoreCase))))
             {
                 bool flag1 = true;
                 byte[] bytes1 = ResourceExtensions.GetBytes(unmanagedLibrary1.GetResource(resource.Name, (object)10));
                 byte[] bytes2 = ResourceExtensions.GetBytes(resource);
                 if (bytes1 != null && bytes1.Length == bytes2.Length)
                 {
                     bool flag2 = true;
                     for (int index = 0; index < bytes1.Length; ++index)
                     {
                         if ((int)bytes1[index] != (int)bytes2[index])
                         {
                             flag2 = false;
                             break;
                         }
                     }
                     flag1 = !flag2;
                 }
                 if (flag1)
                     this.ThemeItems.Add((IThemeItem)new ImageResourceThemeItem(fileName, resource.Name, bytes2));
             }
         }
     }
 }