public void UpdateUI(PlayerStateSendData playerState) { mMuteDuringVideosCheckbox.Checked = playerState.AutoMutingEnabled; mBgMusicNameLabel.Text = playerState.ActiveBgMusicTitle; //mMusicInfoLabel.Text = playerState.TrackName; _toolStripItemDict["play"].Visible = playerState.AllowPlay; _toolStripItemDict["like"].Visible = playerState.AllowLike; _toolStripItemDict["dislike"].Visible = playerState.AllowDislike; _toolStripItemDict["mute"].Visible = playerState.AllowMute; _toolStripItemDict["unmute"].Visible = playerState.AllowUnmute; _toolStripItemDict["stop"].Visible = playerState.AllowStop; _toolStripItemDict["pause"].Visible = playerState.AllowPause; _toolStripItemDict["nexttrack"].Visible = playerState.AllowNextTrack; _toolStripItemDict["prevtrack"].Visible = playerState.AllowPrevTrack; mBgMusicIcon.Image = MuteFmConfigUtil.GetImage(playerState.ActiveBgMusicId, 32); for (int i = 0; i < playerState.fgMusicTitles.Length; i++) { FgMusicInfoControl fgMusicControl; bool muted = (bool)playerState.fgMusicIsMuteds.GetValue(i); bool ignored = (bool)playerState.fgMusicIgnores.GetValue(i); long musicId = (long)playerState.fgMusicIds.GetValue(i); string name = (string)playerState.fgMusicTitles.GetValue(i); if (_fgControlDict.TryGetValue(musicId, out fgMusicControl)) { fgMusicControl.UpdateUI(name, muted, ignored); } else { fgMusicControl = FgMusicInfoControl.CreateFgMusicInfoControl(musicId, name, muted, ignored); mFgMusicSoundsGroupBox.Controls.Add(fgMusicControl); _fgControlDict[musicId] = fgMusicControl; } } // Remove controls that aren't active for (int i = mFgMusicSoundsGroupBox.Controls.Count - 1; i >= 0; i--) { if (mFgMusicSoundsGroupBox.Controls[i] is FgMusicInfoControl) { long musicId = ((FgMusicInfoControl)(mFgMusicSoundsGroupBox.Controls[i])).MusicId; bool found = false; for (int j = 0; j < playerState.fgMusicTitles.Length; j++) { if ((long)playerState.fgMusicIds.GetValue(j) == musicId) { found = true; break; } } if (!found) { mFgMusicSoundsGroupBox.Controls.RemoveAt(i); } } } }
public static FgMusicInfoControl CreateFgMusicInfoControl(long musicId, string name, bool muted, bool ignored) { FgMusicInfoControl fgMusicControl = new FgMusicInfoControl(); fgMusicControl.Dock = DockStyle.Top; fgMusicControl._musicId = musicId; fgMusicControl.mFgMusicIcon.Cursor = System.Windows.Forms.Cursors.Hand; fgMusicControl.addToolStripItem("mute", new EventHandler(fgMusicControl.mMuteButton_Click)); fgMusicControl.addToolStripItem("unmute", new EventHandler(fgMusicControl.mUnmuteButton_Click)); fgMusicControl.addToolStripItem("check", new EventHandler(fgMusicControl.mCheckButton_Click)); fgMusicControl.addToolStripItem("uncheck", new EventHandler(fgMusicControl.mUncheckButton_Click)); fgMusicControl.UpdateUI(name, muted, ignored); fgMusicControl.mFgMusicToolStrip.Renderer = new CleanToolStripRenderer(); return fgMusicControl; }
public static FgMusicInfoControl CreateFgMusicInfoControl(long musicId, string name, bool muted, bool ignored) { FgMusicInfoControl fgMusicControl = new FgMusicInfoControl(); fgMusicControl.Dock = DockStyle.Top; fgMusicControl._musicId = musicId; fgMusicControl.mFgMusicIcon.Cursor = System.Windows.Forms.Cursors.Hand; fgMusicControl.addToolStripItem("mute", new EventHandler(fgMusicControl.mMuteButton_Click)); fgMusicControl.addToolStripItem("unmute", new EventHandler(fgMusicControl.mUnmuteButton_Click)); fgMusicControl.addToolStripItem("check", new EventHandler(fgMusicControl.mCheckButton_Click)); fgMusicControl.addToolStripItem("uncheck", new EventHandler(fgMusicControl.mUncheckButton_Click)); fgMusicControl.UpdateUI(name, muted, ignored); fgMusicControl.mFgMusicToolStrip.Renderer = new CleanToolStripRenderer(); return(fgMusicControl); }