コード例 #1
0
        private void flickerFreeListBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            HostWithStatus host = flickerFreeListBox1.Items[e.Index] as HostWithStatus;

            using (SolidBrush backBrush = new SolidBrush(flickerFreeListBox1.BackColor))
            {
                e.Graphics.FillRectangle(backBrush, e.Bounds);
            }
            e.Graphics.DrawImage(Images.GetImage16For(host.Host), new Rectangle(e.Bounds.Location, new Size(e.Bounds.Height, e.Bounds.Height)));
            int width = Drawing.MeasureText(host.StatusString, flickerFreeListBox1.Font).Width;

            Drawing.DrawText(e.Graphics, host.ToString(), flickerFreeListBox1.Font, new Rectangle(e.Bounds.Left + Properties.Resources._000_Server_h32bit_16.Width, e.Bounds.Top, e.Bounds.Right - (width + Properties.Resources._000_Server_h32bit_16.Width), e.Bounds.Height), flickerFreeListBox1.ForeColor, TextFormatFlags.Left | TextFormatFlags.EndEllipsis);
            if (host.Status == HostStatus.queued)
            {
                Drawing.DrawText(e.Graphics, host.StatusString, flickerFreeListBox1.Font, new Rectangle(e.Bounds.Right - width, e.Bounds.Top, width, e.Bounds.Height), flickerFreeListBox1.ForeColor, flickerFreeListBox1.BackColor);
            }
            else if (host.Status == HostStatus.compiling || host.Status == HostStatus.downloading)
            {
                Drawing.DrawText(e.Graphics, host.StatusString, flickerFreeListBox1.Font, new Rectangle(e.Bounds.Right - width, e.Bounds.Top, width, e.Bounds.Height), Color.Blue, flickerFreeListBox1.BackColor);
            }
            else if (host.Status == HostStatus.succeeded)
            {
                Drawing.DrawText(e.Graphics, host.StatusString, flickerFreeListBox1.Font, new Rectangle(e.Bounds.Right - width, e.Bounds.Top, width, e.Bounds.Height), Color.Green, flickerFreeListBox1.BackColor);
            }
            if (host.Status == HostStatus.failed)
            {
                Drawing.DrawText(e.Graphics, host.StatusString, flickerFreeListBox1.Font, new Rectangle(e.Bounds.Right - width, e.Bounds.Top, width, e.Bounds.Height), Color.Red, flickerFreeListBox1.BackColor);
            }
        }