Example #1
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.originalTitle != this.Title)
         this.AppElement.SetAttribute("Title", this.Title);
     if (this.IsEnabled)
         this.AppElement.RemoveAttribute("Visible");
     else
         this.AppElement.SetAttribute("Visible", "False");
     foreach (XmlQuickLink xmlQuickLink in (Collection<IQuickLink>)this.QuickLinks)
     {
         XmlNode parentNode = xmlQuickLink.XmlElement.ParentNode;
         if (parentNode != null)
         {
             try
             {
                 parentNode.RemoveChild((XmlNode)xmlQuickLink.XmlElement);
             }
             catch (Exception)
             {
             }
         }
         this.AppElement.AppendChild((XmlNode)xmlQuickLink.XmlElement);
     }
     base.Save(ehres);
 }
 public void TestCleanup()
 {
     this.gameDefinitionId = null;
     this.resourceLibrary.Dispose();
     this.resourceLibrary = null;
     GC.Collect();
 }
Example #3
0
        protected EntityBase(
            EntityDefinition definition,
            IResourceLibrary resources,
            IAvatarFactory avatarFactory,
            IControllerFactory[] controllerFactories,
            ControllerConfig[] customControllers,
            Vector3D position,
            Vector3D direction,
            Vector3D velocity)
            : base(
                resources.GetSerializedResource <AvatarDefinition>(definition.AvatarId),
                definition.Mass,
                controllerFactories,
                definition.Controllers,
                customControllers)
        {
#if LOG_VERBOSE
            Log.Trace("Creating entity '{0}' at {1}...", definition.Id, position);
#endif
            this.Avatar = avatarFactory.Create(this.AvatarDefinition);

            this.Position  = position;
            this.Direction = direction;
            this.Velocity  = velocity;

#if LOG_VERBOSE
            Log.Trace("Created '{0}' at {1}.", this.Avatar.Id, this.Avatar.Position);
#endif
        }
Example #4
0
        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 UnityEntityFactory class</summary>
 public UnityEntityFactory(
     IResourceLibrary resources,
     IAvatarFactory avatarFactory,
     IControllerFactory[] controllerFactories)
     : base(resources, avatarFactory, controllerFactories)
 {
 }
 /// <summary>Initializes a new instance of the UnityGameFactory class</summary>
 /// <param name="resources">Resource library</param>
 /// <param name="worldFactory">World factory</param>
 /// <param name="inputManager">Input manager</param>
 public UnityGameFactory(
     IResourceLibrary resources,
     IWorldFactory worldFactory,
     IInputManager inputManager)
     : base(resources, worldFactory, inputManager)
 {
 }
Example #7
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.originalTitle != this.Title)
     {
         this.AppElement.SetAttribute("Title", this.Title);
     }
     if (this.IsEnabled)
     {
         this.AppElement.RemoveAttribute("Visible");
     }
     else
     {
         this.AppElement.SetAttribute("Visible", "False");
     }
     foreach (XmlQuickLink xmlQuickLink in (Collection <IQuickLink>) this.QuickLinks)
     {
         XmlNode parentNode = xmlQuickLink.XmlElement.ParentNode;
         if (parentNode != null)
         {
             try
             {
                 parentNode.RemoveChild((XmlNode)xmlQuickLink.XmlElement);
             }
             catch (Exception)
             {
             }
         }
         this.AppElement.AppendChild((XmlNode)xmlQuickLink.XmlElement);
     }
     base.Save(ehres);
 }
Example #8
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.Title != this.m_originalTitle)
     {
         this.LinkElement.SetAttribute("Description", this.Title);
     }
     base.Save(ehres);
 }
Example #9
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.IsValid)
     {
         this.SetTitleId(this.titleId);
     }
     base.Save(ehres);
 }
 /// <summary>Initializes a new instance of the UnityWorldFactory class</summary>
 public UnityWorldFactory(
     IResourceLibrary resources,
     IControllerManager controllerManager,
     IControllerFactory[] controllerFactories,
     IEntityFactory entityFactory)
     : base(resources, controllerManager, controllerFactories, entityFactory)
 {
 }
