views:

85

answers:

1

Ok so im starting to get stuck into my design and get the style right.

My Theme is using a kryptonForm style GUI but kyryptonForms do not not have a pre designed ListView, so im having to build this myself

My Application is a messenger system based on XMPP/Jabber so you can guess how i would like my contact list to be designed.

i have done most of the positioning but im struggling on styling each contact row.

Im aiming for some transparent overlay simmerler to the MSN Live messenger Contact List

Heres my OnDraw Event code atm and im struggling to figure out the best way to do the gradient

private void ContactItem_OnPaintDraw(object sender, DrawListViewItemEventArgs e)
    {

        Rectangle ImageRect = e.Bounds;
        ImageRect.Inflate(-2, -2);
        ImageRect.Width = 32;

        Rectangle TextRect = e.Bounds;
        TextRect.X = ImageRect.Right + 2;
        TextRect.Width = e.Bounds.Width - TextRect.X;

        Rectangle IconRect = TextRect;
        IconRect.Inflate(-1, 0);
        IconRect.Y = ImageRect.Bottom - 16;
        IconRect.Width = 16;
        IconRect.Height = 16;

        if ((e.State & ListViewItemStates.Selected) != 0)
        {
            // Draw the background and focus rectangle for a selected item.
            e.Graphics.FillRectangle(ContactListBackgroundBrush, e.Bounds);
            e.DrawFocusRectangle();
        }
        else
        {
            // Draw the background for an unselected item.
            e.Graphics.FillRectangle(Brushes.White, e.Bounds);
        }

        if (ListViewContacts.View != View.Details)
        {

            e.Graphics.DrawImage((Image)Resources.UserIconDefault, ImageRect);

            TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.Font, TextRect, e.Item.ForeColor, TextFormatFlags.GlyphOverhangPadding);
        }
    }

And the ContactListBackgroundBrush var is like so

private Brush ContactListBackgroundBrush = new SolidBrush(Color.FromArgb(33, 162, 191));

its this that i need to convert to the styled element

alt text

Im Looking to get this Highlighted style without importing any specific windows 7 DLL files as the App is used for windows XP as well.

Hope you guys can help me :)

A: 

You can define a brush as a LinearGradientBrush, look for the msnd documentation. This is IMHO the best way, to draw gradiants..

cevik