Ejemplo n.º 1
0
        protected override IMenuStrip CreateCustomStrip()
        {
            XmlElement element = this.StartMenuDocument.CreateElement("home", "McmlApplication", this.StartMenuDocument.DocumentElement.GetAttribute("xmlns:home"));
            int        num     = 100;

            element.SetAttribute("Priority", num.ToString());
            string str1 = Guid.NewGuid().ToString();

            element.SetAttribute("AppID", str1);
            string str2 = string.Format("m{0}", (object)str1);

            element.SetAttribute("StartMenuCategory", string.Format("global://{0}:MenuMenderSMC", (object)str2));
            string       resourceName = string.Format("SM.MenuMender.{0}.xml", (object)str1);
            XmlAttribute attribute    = this.StartMenuDocument.CreateAttribute(string.Format("xmlns:{0}", (object)str2));

            attribute.Value = string.Format("res://ehres!{0}", (object)resourceName);
            this.StartMenuDocument.DocumentElement.Attributes.Append(attribute);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(string.Format(Advent.MediaCenter.Resources.FijiMenuStripTemplate, (object)"Custom menu", (object)str1));
            FijiMenuStrip fijiMenuStrip = new FijiMenuStrip((StartMenuManager)this, doc, element, resourceName);

            fijiMenuStrip.BeginInit();
            fijiMenuStrip.StartMenuNamespace = str2;
            fijiMenuStrip.Priority           = num;
            fijiMenuStrip.EndInit();
            return((IMenuStrip)fijiMenuStrip);
        }
Ejemplo n.º 2
0
 private void Strips_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.OldItems != null)
     {
         foreach (IMenuStrip menuStrip in (IEnumerable)e.OldItems)
         {
             FijiMenuStrip fijiMenuStrip = menuStrip as FijiMenuStrip;
             if (fijiMenuStrip != null)
             {
                 this.deletedStrips.Add(fijiMenuStrip);
             }
         }
     }
     if (e.NewItems == null)
     {
         return;
     }
     foreach (IMenuStrip menuStrip in (IEnumerable)e.NewItems)
     {
         FijiMenuStrip fijiMenuStrip = menuStrip as FijiMenuStrip;
         if (fijiMenuStrip != null)
         {
             this.deletedStrips.Remove(fijiMenuStrip);
         }
     }
 }
Ejemplo n.º 3
0
        protected override XmlNode GetNodeForSave(BaseXmlMenuStrip strip)
        {
            FijiMenuStrip fijiMenuStrip = strip as FijiMenuStrip;

            if (fijiMenuStrip == null || fijiMenuStrip.IsEnabled)
            {
                return(base.GetNodeForSave(strip));
            }
            else
            {
                return((XmlNode)strip.StartMenuElement.OwnerDocument.CreateComment(strip.StartMenuElement.OuterXml));
            }
        }
Ejemplo n.º 4
0
        protected override IMenuStrip CreateMenuStrip(XmlNode node, IResourceLibrary ehres)
        {
            XmlElement xmlElement = node as XmlElement;
            bool       flag       = true;

            if (xmlElement == null)
            {
                XmlComment comment = node as XmlComment;
                if (comment != null)
                {
                    xmlElement = MediaCenterUtil.UncommentElement(comment);
                    flag       = xmlElement == null;
                }
            }
            IMenuStrip menuStrip = (IMenuStrip)null;

            if (xmlElement != null)
            {
                if (xmlElement.Name == "home:NowPlayingApp")
                {
                    menuStrip = (IMenuStrip) new NowPlayingStrip((StartMenuManager)this, xmlElement);
                }
                else if (!(xmlElement.Name == "home:MSOApp"))
                {
                    string attribute1 = xmlElement.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);
                                    FijiMenuStrip fijiMenuStrip = new FijiMenuStrip((StartMenuManager)this, doc, xmlElement, resourceName);
                                    fijiMenuStrip.StartMenuNamespace = str;
                                    fijiMenuStrip.IsEnabled          = flag;
                                    menuStrip = (IMenuStrip)fijiMenuStrip;
                                }
                                else
                                {
                                    Trace.TraceWarning("Strip {0} points to null resource: {1}", (object)xmlElement.Name, (object)attribute2);
                                }
                            }
                            else
                            {
                                Trace.TraceWarning("Could not find namespace \"{0}\". Element: {1}", (object)str, (object)xmlElement.OuterXml);
                            }
                        }
                        else
                        {
                            Trace.TraceWarning("Invalid StartMenuCategory value \"{0}\". Element: {1}", (object)attribute1, (object)xmlElement.OuterXml);
                        }
                    }
                    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);
        }