Example #11
0
        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);
        }
Example #12
0
 /// <summary>Initializes a new instance of the TestEntity class</summary>
 public TestWorld(
     LevelDefinition definition,
     IResourceLibrary resources,
     IControllerManager controllerManager,
     IControllerFactory[] controllerFactories,
     IEntityFactory entityFactory)
     : base(definition, resources, controllerManager, controllerFactories, entityFactory)
 {
 }
Example #13
0
        /// <summary>Deep creates a test EntityDefinition</summary>
        /// <param name="resourceLibrary">Library in which to create resources</param>
        /// <returns>Created EntityDefinition identifier</returns>
        public static string DeepCreateTestEntityDefinition(IResourceLibrary resourceLibrary)
        {
            var entity = CreateTestEntityDefinition(
                NewResourceId(),
                DeepCreateTestAvatarDefinition(resourceLibrary));

            resourceLibrary.AddResource(entity);
            return(entity.Id);
        }
Example #14
0
 internal override void Save(IResourceLibrary ehres)
 {
     foreach (StartMenuObject startMenuObject in (Collection <IQuickLink>) this.quickLinks)
     {
         startMenuObject.Save(ehres);
     }
     MediaCenterUtil.SaveXmlResource(ehres, this.DocumentResourceName, 23, this.xml);
     base.Save(ehres);
 }
Example #15
0
 /// <summary>Initializes a new instance of the GameBase class</summary>
 /// <param name="definition">Game definition</param>
 /// <param name="resources">Resource library</param>
 /// <param name="worldFactory">World factory</param>
 /// <param name="inputManager">Input manager</param>
 protected GameBase(GameDefinition definition, IResourceLibrary resources, IWorldFactory worldFactory, IInputManager inputManager)
 {
     this.Id           = new RuntimeId(definition.Id);
     this.Title        = definition.Title;
     this.Resources    = resources;
     this.WorldFactory = worldFactory;
     this.InputManager = inputManager;
     this.levelIds     = definition.LevelIds;
 }
Example #16
0
 /// <summary>Initializes a new instance of the UnityWorld class</summary>
 public UnityWorld(
     LevelDefinition definition,
     IResourceLibrary resources,
     IControllerManager controllerManager,
     IControllerFactory[] controllerFactories,
     IEntityFactory entityFactory)
     : base(definition, resources, controllerManager, controllerFactories, entityFactory)
 {
     SafeECall.Invoke(() => WorldBehaviour.Instance.World = this);
 }
Example #17
0
        public void TearDown()
        {
            if (this.resources != null)
            {
                this.resources.Dispose();
            }

            this.resources = null;
            GC.Collect();
        }
Example #18
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.IsEnabled)
         this.XmlElement.RemoveAttribute("Visible");
     else
         this.XmlElement.SetAttribute("Visible", "False");
     if (this.originalTitle != this.Title)
         this.XmlElement.SetAttribute("Title", this.Title);
     base.Save(ehres);
 }
