Beispiel #1
0
        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);
                    }
                }
            }
        }
Beispiel #2
0
        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);
                    }
                }
            }
        }
Beispiel #3
0
        public static void UpdateUiForState(Operation validOperation, bool isVisible, bool isRunning, bool playerVisible)
        {
            try
            {
                _validOperation = validOperation;
                _isVisible      = isVisible;
                _isRunning      = isRunning;
                _playerVisible  = playerVisible;


                PlayerStateSendData playerState = new PlayerStateSendData(
                    validOperation,
                    isVisible,
                    isRunning,
                    MuteFm.SmartVolManagerPackage.BgMusicManager.ActiveBgMusic,
                    MuteFm.SmartVolManagerPackage.BgMusicManager.FgMusics,
                    SmartVolManagerPackage.BgMusicManager.BgMusicVolume,
                    SmartVolManagerPackage.BgMusicManager.BgMusicMuted,
                    SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic,
                    SmartVolManagerPackage.BgMusicManager.AutoMuted,
                    SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.AutoMuteEnabled,
                    SmartVolManagerPackage.BgMusicManager.ForegroundSoundPlaying,
                    SmartVolManagerPackage.BgMusicManager.MasterVol,
                    SmartVolManagerPackage.BgMusicManager.MasterMuted
                    );

                // Tray
                if (TrayLoaded)
                {
                    try
                    {
                        WinSoundServerSysTray.Instance.Invoke((System.Windows.Forms.MethodInvoker) delegate
                        {
                            if (WinSoundServerSysTray.Instance.Visible)
                            {
                                WinSoundServerSysTray.Instance.UpdateTrayMenu(validOperation, isVisible, isRunning, playerVisible);
                            }
                        });
                    }
                    catch (Exception ex)
                    {
                        MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                    }
                }


#if !NOAWE
                // BgMusicForm
                try
                {
                    if ((WebBgMusicForm != null) && (WebBgMusicForm.IsHandleCreated))
                    {
                        WebBgMusicForm.Invoke((System.Windows.Forms.MethodInvoker) delegate
                        {
                            if (WebBgMusicForm.Visible)
                            {
                                WebBgMusicForm.UpdateUiForState();
                            }
                        });
                    }
                }
                catch (Exception ex)
                {
                    MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                }
#endif

                // Mixer
                if ((mPlayerForm != null) && (mPlayerForm.IsHandleCreated))
                {
                    bool f  = mPlayerForm.InvokeRequired;
                    bool f2 = mPlayerForm.IsDisposed;

                    try
                    {
                        mPlayerForm.Invoke((System.Windows.Forms.MethodInvoker) delegate
                        {
                            UiCommands.mPlayerForm.UpdateUI(playerState);
                        });
                    }
                    catch (Exception ex)
                    {
                        MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                    }
                }


                // Web socket connections (not used anymore since mixer now uses native controls)
                //MixerWebSocketServerHelper.SendCommand("BGSTATE", playerState);
                //MixerWebSocketServerHelper.SendCommand("FGSTATE", playerState); // TODO: don't send full state for bg and fg and don't always call both
                // TODO: shouldn't always call this...
                //BgMusicFavoritesSendData favorites = new BgMusicFavoritesSendData(MuteApp.SmartVolManagerPackage.BgMusicManager.MuteTunesConfig.BgMusics, SmartVolManagerPackage.BgMusicManager.MuteTunesConfig.GeneralSettings.AutoMuteEnabled, SmartVolManagerPackage.BgMusicManager.ForegroundSoundPlaying);
                //MixerWebSocketServerHelper.SendCommand("FAVORITES", favorites);
            }
            catch (Exception ex)
            {
                MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
            }
        }
Beispiel #4
0
        public static void UpdateUiForState(Operation validOperation, bool isVisible, bool isRunning, bool playerVisible)
        {
            try
            {
                _validOperation = validOperation;
                _isVisible = isVisible;
                _isRunning = isRunning;
                _playerVisible = playerVisible;

                PlayerStateSendData playerState = new PlayerStateSendData(
                    validOperation,
                    isVisible,
                    isRunning,
                    MuteFm.SmartVolManagerPackage.BgMusicManager.ActiveBgMusic,
                    MuteFm.SmartVolManagerPackage.BgMusicManager.FgMusics,
                    SmartVolManagerPackage.BgMusicManager.BgMusicVolume,
                    SmartVolManagerPackage.BgMusicManager.BgMusicMuted,
                    SmartVolManagerPackage.BgMusicManager.UserWantsBgMusic,
                    SmartVolManagerPackage.BgMusicManager.AutoMuted,
                    SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GeneralSettings.AutoMuteEnabled,
                    SmartVolManagerPackage.BgMusicManager.ForegroundSoundPlaying,
                    SmartVolManagerPackage.BgMusicManager.MasterVol,
                    SmartVolManagerPackage.BgMusicManager.MasterMuted
                );

                // Tray
                if (TrayLoaded)
                {
                    try
                    {
                        WinSoundServerSysTray.Instance.Invoke((System.Windows.Forms.MethodInvoker)delegate
                        {
                            if (WinSoundServerSysTray.Instance.Visible)
                                WinSoundServerSysTray.Instance.UpdateTrayMenu(validOperation, isVisible, isRunning, playerVisible);
                        });
                    }
                    catch (Exception ex)
                    {
                        MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                    }
                }

            #if !NOAWE
                // BgMusicForm
                try
                {
                    if ((WebBgMusicForm != null) && (WebBgMusicForm.IsHandleCreated))
                    {
                        WebBgMusicForm.Invoke((System.Windows.Forms.MethodInvoker)delegate
                        {
                            if (WebBgMusicForm.Visible)
                                WebBgMusicForm.UpdateUiForState();
                        });
                    }
                }
                catch (Exception ex)
                {
                    MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                }
            #endif

                // Mixer
                if ((mPlayerForm != null) && (mPlayerForm.IsHandleCreated))
                {
                    bool f = mPlayerForm.InvokeRequired;
                    bool f2 = mPlayerForm.IsDisposed;

                    try
                    {
                        mPlayerForm.Invoke((System.Windows.Forms.MethodInvoker)delegate
                        {
                            UiCommands.mPlayerForm.UpdateUI(playerState);
                        });
                    }
                    catch (Exception ex)
                    {
                        MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
                    }
                }

                // Web socket connections (not used anymore since mixer now uses native controls)
                //MixerWebSocketServerHelper.SendCommand("BGSTATE", playerState);
                //MixerWebSocketServerHelper.SendCommand("FGSTATE", playerState); // TODO: don't send full state for bg and fg and don't always call both
                // TODO: shouldn't always call this...
                //BgMusicFavoritesSendData favorites = new BgMusicFavoritesSendData(MuteApp.SmartVolManagerPackage.BgMusicManager.MuteTunesConfig.BgMusics, SmartVolManagerPackage.BgMusicManager.MuteTunesConfig.GeneralSettings.AutoMuteEnabled, SmartVolManagerPackage.BgMusicManager.ForegroundSoundPlaying);
                //MixerWebSocketServerHelper.SendCommand("FAVORITES", favorites);
            }
            catch (Exception ex)
            {
                MuteFm.SmartVolManagerPackage.SoundEventLogger.LogException(ex);
            }
        }