129 lines
2.4 KiB
C#
129 lines
2.4 KiB
C#
using System;
|
|
using System.Drawing;
|
|
|
|
namespace MLV;
|
|
|
|
public class ManagedListViewRatingSubItem : ManagedListViewSubItem
|
|
{
|
|
private int rating;
|
|
|
|
private bool drawOverImage;
|
|
|
|
private int overRating;
|
|
|
|
private int itemHeight;
|
|
|
|
public int Rating
|
|
{
|
|
get
|
|
{
|
|
return rating;
|
|
}
|
|
set
|
|
{
|
|
rating = value;
|
|
}
|
|
}
|
|
|
|
public int OverRating
|
|
{
|
|
get
|
|
{
|
|
return overRating;
|
|
}
|
|
set
|
|
{
|
|
overRating = value;
|
|
}
|
|
}
|
|
|
|
public bool DrawOverImage
|
|
{
|
|
get
|
|
{
|
|
return drawOverImage;
|
|
}
|
|
set
|
|
{
|
|
drawOverImage = value;
|
|
}
|
|
}
|
|
|
|
public event EventHandler<ManagedListViewRatingChangedArgs> RatingChanged;
|
|
|
|
public event EventHandler<ManagedListViewRatingChangedArgs> UpdateRatingRequest;
|
|
|
|
public override void OnMouseClick(Point mouseLocation, Size charFontSize, int itemIndex)
|
|
{
|
|
base.OnMouseClick(mouseLocation, charFontSize, itemIndex);
|
|
int num = itemHeight * 4 / 5;
|
|
if (mouseLocation.X < num)
|
|
{
|
|
rating = 1;
|
|
}
|
|
else if (mouseLocation.X >= num && mouseLocation.X < num * 2)
|
|
{
|
|
rating = 2;
|
|
}
|
|
else if (mouseLocation.X >= num * 2 && mouseLocation.X < num * 3)
|
|
{
|
|
rating = 3;
|
|
}
|
|
else if (mouseLocation.X >= num * 3 && mouseLocation.X < num * 4)
|
|
{
|
|
rating = 4;
|
|
}
|
|
else if (mouseLocation.X >= num * 4 && mouseLocation.X < num * 5)
|
|
{
|
|
rating = 5;
|
|
}
|
|
else if (mouseLocation.X >= num * 5)
|
|
{
|
|
rating = 0;
|
|
}
|
|
if (this.RatingChanged != null)
|
|
{
|
|
this.RatingChanged(this, new ManagedListViewRatingChangedArgs(base.ColumnID, itemIndex, rating));
|
|
}
|
|
}
|
|
|
|
public override void OnMouseOver(Point mouseLocation, Size charFontSize)
|
|
{
|
|
base.OnMouseOver(mouseLocation, charFontSize);
|
|
int num = itemHeight * 4 / 5;
|
|
if (mouseLocation.X < num)
|
|
{
|
|
overRating = 1;
|
|
}
|
|
else if (mouseLocation.X >= num && mouseLocation.X < num * 2)
|
|
{
|
|
overRating = 2;
|
|
}
|
|
else if (mouseLocation.X >= num * 2 && mouseLocation.X < num * 3)
|
|
{
|
|
overRating = 3;
|
|
}
|
|
else if (mouseLocation.X >= num * 3 && mouseLocation.X < num * 4)
|
|
{
|
|
overRating = 4;
|
|
}
|
|
else if (mouseLocation.X >= num * 4 && mouseLocation.X < num * 5)
|
|
{
|
|
overRating = 5;
|
|
}
|
|
else if (mouseLocation.X >= num * 5)
|
|
{
|
|
overRating = 0;
|
|
}
|
|
}
|
|
|
|
public void OnRefreshRating(int itemIndex, int itemHeight)
|
|
{
|
|
if (this.UpdateRatingRequest != null)
|
|
{
|
|
this.UpdateRatingRequest(this, new ManagedListViewRatingChangedArgs(base.ColumnID, itemIndex, 0));
|
|
}
|
|
this.itemHeight = itemHeight;
|
|
}
|
|
}
|