Example #19
0
        /// <summary>Initializes a new instance of the ReflectionControllerFactory class</summary>
        /// <param name="controllerManager">Controller manager</param>
        /// <param name="resourceLibrary">Resource library</param>
        public ReflectionControllerFactory(IControllerManager controllerManager, IResourceLibrary resourceLibrary)
        {
            this.controllerManager = controllerManager;
            this.resources         = resourceLibrary;

            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
            //// Log.Trace("ControllerFactory - Searching for controllers in {0} assemblies: {1}", assemblies.Length, string.Join(", ", assemblies.Select(asm => asm.FullName).ToArray()));

            var types = assemblies
                        .SelectMany(asm => asm.TryGetTypes())
                        .Where(t =>
                               t != null && !t.IsInterface && !t.IsAbstract &&
                               typeof(IController).IsAssignableFrom(t))
                        .ToArray();

            this.constructors = new Dictionary <string, ConstructorInfo>();
            foreach (var type in types)
            {
                //// Log.Trace("ControllerFactory - Indexing type '{0}'...", type.FullName);

                var attr = type.GetCustomAttributes(typeof(ControllerAttribute), false)
                           .FirstOrDefault() as ControllerAttribute;

                if (attr == null)
                {
                    Log.Error(
                        "Skipping '{0}': IController implementation missing required attribute '[Controller(\"controller.identifier\")]'.",
                        type.FullName);
                    continue;
                }

                var ctor = type.GetConstructors()
                           .FirstOrDefault(c => c.GetParameters()
                                           .Select(p => p.ParameterType)
                                           .All(t => DefaultConstructorParameterTypes.Any(ct => ct.IsAssignableFrom(t)) || GlobalContainer.CanResolve(t)));
                if (ctor == null)
                {
                    Log.Error(
                        "Skipping '{0}': IController implementation did not contain any acceptable constructors.",
                        type.FullName,
                        type.Name,
                        string.Join(", ", DefaultConstructorParameterTypes.Select(t => t.FullName).ToArray()));
                    continue;
                }

                this.constructors.Add(attr.Id, ctor);
            }

#if TRACE
            Log.Trace(
                "ControllerFactory - Indexed {0} controller types:\n\t{1}",
                this.constructors.Count,
                string.Join("\n\t", this.constructors.Select(kvp => "{0} ({1})".FormatInvariant(kvp.Key, kvp.Value.DeclaringType.FullName)).ToArray()));
#endif
        }
Example #20
0
        public void TestInitialize()
        {
            this.resourceLibrary   = new ResourceLibrary();
            this.controllerManager = new ControllerManager();
            new DependencyContainer()
            .RegisterSingleton <IResourceLibrary>(this.resourceLibrary)
            .RegisterSingleton <IControllerManager>(this.controllerManager);

            this.gameDefinitionId = GameDataHelper.DeepCreateTestGameDefinition(
                this.resourceLibrary, 4, 8, 3, 16, 16);
        }
Example #21
0
 /// <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)
 {
 }
Example #22
0
 /// <summary>Initializes a new instance of the WorldFactoryBase class</summary>
 protected WorldFactoryBase(
     IResourceLibrary resources,
     IControllerManager controllerManager,
     IControllerFactory[] controllerFactories,
     IEntityFactory entityFactory)
     : base(resources)
 {
     this.ControllerManager = controllerManager;
     this.ControllerFactories = controllerFactories;
     this.EntityFactory = entityFactory;
 }
Example #23
0
 /// <summary>Initializes a new instance of the TestEntity class</summary>
 public TestEntity(
     EntityDefinition definition,
     IResourceLibrary library,
     IAvatarFactory avatarFactory,
     IControllerFactory[] controllerFactories,
     ControllerConfig[] controllers,
     Vector3D position,
     Vector3D direction,
     Vector3D velocity)
     : base(definition, library, avatarFactory, controllerFactories, controllers, position, direction, velocity)
 {
 }
Example #24
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);
            }
        }
Example #25
0
        /// <summary>Deep creates a test AvatarDefinition</summary>
        /// <param name="resourceLibrary">Library in which to create resources</param>
        /// <returns>Created AvatarDefinition identifier</returns>
        public static string DeepCreateTestAvatarDefinition(IResourceLibrary resourceLibrary)
        {
            var avatar = CreateTestAvatarDefinition();

            resourceLibrary.AddResource(avatar);

            var content  = "<AvatarResource>{0}</AvatarResource>".FormatInvariant(avatar.ResourceId);
            var resource = new GenericNativeResource <string>(avatar.ResourceId, content);

            resourceLibrary.AddResource(resource);

            return(avatar.Id);
        }
Example #26
0
 public void SetUp()
 {
     this.resources           = new ResourceLibrary();
     this.controllers         = new ControllerManager();
     this.avatarFactory       = new TestAvatarFactory(this.resources);
     this.controllerFactories = new IControllerFactory[]
     {
         this.entityControllerFactory = new ReflectionControllerFactory <IEntity>(this.controllers, this.resources),
     };
     new DependencyContainer()
     .RegisterSingleton <IControllerManager, ControllerManager>()
     .RegisterSingleton <IInputManager, InputManager>();
 }
