コード例 #1
0
        /// <summary>
        /// Gets the dashboard settings e.g. windows supported
        /// </summary>
        /// <param name="doc"></param>
        private static void GetDashboardSkinSettings(XmlDocument doc)
        {
            TraktLogger.Info("Loading Settings for Dashboard");

            // skinner can define different trending dashboards
            DashboardTrendingCollection = new List <DashboardTrendingSettings>();

            DashBoardActivityWindows            = new List <string>();
            DashboardActivityPropertiesMaxItems = 0;
            DashboardActivityFacadeMaxItems     = 25;
            DashboardActivityFacadeType         = "None";

            XmlNode rootNode = null;
            XmlNode node     = null;

            rootNode = doc.DocumentElement.SelectSingleNode("/settings/dashboard/statistics");
            if (rootNode != null)
            {
                HasDashboardStatistics = rootNode.InnerText.ToLowerInvariant() == "true";
            }

            rootNode = doc.DocumentElement.SelectSingleNode("/settings/dashboard/activities");
            if (rootNode != null)
            {
                node = rootNode.SelectSingleNode("windows");
                if (node != null)
                {
                    DashBoardActivityWindows = node.InnerText.Split('|').ToList();
                }

                node = rootNode.SelectSingleNode("facadetype");
                if (node != null)
                {
                    DashboardActivityFacadeType = node.InnerText;
                }

                node = rootNode.SelectSingleNode("facademaxitems");
                if (node != null)
                {
                    int maxItems;
                    if (int.TryParse(node.InnerText, out maxItems))
                    {
                        DashboardActivityFacadeMaxItems = maxItems;
                    }
                }
                node = rootNode.SelectSingleNode("propertiesmaxitems");
                if (node != null)
                {
                    int maxItems;
                    if (int.TryParse(node.InnerText, out maxItems))
                    {
                        DashboardActivityPropertiesMaxItems = maxItems;
                    }
                }
            }

            var trendingNodes = doc.DocumentElement.SelectNodes("/settings/dashboard/trending");

            if (trendingNodes != null)
            {
                foreach (XmlNode trendingNode in trendingNodes)
                {
                    var trendingItem = new DashboardTrendingSettings
                    {
                        TVShowWindows      = new List <string>(),
                        MovieWindows       = new List <string>(),
                        PropertiesMaxItems = 0,
                        FacadeMaxItems     = 10,
                        FacadeType         = "None"
                    };

                    node = trendingNode.SelectSingleNode("facadetype");
                    if (node != null)
                    {
                        trendingItem.FacadeType = node.InnerText;
                    }

                    node = trendingNode.SelectSingleNode("facademaxitems");
                    if (node != null)
                    {
                        int maxItems;
                        if (int.TryParse(node.InnerText, out maxItems))
                        {
                            trendingItem.FacadeMaxItems = maxItems;
                        }
                    }

                    node = trendingNode.SelectSingleNode("propertiesmaxitems");
                    if (node != null)
                    {
                        int maxItems;
                        if (int.TryParse(node.InnerText, out maxItems))
                        {
                            trendingItem.PropertiesMaxItems = maxItems;
                        }
                    }

                    node = trendingNode.SelectSingleNode("shows");
                    if (node != null)
                    {
                        node = node.SelectSingleNode("windows");
                        if (node != null)
                        {
                            trendingItem.TVShowWindows = node.InnerText.Split('|').ToList();
                        }
                    }

                    node = trendingNode.SelectSingleNode("movies");
                    if (node != null)
                    {
                        node = node.SelectSingleNode("windows");
                        if (node != null)
                        {
                            trendingItem.MovieWindows = node.InnerText.Split('|').ToList();
                        }
                    }

                    // add to the collection
                    DashboardTrendingCollection.Add(trendingItem);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the dashboard settings e.g. windows supported
        /// </summary>
        /// <param name="doc"></param>
        private static void GetDashboardSkinSettings(XmlDocument doc)
        {
            TraktLogger.Info("Loading Settings for Dashboard");

            // skinner can define different trending dashboards
            DashboardTrendingCollection = new List<DashboardTrendingSettings>();

            DashBoardActivityWindows = new List<string>();
            DashboardActivityPropertiesMaxItems = 0;
            DashboardActivityFacadeMaxItems = 25;
            DashboardActivityFacadeType = "None";

            XmlNode rootNode = null;
            XmlNode node = null;

            rootNode = doc.DocumentElement.SelectSingleNode("/settings/dashboard/statistics");
            if (rootNode != null)
            {
                HasDashboardStatistics = rootNode.InnerText.ToLowerInvariant() == "true";
            }

            rootNode = doc.DocumentElement.SelectSingleNode("/settings/dashboard/activities");
            if (rootNode != null)
            {
                node = rootNode.SelectSingleNode("windows");
                if (node != null)
                {
                    DashBoardActivityWindows = node.InnerText.Split('|').ToList();
                }

                node = rootNode.SelectSingleNode("facadetype");
                if (node != null)
                {
                    DashboardActivityFacadeType = node.InnerText;
                }

                node = rootNode.SelectSingleNode("facademaxitems");
                if (node != null)
                {
                    int maxItems;
                    if (int.TryParse(node.InnerText, out maxItems))
                        DashboardActivityFacadeMaxItems = maxItems;
                }
                node = rootNode.SelectSingleNode("propertiesmaxitems");
                if (node != null)
                {
                    int maxItems;
                    if (int.TryParse(node.InnerText, out maxItems))
                        DashboardActivityPropertiesMaxItems = maxItems;
                }
            }

            MaxTrendingItems = 10;

            var trendingNodes = doc.DocumentElement.SelectNodes("/settings/dashboard/trending");
            if (trendingNodes != null)
            {
                foreach (XmlNode trendingNode in trendingNodes)
                {
                    var trendingItem = new DashboardTrendingSettings
                    {
                        TVShowWindows = new List<string>(),
                        MovieWindows = new List<string>(),
                        PropertiesMaxItems = 0,
                        FacadeMaxItems = 10,
                        FacadeType = "None"
                    };

                    node = trendingNode.SelectSingleNode("facadetype");
                    if (node != null)
                    {
                        trendingItem.FacadeType = node.InnerText;
                    }

                    node = trendingNode.SelectSingleNode("facademaxitems");
                    if (node != null)
                    {
                        int maxItems;
                        if (int.TryParse(node.InnerText, out maxItems))
                        {
                            trendingItem.FacadeMaxItems = maxItems;
                            if (maxItems > MaxTrendingItems) MaxTrendingItems = maxItems;
                        }
                    }

                    node = trendingNode.SelectSingleNode("propertiesmaxitems");
                    if (node != null)
                    {
                        int maxItems;
                        if (int.TryParse(node.InnerText, out maxItems))
                            trendingItem.PropertiesMaxItems = maxItems;
                    }

                    node = trendingNode.SelectSingleNode("shows");
                    if (node != null)
                    {
                        node = node.SelectSingleNode("windows");
                        if (node != null)
                        {
                            trendingItem.TVShowWindows = node.InnerText.Split('|').ToList();
                        }
                    }

                    node = trendingNode.SelectSingleNode("movies");
                    if (node != null)
                    {
                        node = node.SelectSingleNode("windows");
                        if (node != null)
                        {
                            trendingItem.MovieWindows = node.InnerText.Split('|').ToList();
                        }
                    }

                    // add to the collection
                    DashboardTrendingCollection.Add(trendingItem);
                }
            }
        }