コード例 #1
0
        public static List <PlexActor> GetActorsFromMetadata(XmlDocument metadata)
        {
            var actors = new List <PlexActor>();

            var sections = new DataSet();

            sections.ReadXml(new XmlNodeReader(metadata));
            var dtActors = sections.Tables["Role"];

            if (dtActors == null)
            {
                return(actors);
            }

            foreach (DataRow r in dtActors.Rows)
            {
                var thumb = "";
                var role  = "Unknown";
                var name  = "Unknown";
                if (dtActors.Columns.Contains("thumb"))
                {
                    if (r["thumb"] != null)
                    {
                        thumb = r["thumb"].ToString();
                    }
                }
                if (dtActors.Columns.Contains("role"))
                {
                    if (r["role"] != null)
                    {
                        role = r["role"].ToString();
                    }
                }
                if (dtActors.Columns.Contains("tag"))
                {
                    if (r["tag"] != null)
                    {
                        name = r["tag"].ToString();
                    }
                }
                var a = new PlexActor
                {
                    ThumbnailUri = thumb,
                    ActorRole    = role,
                    ActorName    = name
                };
                actors.Add(a);
            }

            return(actors);
        }
コード例 #2
0
        private Panel ActorPanel(PlexActor a)
        {
            //the containing panel to be returned
            var p = new Panel
            {
                Size      = new Size(flpActors.Width, 119),
                Location  = new Point(3, 3),
                BackColor = Color.White
            };

            //their name
            var lblActorName = new Label
            {
                Text     = a.ActorName,
                AutoSize = true,
                Location = new Point(88, 3),
                Font     = new Font(FontFamily.GenericSansSerif, 13),
                Visible  = true
            };

            //the role they play in the content
            var lblActorRole = new Label
            {
                Text     = a.ActorRole,
                AutoSize = true,
                Location = new Point(112, 29),
                Visible  = true
            };

            //actor's photo
            var actorPortrait = new PictureBox
            {
                Size     = new Size(79, 119),
                Location = new Point(3, 3),
                BackgroundImageLayout = ImageLayout.Zoom,
                BackgroundImage       = a.Thumbnail ?? ImageHandler.GetImageFromUrl(a.ThumbnailUri),
                Visible = true
            };

            //add the image preview handler to the portrait
            actorPortrait.DoubleClick += ImagePreview_Portrait;

            //add the sub-controls
            p.Controls.Add(lblActorRole);
            p.Controls.Add(lblActorName);
            p.Controls.Add(actorPortrait);

            //return the result
            return(p);
        }