Skip to content

Commit

Permalink
Fix #6 drawing of the first column after reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Łaputa authored and Krzysztof Łaputa committed Jun 27, 2019
1 parent 22a9ea6 commit e4ff229
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions KeeTheme/Decorators/ListViewDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,24 @@ private void HandleListViewDrawSubItem(object sender, DrawListViewSubItemEventAr
return;
}

var bounds = e.Bounds;
if (e.ColumnIndex == 0 && e.Header.DisplayIndex > 0)
{
// Fixes ListView internal error VSWhidbey #163674
bounds.Offset(e.Item.Position.X - 4, 0);
}

var flags = GetTextFormatFlags(e.Header.TextAlign);
var text = e.ItemIndex == -1 ? e.Item.Text : e.SubItem.Text;
var font = e.ItemIndex == -1 ? e.Item.Font : e.SubItem.Font;
var color = e.ItemIndex == -1 ? e.Item.ForeColor : e.SubItem.ForeColor;
var textBounds = new Rectangle(e.Bounds.Location, e.Bounds.Size);
var textBounds = new Rectangle(bounds.Location, bounds.Size);

text = " " + text + " ";
if (e.ColumnIndex == 0 && e.Item.ImageIndex > -1)
{
var image = e.Item.ImageList.Images[e.Item.ImageIndex];
e.Item.ImageList.Draw(e.Graphics, e.Bounds.X + 4, e.Bounds.Y + 1, image.Width, image.Height,
e.Item.ImageList.Draw(e.Graphics, bounds.X + 4, bounds.Y + 1, image.Width, image.Height,
e.Item.ImageIndex);

textBounds.Inflate(-image.Width - 4 - 2, 0);
Expand All @@ -248,7 +255,7 @@ private void HandleListViewDrawSubItem(object sender, DrawListViewSubItemEventAr
TextRenderer.DrawText(e.Graphics, text, font, textBounds, color, flags);

using (var pen = new Pen(_theme.ListView.ColumnBorderColor))
e.Graphics.DrawLine(pen, e.Bounds.Right - 2, e.Bounds.Y, e.Bounds.Right - 2, e.Bounds.Bottom);
e.Graphics.DrawLine(pen, bounds.Right - 2, bounds.Y, bounds.Right - 2, bounds.Bottom);
}

private void HandleListViewDrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions KeeTheme/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.1.0")]
[assembly: AssemblyFileVersion("0.5.1.0")]
[assembly: AssemblyVersion("0.5.2.0")]
[assembly: AssemblyFileVersion("0.5.2.0")]

0 comments on commit e4ff229

Please sign in to comment.