[英]Setting the visibility for a ThumbnailToolBarButton
I've got a few ThumbnailToolBarButtons
on my window thumbnail. 我的窗口缩略图上有几个ThumbnailToolBarButtons
。 One is a play/pause button. 一个是播放/暂停按钮。 I've actually got two buttons for this ... one for play and one for pause. 实际上,我为此有两个按钮...一个用于播放,一个用于暂停。 When I click the button it will hide one and show the other using the ThumbnailToolBarButton
's Visible property. 当我单击按钮时,它将使用ThumbnailToolBarButton
的Visible属性隐藏一个,并显示另一个。 However, while the window thumbnail is up if I click the play/pause button the ThumbnailToolBarButtons
all get really wide and suddenly I only see two buttons. 但是,在窗口缩略图打开的情况下,如果单击“播放/暂停”按钮,则ThumbnailToolBarButtons
都会变宽,突然我只能看到两个按钮。 If I let the window thumbnail disappear and roll over it again all my buttons are back and the correct widths. 如果我让窗口缩略图消失并再次滚动,则所有我的按钮都将返回,并且宽度正确。 What is going on here? 这里发生了什么? Thanks. 谢谢。
Update: Ok. 更新:好的。 Here is some code as an example. 这是一些示例代码。
private ThumbnailToolBarButton buttonPrevious;
private ThumbnailToolBarButton buttonNext;
private ThumbnailToolBarButton buttonPlay;
private ThumbnailToolBarButton buttonPause;
private Boolean bPlaying = false;
private void Form1_Load(object sender, EventArgs e)
{
buttonPrevious = new ThumbnailToolBarButton(Properties.Resources.previous, "Previous");
buttonPrevious.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPrevious_Click);
buttonPrevious.Visible = true;
buttonNext = new ThumbnailToolBarButton(Properties.Resources.next, "Next");
buttonNext.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonNext_Click);
buttonNext.Visible = true;
buttonPlay = new ThumbnailToolBarButton(Properties.Resources.play, "Pause/Pause");
buttonPlay.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPlay_Click);
buttonPlay.Visible = true;
buttonPause = new ThumbnailToolBarButton(Properties.Resources.pause, "Play");
buttonPause.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(buttonPlay_Click);
buttonPause.Visible = false;
TaskbarManager.Instance.ThumbnailToolBars.AddButtons(this.Handle, buttonPrevious, buttonPlay, buttonPause, buttonNext);
}
private void buttonPlay_Click(object sender, ThumbnailButtonClickedEventArgs e)
{
bPlaying = !bPlaying;
buttonPlay.Visible = bPlaying ? false : true;
buttonPause.Visible = bPlaying ? true : false;
}
Try uniting the play/pause buttons into one button, and in the click event handler write: 尝试将播放/暂停按钮组合为一个按钮,然后在click事件处理程序中编写:
if ( buttonPlayPause.Icon == Properties.Resources.play )
buttonPlayPause.Icon = Properties.Resources.pause;
else
buttonPlayPause.Icon = Properties.Resources.play;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.