public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache) { FontsThemeItem fontsThemeItem = (FontsThemeItem)themeItem; IResourceLibrary resourceLibrary1 = readCache["Microsoft.MediaCenter.Shell.dll"]; IResourceLibrary resourceLibrary2 = writeCache["Microsoft.MediaCenter.Shell.dll"]; McmlDocument mcml1 = MediaCenterUtil.GetMcml(resourceLibrary1.GetResource("FONTNAMES.MCML", (object)this.DocumentResourceType)); McmlDocument mcml2 = MediaCenterUtil.GetMcml(resourceLibrary1.GetResource("FONTS.MCML", (object)this.DocumentResourceType)); foreach (FontClass fontClass in Enumerable.Where <FontClass>((IEnumerable <FontClass>)fontsThemeItem.FontClasses, (Func <FontClass, bool>)(o => o.FontFace != null))) { string typefaceName = FontUtilities.GetTypefaceName(themeItem.Theme, fontClass.FontFace); PropertyElement property = mcml1.Properties().GetProperty(fontClass.Name); if (property == null) { XElement xelement = new XElement(McmlDocument.SystemCoreNamespace + "String", new object[2] { (object)new XAttribute((XName)"Name", (object)fontClass.Name), (object)new XAttribute((XName)"String", (object)typefaceName) }); mcml1.Xml.Root.Add((object)xelement); } else { property.Value = typefaceName; } } foreach (XElement xelement in mcml1.Xml.Root.Elements()) { mcml2.Xml.Root.AddFirst((object)xelement); } MediaCenterUtil.UpdateMcml(resourceLibrary2.GetResource("FONTNAMES.MCML", (object)this.DocumentResourceType), mcml1); foreach (FontOverride fontOverride in Enumerable.Where <FontOverride>((IEnumerable <FontOverride>)fontsThemeItem.FontOverrides, (Func <FontOverride, bool>)(o => { if (o.FontFace == null) { return(o.FontClass != null); } else { return(true); } }))) { FontElement fontElement = mcml2.Properties().GetProperty(fontOverride.Name) as FontElement; if (fontElement == null) { XElement xelement = new XElement(mcml2.DefaultNamespace + "Font", (object)new XAttribute((XName)"Name", (object)fontOverride.Name)); mcml2.Xml.Root.Add((object)xelement); fontElement = (FontElement)mcml2.Properties().GetProperty(fontOverride.Name); } McmlUtilities.UpdateFontElement(fontOverride, fontElement, themeItem.Theme); } foreach (XNode xnode in mcml2.Xml.Root.Elements(mcml2.DefaultNamespace + "Aggregate")) { xnode.Remove(); } MediaCenterUtil.UpdateMcml(resourceLibrary2.GetResource("FONTS.MCML", (object)this.DocumentResourceType), mcml2); }
public void Apply(IThemeItem themeItem, MediaCenterLibraryCache readCache, MediaCenterLibraryCache writeCache) { ColorsThemeItem colorsThemeItem = (ColorsThemeItem)themeItem; if (colorsThemeItem.DefaultColors.Count <= 0) { return; } IResourceLibrary resourceLibrary1 = readCache[this.ResourceLibraryName]; IResourceLibrary resourceLibrary2 = writeCache[this.ResourceLibraryName]; McmlDocument mcml = MediaCenterUtil.GetMcml(resourceLibrary1.GetResource(this.ColorsDocumentName, (object)this.ColorsDocumentResourceType)); foreach (ColorItem colorItem in (Collection <ColorItem>)colorsThemeItem.DefaultColors) { string str = colorItem.ToString(); PropertyElement property = mcml.Properties().GetProperty(colorItem.Name); if (property == null) { XElement xelement = new XElement(mcml.DefaultNamespace + "Color", new object[2] { (object)new XAttribute((XName)"Name", (object)colorItem.Name), (object)new XAttribute((XName)"Color", (object)str) }); mcml.Xml.Root.Add((object)xelement); } else { property.Value = str; } } MediaCenterUtil.UpdateMcml(resourceLibrary2.GetResource(this.ColorsDocumentName, (object)this.ColorsDocumentResourceType), mcml); }
/// <summary>Initializes a new instance of the TestEntity class</summary> public TestEntity( IResourceLibrary library, IAvatarFactory avatarFactory, IControllerFactory[] controllerFactories, ControllerConfig[] controllers, Vector3D position, Vector3D direction, Vector3D velocity) : this(library.GetResource <EntityDefinition>(GameDataHelper.DeepCreateTestEntityDefinition(library)), library, avatarFactory, controllerFactories, controllers, position, direction, velocity) { }
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); } }
/// <summary>Initializes a new instance of the TestEntity class</summary> public TestWorld( IResourceLibrary resources, IControllerManager controllerManager, IControllerFactory[] controllerFactories, IEntityFactory entityFactory, int numEntities = DefaultNumEntities) : this( resources.GetResource <LevelDefinition>(GameDataHelper.DeepCreateTestLevelDefinition(resources, numEntities)), resources, controllerManager, controllerFactories, entityFactory) { }
public void ApplyTo(IResourceLibraryCache libraryCache) { foreach (string index in this.Libraries) { IResourceLibrary resourceLibrary1 = this[index]; IResourceLibrary resourceLibrary2 = libraryCache[index]; foreach (int num in resourceLibrary1.ResourceTypes) { foreach (IResource resource in resourceLibrary1[(object)num]) { ResourceExtensions.Update(resourceLibrary2.GetResource(resource.Name, (object)num), ResourceExtensions.GetBytes(resource)); } } } }
protected override void SaveInternal(IResourceLibrary ehres) { MediaCenterUtil.StripChildComments(this.StripParentNode); foreach (Windows7MenuStrip windows7MenuStrip in this.m_deletedStrips) { XmlElement startMenuElement = windows7MenuStrip.StartMenuElement; if (startMenuElement.ParentNode != null) { startMenuElement.ParentNode.RemoveChild((XmlNode)startMenuElement); } this.StartMenuDocument.DocumentElement.RemoveAttribute(string.Format("xmlns:{0}", (object)windows7MenuStrip.StartMenuNamespace)); ResourceExtensions.Update(ehres.GetResource(windows7MenuStrip.DocumentResourceName, (object)23), (byte[])null); } this.m_deletedStrips.Clear(); base.SaveInternal(ehres); }
public static string CreateSupportPackage() { string path2 = Guid.NewGuid().ToString(); string str1 = Path.Combine(Path.GetTempPath(), path2); Trace.TraceInformation("Creating support package..."); Directory.CreateDirectory(str1); try { File.Copy(VmcStudioUtil.LogFilePath, Path.Combine(str1, Path.GetFileName(VmcStudioUtil.LogFilePath))); string path1 = Path.Combine(VmcStudioUtil.ApplicationDataPath, "Logs"); if (Directory.Exists(path1)) { FileUtil.CopyTo(new DirectoryInfo(path1), Path.Combine(str1, "Logs"), true); } using (StreamWriter text = File.CreateText(Path.Combine(str1, "info.txt"))) { text.WriteLine("Support package ID: {0}", (object)path2); text.WriteLine("{1} Version: {0}", (object)Assembly.GetEntryAssembly().GetName().Version, (object)VmcStudioUtil.ApplicationName); FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(MediaCenterUtil.MediaCenterPath, "ehshell.exe")); text.WriteLine("Media Center Version: {0}", (object)versionInfo.ProductVersion); text.WriteLine("Date/Time: {0}", (object)DateTime.Now); text.WriteLine("User preferred language: {0}", (object)LanguageUtils.GetUserDefaultUILanguage()); text.WriteLine("System default language: {0}", (object)LanguageUtils.GetSystemDefaultUILanguage()); text.WriteLine(); try { text.WriteLine("Dumping registry..."); string str2 = Path.Combine(str1, "Registry"); Directory.CreateDirectory(str2); using (RegistryKey key1 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility")) { using (RegistryKey key2 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Extensibility")) { using (RegistryKey key3 = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Start Menu")) { using (RegistryKey key4 = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Media Center\\Start Menu")) { VmcStudioUtil.DumpRegistry(key1, Path.Combine(str2, "HKEY_LOCAL_MACHINE Extensibility.txt")); VmcStudioUtil.DumpRegistry(key2, Path.Combine(str2, "HKEY_CURRENT_USER Extensibility.txt")); VmcStudioUtil.DumpRegistry(key3, Path.Combine(str2, "HKEY_LOCAL_MACHINE Start Menu.txt")); VmcStudioUtil.DumpRegistry(key4, Path.Combine(str2, "HKEY_CURRENT_USER Start Menu.txt")); } } } } text.WriteLine("Success!"); } catch (Exception ex) { text.WriteLine(((object)ex).ToString()); } text.WriteLine(); try { text.WriteLine("Dumping resources..."); string path3 = Path.Combine(str1, "Resources"); Directory.CreateDirectory(path3); using (MediaCenterLibraryCache centerLibraryCache = new MediaCenterLibraryCache(MediaCenterUtil.MediaCenterPath)) { IResourceLibrary lib = centerLibraryCache["ehres.dll"]; VmcStudioUtil.DumpHtmlResource(lib, "STARTMENU.XML", path3); VmcStudioUtil.DumpHtmlResource(lib, "SM.ACTIVITIES.XML", path3); VmcStudioUtil.DumpHtmlResource(lib, "SM.MUSIC.XML", path3); VmcStudioUtil.DumpHtmlResource(lib, "SM.PICTURES.XML", path3); VmcStudioUtil.DumpHtmlResource(lib, "SM.SPORTS.XML", path3); VmcStudioUtil.DumpHtmlResource(lib, "SM.TV.XML", path3); UnmanagedLibrary unmanagedLibrary = lib as UnmanagedLibrary; if (unmanagedLibrary != null) { text.WriteLine("ehres.dll MUI languages: {0}", (object)VmcStudioUtil.ArrayToString(unmanagedLibrary.GetMUI().Languages)); } text.WriteLine("STARTMENU.XML languages: {0}", (object)VmcStudioUtil.ArrayToString(lib.GetResource("STARTMENU.XML", (object)23).Languages)); } text.WriteLine("Success!"); } catch (Exception ex) { text.WriteLine(((object)ex).ToString()); } } string str3 = Path.Combine(VmcStudioUtil.UserPath, "Support Packages"); if (!Directory.Exists(str3)) { Directory.CreateDirectory(str3); } string str4 = Path.Combine(str3, string.Format("Media Center Studio Support {0}.zip", (object)path2)); new FastZip().CreateZip(str4, str1, true, (string)null); Trace.WriteLine("Support package successfully created at {0}", str4); return(str4); } finally { Directory.Delete(str1, true); } }
public static void SaveXmlResource(IResourceLibrary lib, string name, int type, XmlDocument doc) { MediaCenterUtil.UpdateXml(lib.GetResource(name, (object)type), doc); }
protected override void SaveInternal(IResourceLibrary ehres) { MediaCenterUtil.StripChildComments(this.StripParentNode); foreach (Windows7MenuStrip windows7MenuStrip in this.m_deletedStrips) { XmlElement startMenuElement = windows7MenuStrip.StartMenuElement; if (startMenuElement.ParentNode != null) startMenuElement.ParentNode.RemoveChild((XmlNode)startMenuElement); this.StartMenuDocument.DocumentElement.RemoveAttribute(string.Format("xmlns:{0}", (object)windows7MenuStrip.StartMenuNamespace)); ResourceExtensions.Update(ehres.GetResource(windows7MenuStrip.DocumentResourceName, (object)23), (byte[])null); } this.m_deletedStrips.Clear(); base.SaveInternal(ehres); }
/// <summary>Gets the text representation of a resource</summary> /// <param name="this">The resource library</param> /// <param name="id">Id for the resource</param> /// <returns>Text representation of the resource</returns> public static string GetTextResource(this IResourceLibrary @this, string id) { return(@this.GetResource <ITextResource>(id).Text); }
public static void SaveXmlResource(IResourceLibrary lib, string name, int type, XmlDocument doc) { MediaCenterUtil.UpdateXml(lib.GetResource(name, (object)type), doc); }
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; }