this.OnSelectedIndexChanged(EventArgs.Empty);
}
- public void ChangeItemBackColor(ListViewItem item, Color backColor)
+ public void RefreshItem(int index)
{
- if (item.BackColor == backColor)
- return;
-
- item.BackColor = backColor;
-
- var index = item.Index;
- if (index != -1)
- this.RefreshItemsRange(index, index);
- }
-
- public void ChangeItemForeColor(ListViewItem item, Color foreColor)
- {
- if (item.ForeColor == foreColor)
- return;
-
- item.ForeColor = foreColor;
-
- var index = item.Index;
- if (index != -1)
- this.RefreshItemsRange(index, index);
+ this.ValidateAll();
+ this.RefreshItemsRange(index, index);
}
- public void ChangeItemFontAndColor(ListViewItem item, Color foreColor, Font fnt)
+ public void RefreshItems(IEnumerable<int> indices)
{
- if (item.ForeColor == foreColor && item.Font.Equals(fnt))
- return;
-
- item.ForeColor = foreColor;
- item.Font = fnt;
+ var chunks = MyCommon.ToRangeChunk(indices);
+ this.ValidateAll();
- var index = item.Index;
- if (index != -1)
- this.RefreshItemsRange(index, index);
+ foreach (var (start, end) in chunks)
+ this.RefreshItemsRange(start, end);
}
private void RefreshItemsRange(int start, int end)
try
{
this.redrawRange = (start, end);
- this.ValidateAll();
this.RedrawItems(start, end, invalidateOnly: false);
}
finally
var fnt = this.GetFont(this.DetermineFont(post));
var cl = this.GetForeColor(this.DetermineForeColor(post));
+ var index = item.Index;
+ if (index != -1)
+ this.listView.Update();
+
if (item.SubItems[5].Text != star)
item.SubItems[5].Text = star;
- if (item.Index == -1)
- {
- item.ForeColor = cl;
- item.Font = fnt;
- }
- else
- {
- this.listView.Update();
- this.listView.ChangeItemFontAndColor(item, cl, fnt);
- }
+ item.ForeColor = cl;
+ item.Font = fnt;
+
+ if (index != -1)
+ this.listView.RefreshItem(index);
}
public void ColorizeList()
{
var post = this.tab[index];
var backColor = this.JudgeColor(basePost, post);
- this.listView.ChangeItemBackColor(listViewItem, backColor);
+ listViewItem.BackColor = backColor;
+ this.listView.RefreshItem(index);
}
}
if (basePost == null)
return;
- if (item.Index == -1)
- item.BackColor = this.JudgeColor(basePost, post);
- else
- this.listView.ChangeItemBackColor(item, this.JudgeColor(basePost, post));
+ var index = item.Index;
+ if (index != -1)
+ this.listView.Update();
+
+ item.BackColor = this.JudgeColor(basePost, post);
+
+ if (index != -1)
+ this.listView.RefreshItem(index);
}
internal Color JudgeColor(PostClass basePost, PostClass targetPost)