Exemplo n.º 1
0
        public override void Draw(Graphics g, ref int x, ref int y)
        {
            base.Draw(g, ref x, ref y);
            Color fgColor = this.Block.ForeColor;
            Color bgColor = this.Block.BackColor;
            switch (Track.Status)
            {
                case Spider.Media.Resource.State.BadKarma:
                    fgColor = Color.DarkGoldenrod;
                    break;
                case Spider.Media.Resource.State.Removed:
                case Spider.Media.Resource.State.NotAvailable:
                    fgColor = Color.FromArgb(255, Color.FromArgb(100,50,50));
                    break;
            }
            if (Track.Playing)
            {
                bgColor = Color.Black;
                fgColor = Color.LightGreen;
            }
            if (Selected)
            {
                bgColor = this.SelectedBlock.BackColor;
                fgColor = this.SelectedBlock.ForeColor;
            }

            if(columnHeader == null)
                columnHeader =  this.Playlist != null && this.Playlist.ColumnHeader != null ? this.Playlist.ColumnHeader : new columnheader(this.Board, node);

            g.FillRectangle(new SolidBrush(bgColor), new Rectangle(x, y, this.Width, this.Height));
              //  g.DrawLine(new Pen(new SolidBrush(this.Block.AlternateBackColor)), new Point(x, y + this.Height - 1), new Point(this.Width + x, this.Height - 1 + y));
            if (Track.Loaded)
            {
                //

                this.Stylesheet.DrawString(g, Track.Name, this.Block.Font, new SolidBrush(fgColor), new Rectangle(10 + x + columnHeader.ColumnHeaders["name"].Left, 1 + y, 300, 30));
                if(Track.Artists != null && Track.Artists.Length > 0)
                    this.Stylesheet.DrawString(g, Track.Artists[0].Name, this.Block.Font, new SolidBrush(fgColor), new Rectangle(x + columnHeader.ColumnHeaders["artist"].Left, 1 + y, 300, 30));
                if(Track.Album != null)
                this.Stylesheet.DrawString(g, Track.Album.Name, this.Block.Font, new SolidBrush(fgColor), new Rectangle(x + columnHeader.ColumnHeaders["album"].Left, 1 + y, 300, 30));
                if (columnHeader.ColumnHeaders.ContainsKey("popularity"))
                {
                    ColumnHeader cp = columnHeader.ColumnHeaders["popularity"];
                    float popularity = Track.Popularity; // Change soon
                    for (int i = 0; i < cp.Width; i+= 3)
                    {
                        Color tagColor = Color.FromArgb(226, 226, 226);
                        float progress =  ((float)popularity) ;
                        if (((float)i / (float)cp.Width) > progress)
                        {
                            tagColor = Color.FromArgb(94,94,94);
                        }
                        g.FillRectangle(new SolidBrush(tagColor), new Rectangle(x + cp.Left + i, y +4, 2, 8));
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void PackChildren()
        {
            try
            {
                int i = 0;

                foreach (Element track in this.Children)
                {
                    if (!track.Visible)
                    {
                        i++;
                        continue;
                    }
                    if (track.GetType() == typeof(columnheader))
                    {
                        track.Height = trackHeight;
                        track.Width = this.Width == -1 ? this.Parent.Width : this.Width;
                        this.ColumnHeader = (columnheader)track;
                        this.ColumnHeader.Playlist = this;
                        track.X = 0;
                        track.Y = i * trackHeight;
                    }
                    if (track.GetType() == typeof(track))
                    {
                        //  if (track.GetType() != typeof(track) |)
                        //    throw new Exception("Invalid type");
                        track.Height = trackHeight;
                        track.Width = this.Width == -1 ? this.Parent.Width : this.Width;
                        ((track)track).Playlist = this;
                        ((track)track).Parent = this;
                        track.X = 0;
                        track.Y = i * trackHeight;
                        if (i % 2 == 1)
                        {
                            track.Block = this.Stylesheet.Blocks["track::even"];
                        }
                    }
                    if (track.GetType() == typeof(text))
                    {
                        track.Height = trackHeight;
                        track.Width = this.Width == -1 ? this.Parent.Width : this.Width;

                        track.X = 0;
                        track.Y = i * trackHeight;
                    }
                    i++;
                }
                if (i * trackHeight > this.Height)
                    this.Height = i * trackHeight + 25;
            }
            catch (Exception e)
            {
            }
        }