2013-12-16 1 views
1

행에 오디오 레코드가있는 테이블 (ObjectListView)이 있습니다. 그 중 하나가 열입니다. 형식은 hh : mm : ss입니다. BarRenderer를이 열에 적용하여이 진행률과 길이 모두 재생 진행률을 표시해야합니다. 나는 자신의 렌더러를 쓰거나 기존의 렌더러를 사용할 수 있습니까?ObjectListView에 텍스트가있는 진행률 열

답변

1

BarRenderer에서 파생 된 사용자 정의 클래스를 사용하여이 작업을 수행했습니다. 재정의 된 Render 메서드를 고려하십시오.

public class BarTextRenderer : BarRenderer 
{ 
    #region Constructors 

    /// <summary> 
    /// Make a BarTextRenderer 
    /// </summary> 
    public BarTextRenderer() : base() {} 

    /// <summary> 
    /// Make a BarTextRenderer for the given range of data values 
    /// </summary> 
    public BarTextRenderer (int minimum, int maximum) : base(minimum, maximum) { } 

    /// <summary> 
    /// Make a BarTextRenderer using a custom bar scheme 
    /// </summary> 
    public BarTextRenderer (Pen pen, Brush brush) : base(pen, brush) { } 
    /// <summary> 
    /// Make a BarTextRenderer using a custom bar scheme 
    /// </summary> 
    public BarTextRenderer (int minimum, int maximum, Pen pen, Brush brush) : base(minimum, maximum, pen, brush) { } 

    /// <summary> 
    /// Make a BarTextRenderer that uses a horizontal gradient 
    /// </summary> 
    public BarTextRenderer (Pen pen, Color start, Color end) : base(pen, start, end) { } 

    /// <summary> 
    /// Make a BarTextRenderer that uses a horizontal gradient 
    /// </summary> 
    public BarTextRenderer (int minimum, int maximum, Pen pen, Color start, Color end) : base(minimum, maximum, pen, start, end) { } 

    #endregion 

    public override void Render(Graphics g, Rectangle r) 
    { 
    base.Render(g, r); 
    float x = r.X + (float)r.Width/2f; 
    float w = r.Width/2f; 
    float h = Math.Max (r.Height-this.Font.Size, 0.8f*r.Height); 
    float y = (float)r.Y + 0.6f*(r.Height-h); 

    RectangleF rf = new RectangleF(x, y, w, h); 
    g.DrawString(this.Aspect.ToString(), this.Font, this.Brush, rf); 
    } 
} 
관련 문제