Example #27
0
 /// <summary>Initializes a new instance of the UnityEntity class</summary>
 public UnityEntity(
     EntityDefinition definition,
     IResourceLibrary library,
     IAvatarFactory avatarFactory,
     IControllerFactory[] controllerFactories,
     ControllerConfig[] controllers,
     Vector3D position,
     Vector3D direction,
     Vector3D velocity)
     : base(definition, library, avatarFactory, controllerFactories, controllers, position, direction, velocity)
 {
     this.UnityAvatar.AddObjectBehaviour <EntityBehaviour>().Entity = this;
     this.UnityAvatar.Layer = EntityLayer;
 }
Example #28
0
        /// <summary>Deep creates a test LevelDefinition</summary>
        /// <param name="resourceLibrary">Library in which to create resources</param>
        /// <param name="numEntities">Number of entities to create</param>
        /// <returns>Created LevelDefinition identifier</returns>
        public static string DeepCreateTestLevelDefinition(
            IResourceLibrary resourceLibrary,
            int numEntities)
        {
            var entityIds = Enumerable.Range(0, numEntities).Select(i =>
                                                                    DeepCreateTestEntityDefinition(resourceLibrary))
                            .ToArray();
            var level = CreateTestLevelDefinition(
                NewResourceId(),
                entityIds);

            resourceLibrary.AddResource(level);
            return(level.Id);
        }
Example #29
0
        /// <summary>Deep creates a test GameDefinition</summary>
        /// <remarks>Creates a test game definition and all referenced resources</remarks>
        /// <param name="resourceLibrary">Library in which to create resources</param>
        /// <param name="numEntities">Number of entities to create</param>
        /// <param name="numLevels">Number of levels to create</param>
        /// <returns>Created game definition identifier</returns>
        public static string DeepCreateTestGameDefinition(
            IResourceLibrary resourceLibrary,
            int numEntities,
            int numLevels)
        {
            var levelIds = Enumerable.Range(0, numLevels)
                           .Select(i =>
                                   DeepCreateTestLevelDefinition(resourceLibrary, numEntities))
                           .ToArray();
            var game = CreateTestGameDefinition(NewResourceId(), levelIds);

            resourceLibrary.AddResource(game.GetTextResource());
            return(game.Id);
        }
Example #30
0
 /// <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)
 {
 }
Example #31
0
 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));
             }
         }
     }
 }
Example #32
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.OemQuickLink != null)
     {
         OemQuickLink oemQuickLink = this.OemQuickLink;
         this.launchElement.SetAttribute("AppId", oemQuickLink.ApplicationID);
         this.launchElement.SetAttribute("EntryPointId", oemQuickLink.EntryPointID);
         this.LinkElement.SetAttribute("Description", this.OemQuickLink.Title);
         this.LinkElement.SetAttribute("EntryPointId", oemQuickLink.EntryPointID);
         XmlElement xmlElement = (XmlElement)Enumerable.First <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)this.LinkElement), (Func <XmlElement, bool>)(o => o.Name == "Image")).FirstChild.FirstChild;
         Enumerable.First <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)xmlElement.ChildNodes), (Func <XmlElement, bool>)(o => o.GetAttribute("Name") == "Focus")).SetAttribute("Source", Windows7PartnerQuickLink.GetFileUrl(oemQuickLink.EntryPoint.ImageUrl));
         Enumerable.First <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)xmlElement.ChildNodes), (Func <XmlElement, bool>)(o => o.GetAttribute("Name") == "Default")).SetAttribute("Source", Windows7PartnerQuickLink.GetFileUrl(oemQuickLink.EntryPoint.InactiveImageUrl ?? oemQuickLink.EntryPoint.ImageUrl));
     }
     base.Save(ehres);
 }
