Ejemplo n.º 1
0
 private void QuickLinks_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (!this.IsInitInProgress && e.NewItems != null)
     {
         foreach (IQuickLink quickLink in (IEnumerable)e.NewItems)
         {
             XmlQuickLink xmlQuickLink = quickLink as XmlQuickLink;
             if (xmlQuickLink != null)
             {
                 if (this.m_app != null)
                 {
                     xmlQuickLink.LinkElement.SetAttribute("App", this.m_app);
                     xmlQuickLink.LinkElement.RemoveAttribute("AppId");
                 }
                 else if (this.m_appId != null)
                 {
                     xmlQuickLink.LinkElement.SetAttribute("AppId", this.m_appId);
                     xmlQuickLink.LinkElement.RemoveAttribute("App");
                 }
             }
         }
     }
     this.UpdateEnabled();
 }
Ejemplo n.º 2
0
        protected override void Load()
        {
            XmlAttribute xmlAttribute1 = this.StartMenuCategoryNode.Attributes["App"];

            this.m_app = xmlAttribute1 == null ? (string)null : xmlAttribute1.Value;
            XmlAttribute xmlAttribute2 = this.StartMenuCategoryNode.Attributes["AppId"];

            this.m_appId = xmlAttribute2 == null ? (string)null : xmlAttribute2.Value;
            string uri = this.StartMenuCategoryNode.Attributes["Description"].Value;

            this.Title           = MediaCenterUtil.GetStringResource(this.Manager.Resources, uri, false) ?? uri;
            this.m_originalTitle = this.Title;
            this.IsEnabled       = true;
            XmlNodeList childNodes = this.QuickLinksNode.ChildNodes;

            for (int index = 0; index < childNodes.Count; ++index)
            {
                bool       flag        = true;
                XmlElement xmlElement1 = childNodes[index] as XmlElement;
                if (xmlElement1 == null)
                {
                    XmlComment comment = childNodes[index] as XmlComment;
                    if (comment != null)
                    {
                        xmlElement1 = MediaCenterUtil.UncommentElement(comment);
                        flag        = xmlElement1 == null;
                    }
                }
                if (xmlElement1 != null)
                {
                    XmlElement linkElement = Windows7QuickLinkBase.GetLinkElement(xmlElement1);
                    IQuickLink quickLink   = (IQuickLink)null;
                    try
                    {
                        if (linkElement.Name == "home:PackageMarkupQuickLink" || linkElement.Name == "home:ExtensiblityPackageQuickLink" || linkElement.Name == "home:DualPackageMarkupQuickLink")
                        {
                            quickLink = (IQuickLink) new Windows7PackageQuickLink(this.Manager, xmlElement1);
                        }
                        else if (linkElement.Name == "home:BroadbandPromoQuicklink")
                        {
                            quickLink = (IQuickLink) new BroadbandPromoQuickLink(this.Manager, xmlElement1);
                        }
                        else if (linkElement.Name == "home:FavoritePartnerQuicklink")
                        {
                            quickLink = (IQuickLink) new FavouritePartnerQuickLink(this.Manager, xmlElement1);
                        }
                        else
                        {
                            XmlElement xmlElement2 = Enumerable.FirstOrDefault <XmlElement>(Enumerable.OfType <XmlElement>((IEnumerable)linkElement.ChildNodes), (Func <XmlElement, bool>)(o => o.Name == "Command"));
                            quickLink = xmlElement2 == null || !(xmlElement2.FirstChild.Name == "home:LaunchExtensibilityEntryPointCommand") ? (IQuickLink) new Windows7QuickLink(this.Manager, xmlElement1) : (IQuickLink) new Windows7PartnerQuickLink(this.Manager, xmlElement1);
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceWarning("Failed to load link. Exception is:\n{0}\nXml for element is:\n{1}", (object)((object)ex).ToString(), (object)xmlElement1.OuterXml);
                    }
                    if (quickLink != null)
                    {
                        quickLink.BeginInit();
                        XmlQuickLink xmlQuickLink = quickLink as XmlQuickLink;
                        if (xmlQuickLink != null)
                        {
                            int result = int.MaxValue;
                            int.TryParse(xmlQuickLink.LinkElement.GetAttribute("Priority"), out result);
                            xmlQuickLink.Priority = result;
                        }
                        quickLink.IsEnabled = flag;
                        this.QuickLinks.Add(quickLink);
                        quickLink.EndInit();
                    }
                }
            }
        }