1

好的,所以我开始陷入我的设计并获得正确的风格。

我的主题使用的是 kryptonForm 风格的 GUI,但 kyryptonForms 没有预先设计的 ListView,所以我必须自己构建这个

我的应用程序是一个基于 XMPP/Jabber 的信使系统,因此您可以猜到我希望如何设计我的联系人列表。

我已经完成了大部分定位,但我在为每个联系人行设置样式时苦苦挣扎。

我的目标是为 MSN Live Messenger 联系人列表添加一些透明覆盖

这是我的 OnDraw 事件代码 atm,我正在努力找出进行渐变的最佳方法

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);
        }
    }

ContactListBackgroundBrushvar就是这样

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

我需要将其转换为样式元素

替代文字 http://screensnapr.com/u/yeq8o0.png

我希望在不导入任何特定的 windows 7 DLL 文件的情况下获得这种突出显示的样式,因为该应用程序也用于 windows XP。

希望你们能帮助我:)

4

1 回答 1

1

您可以将画笔定义为LinearGradientBrush,查找msnd 文档。这是恕我直言,绘制渐变的最佳方式..

于 2010-07-19T20:09:34.773 回答