Esempio n. 1
0
        private static void DumpHtmlResource(IResourceLibrary lib, string resource, string path)
        {
            XmlReader   xmlResource = MediaCenterUtil.GetXmlResource(lib, resource, 23);
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(xmlResource);
            StringWriter  stringWriter  = new StringWriter();
            XmlTextWriter xmlTextWriter = new XmlTextWriter((TextWriter)stringWriter)
            {
                Formatting = Formatting.Indented
            };

            xmlDocument.WriteTo((XmlWriter)xmlTextWriter);
            using (StreamWriter text = File.CreateText(Path.Combine(path, resource)))
                text.Write(stringWriter.ToString());
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
 private void Reset(bool resetOem)
 {
     try
     {
         this.managerStrips.Clear();
         if (resetOem && this.oemManager != null)
         {
             this.oemManager.Reset();
         }
         IResourceLibrary resourceLibrary = this.Resources["ehres.dll"];
         XmlReader        xmlResource     = MediaCenterUtil.GetXmlResource(resourceLibrary, "STARTMENU.XML", 23);
         if (xmlResource != null)
         {
             this.startMenuXml = new XmlDocument();
             this.startMenuXml.Load(xmlResource);
             List <IMenuStrip> list       = new List <IMenuStrip>();
             XmlNodeList       childNodes = this.StripParentNode.ChildNodes;
             for (int index1 = 0; index1 < childNodes.Count; ++index1)
             {
                 IMenuStrip menuStrip = (IMenuStrip)null;
                 XmlElement element   = childNodes[index1] as XmlElement;
                 int        index2;
                 if (element != null && this.IsOemPlaceholderElement(element, out index2) && index2 >= 0)
                 {
                     if (index2 < this.MaxCustomStripCount)
                     {
                         if (this.oemManager != null && index2 < this.oemManager.StartMenuStrips.Count)
                         {
                             menuStrip = (IMenuStrip)this.oemManager.StartMenuStrips[index2];
                         }
                         else
                         {
                             continue;
                         }
                     }
                     else
                     {
                         Trace.WriteLine(string.Format("OEM strip element has index of {0}, which is over the max strip count of {1}.", (object)index2, (object)this.MaxCustomStripCount));
                     }
                 }
                 if (menuStrip == null)
                 {
                     menuStrip = this.CreateMenuStrip(childNodes[index1], resourceLibrary);
                 }
                 if (menuStrip != null)
                 {
                     if (element == null)
                     {
                         XmlMenuStrip xmlMenuStrip = menuStrip as XmlMenuStrip;
                         if (xmlMenuStrip != null)
                         {
                             XmlElement startMenuElement = xmlMenuStrip.StartMenuElement;
                         }
                     }
                     list.Add(menuStrip);
                 }
             }
             foreach (IMenuStrip menuStrip in list)
             {
                 this.managerStrips.Add(menuStrip);
             }
             this.managerStrips.Add((IMenuStrip) new OemCategoryStrip(this, "Auto Play (Blu-ray)", new string[1]
             {
                 "AutoPlay\\Blu-ray"
             }));
             this.managerStrips.Add((IMenuStrip) new OemCategoryStrip(this, "Auto Play (HD DVD)", new string[1]
             {
                 "AutoPlay\\HD DVD"
             }));
         }
         else
         {
             Trace.TraceWarning("Could not find STARTMENU.XML in ehres.dll!");
         }
         this.IsDirty = false;
     }
     finally
     {
         this.Resources.Clear();
     }
 }