Treeviews QueueDraw不会呈现当前行?

时间:2014-04-16 07:52:15

标签: mono treeview gtk gtk# cellrenderer

我正在使用树视图,其中包含多个列,如果正在播放或暂停音频,还会显示一个pixbuf。如果用户双击一行,则开始音频播放并且需要重新渲染行以显示pixbuf图标。我使用了QueueDraw,但只有当光标离开当前行时才会起作用。如何直接更新pixbuf?

CODE:

protected void trvMainCuesheetRowActivated (object o, RowActivatedArgs args)
    {
        log.debug("trvMainCuesheetRowActivated called");
        TreeIter ti = TreeIter.Zero;
        this.lsCuesheetData.GetIter(out ti,args.Path);
        if (this.lsCuesheetData.GetValue(ti,0) != null)
        {
            Track tCurTrack = (Track)this.lsCuesheetData.GetValue(ti,0);
            if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Stopped)
            {
                this.objProgram.getAudioManager().play(tCurTrack);
                this.refresh();
            }
            else
            {
                if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Playing)
                {
                    this.objProgram.getAudioManager().seek(tCurTrack);
                    this.refresh();
                }
            }
        }
    }


private void renderPlaying(TreeViewColumn _tvcColumn, CellRenderer _crCell, TreeModel _tmModel, TreeIter _tiIter)
    {
        Track tCurTrack = (Track)_tmModel.GetValue (_tiIter, 0);
        //Just display an icon, if we are playing
        if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Playing)
        {
            if (this.objProgram.getAudioManager().getCurrentlyPlayingTrack() == tCurTrack)
            {
                Gdk.Pixbuf icon = this.RenderIcon(Stock.MediaPlay, IconSize.SmallToolbar, null);
                (_crCell as CellRendererPixbuf).Pixbuf = icon;
            } 
            else
            {
                (_crCell as CellRendererPixbuf).Pixbuf = null;
            }
        }
        else
        {
            if (this.objProgram.getAudioManager().getPlayState() == AudioCuesheetEditor.AudioBackend.PlayState.Paused)
            {
                if (this.objProgram.getAudioManager().getCurrentlyPlayingTrack() == tCurTrack)
                {
                    Gdk.Pixbuf icon = this.RenderIcon(Stock.MediaPause, IconSize.SmallToolbar, null);
                    (_crCell as CellRendererPixbuf).Pixbuf = icon;
                }
                else
                {
                    (_crCell as CellRendererPixbuf).Pixbuf = null;
                }
            }
            else
            {
                (_crCell as CellRendererPixbuf).Pixbuf = null;
            }
        }
    }

//Purpose: Function used to refresh the MainWindow depending on new options set.
public void refresh()
{
    //QueueDraw is needed since it fires a signal to cellrenderers to update
    this.trvMainCuesheet.QueueDraw();
    this.sbMainWindow.Visible = this.objProgram.getObjOption().getBShowStatusbar();
    this.mwToolbar.Visible = this.objProgram.getObjOption().getBToolbarVisible();
}

问候 斯文

1 个答案:

答案 0 :(得分:0)

自己发现错误。

this.objProgram.getAudioManager().getCurrentlyPlayingTrack()

并不总是返回一个我预期的轨道,所以渲染器工作正常。错误是固定的,无论如何,谢谢;)。