Example #33
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.OemQuickLink != null)
     {
         OemQuickLink oemQuickLink = this.OemQuickLink;
         this.launchElement.SetAttribute("AppId", oemQuickLink.ApplicationID);
         this.launchElement.SetAttribute("EntryPointId", oemQuickLink.EntryPointID);
         this.LinkElement.SetAttribute("Description", this.OemQuickLink.Title);
         this.LinkElement.SetAttribute("EntryPointId", oemQuickLink.EntryPointID);
         XmlElement xmlElement = (XmlElement)Enumerable.First<XmlElement>(Enumerable.OfType<XmlElement>((IEnumerable)this.LinkElement), (Func<XmlElement, bool>)(o => o.Name == "Image")).FirstChild.FirstChild;
         Enumerable.First<XmlElement>(Enumerable.OfType<XmlElement>((IEnumerable)xmlElement.ChildNodes), (Func<XmlElement, bool>)(o => o.GetAttribute("Name") == "Focus")).SetAttribute("Source", Windows7PartnerQuickLink.GetFileUrl(oemQuickLink.EntryPoint.ImageUrl));
         Enumerable.First<XmlElement>(Enumerable.OfType<XmlElement>((IEnumerable)xmlElement.ChildNodes), (Func<XmlElement, bool>)(o => o.GetAttribute("Name") == "Default")).SetAttribute("Source", Windows7PartnerQuickLink.GetFileUrl(oemQuickLink.EntryPoint.InactiveImageUrl ?? oemQuickLink.EntryPoint.ImageUrl));
     }
     base.Save(ehres);
 }
Example #34
0
 internal override void Save(IResourceLibrary ehres)
 {
     XmlNode quickLinksNode = this.QuickLinksNode;
     MediaCenterUtil.StripChildComments(quickLinksNode);
     foreach (XmlQuickLink xmlQuickLink in (Collection<IQuickLink>)this.QuickLinks)
     {
         XmlNode parentNode = xmlQuickLink.XmlElement.ParentNode;
         if (parentNode != null)
         {
             try
             {
                 parentNode.RemoveChild((XmlNode)xmlQuickLink.XmlElement);
             }
             catch (Exception)
             {
             }
         }
         bool flag = true;
         Windows7PartnerQuickLink partnerQuickLink = xmlQuickLink as Windows7PartnerQuickLink;
         if (partnerQuickLink != null)
             flag = partnerQuickLink.OemQuickLink != null;
         if (flag)
         {
             if (xmlQuickLink.IsEnabled)
             {
                 quickLinksNode.AppendChild((XmlNode)xmlQuickLink.XmlElement);
             }
             else
             {
                 XmlComment comment = this.MenuStripDocument.CreateComment(xmlQuickLink.XmlElement.OuterXml);
                 quickLinksNode.AppendChild((XmlNode)comment);
             }
         }
     }
     if (this.Title != this.m_originalTitle)
         this.StartMenuCategoryNode.Attributes["Description"].Value = this.Title;
     base.Save(ehres);
 }
Example #35
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;
 }
Example #36
0
 protected override IMenuStrip CreateMenuStrip(XmlNode node, IResourceLibrary ehres)
 {
     XmlElement startMenuTargetElement = node as XmlElement;
     bool flag = true;
     if (startMenuTargetElement == null)
     {
         XmlComment comment = node as XmlComment;
         if (comment != null)
         {
             startMenuTargetElement = MediaCenterUtil.UncommentElement(comment);
             flag = startMenuTargetElement == null;
         }
     }
     IMenuStrip menuStrip = (IMenuStrip)null;
     if (startMenuTargetElement != null)
     {
         XmlElement xmlElement = startMenuTargetElement;
         if (startMenuTargetElement.Name == "home:ConstrainedCategory" || startMenuTargetElement.Name == "constraints:ConstrainedItem")
             startMenuTargetElement = (XmlElement)startMenuTargetElement.FirstChild.FirstChild;
         if (startMenuTargetElement.Name == "home:NowPlayingStartMenuCategory")
             menuStrip = (IMenuStrip)new NowPlayingStrip((StartMenuManager)this, xmlElement);
         else if (!(startMenuTargetElement.Name == "home:MSOStartMenuCategory"))
         {
             string attribute1 = startMenuTargetElement.GetAttribute("StartMenuCategory");
             if (!string.IsNullOrEmpty(attribute1) && attribute1.StartsWith("global://"))
             {
                 int num = attribute1.IndexOf(':', "global://".Length);
                 if (num >= 0)
                 {
                     string str = attribute1.Substring("global://".Length, num - "global://".Length);
                     string attribute2 = this.StartMenuDocument.DocumentElement.GetAttribute("xmlns:" + str);
                     if (!string.IsNullOrEmpty(attribute2))
                     {
                         string resourceName;
                         XmlReader xmlResource = MediaCenterUtil.GetXmlResource(this.Resources, attribute2, out resourceName);
                         if (xmlResource != null)
                         {
                             XmlDocument doc = new XmlDocument();
                             doc.Load(xmlResource);
                             Windows7MenuStrip windows7MenuStrip = new Windows7MenuStrip((StartMenuManager)this, doc, xmlElement, startMenuTargetElement, resourceName);
                             windows7MenuStrip.StartMenuNamespace = str;
                             windows7MenuStrip.IsEnabled = flag;
                             menuStrip = (IMenuStrip)windows7MenuStrip;
                         }
                         else
                             Trace.TraceWarning("Strip {0} points to null resource: {1}", (object)startMenuTargetElement.Name, (object)attribute2);
                     }
                     else
                         Trace.TraceWarning("Could not find namespace \"{0}\". Element: {1}", (object)str, (object)startMenuTargetElement.OuterXml);
                 }
                 else
                     Trace.TraceWarning("Invalid StartMenuCategory value \"{0}\". Element: {1}", (object)attribute1, (object)startMenuTargetElement.OuterXml);
             }
             else
                 Trace.TraceWarning("Unknown application element: {0}", new object[1]
     {
       (object) startMenuTargetElement.OuterXml
     });
         }
     }
     int result;
     if (menuStrip != null && int.TryParse(startMenuTargetElement.GetAttribute("Priority"), out result))
         menuStrip.Priority = result;
     return menuStrip;
 }
Example #37
0
 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);
 }
Example #38
0
 protected override IMenuStrip CreateMenuStrip(XmlNode node, IResourceLibrary ehres)
 {
     IMenuStrip menuStrip = (IMenuStrip)null;
     XmlElement xmlElement = node as XmlElement;
     if (xmlElement != null)
     {
         if (xmlElement.Name == "home:NowPlayingApp")
             menuStrip = (IMenuStrip)new NowPlayingStrip((StartMenuManager)this, xmlElement);
         else if (!(xmlElement.Name == "home:MSOApp"))
         {
             string attribute = xmlElement.GetAttribute("Uri");
             if (!string.IsNullOrEmpty(attribute))
             {
                 XmlReader xmlResource = MediaCenterUtil.GetXmlResource(ehres, attribute, 23);
                 if (xmlResource != null)
                 {
                     XmlDocument doc = new XmlDocument();
                     doc.Load(xmlResource);
                     menuStrip = (IMenuStrip)new DefaultMenuStrip((StartMenuManager)this, doc, xmlElement, attribute);
                 }
                 else
                     Trace.TraceWarning("Strip {0} points to null resource: {1}", (object)xmlElement.Name, (object)attribute);
             }
             else
                 Trace.TraceWarning("Unknown application element: {0}", new object[1]
     {
       (object) xmlElement.OuterXml
     });
         }
     }
     int result;
     if (menuStrip != null && int.TryParse(xmlElement.GetAttribute("Priority"), out result))
         menuStrip.Priority = result;
     return menuStrip;
 }
Example #39
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.Title != this.m_originalTitle)
         this.LinkElement.SetAttribute("Description", this.Title);
     base.Save(ehres);
 }
Example #40
0
 public static void SaveXmlResource(IResourceLibrary lib, string name, int type, XmlDocument doc)
 {
     MediaCenterUtil.UpdateXml(lib.GetResource(name, (object)type), doc);
 }
Example #41
0
 internal override void Save(IResourceLibrary ehres)
 {
     if (this.IsValid)
         this.SetTitleId(this.titleId);
     base.Save(ehres);
 }