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
        private void UpdateBgMusicUI()
        {
            SoundPlayerInfo playerInfo = SmartVolManagerPackage.BgMusicManager.MuteFmConfig.GetActiveBgMusic();

            mBackgroundMusicName.Text = playerInfo.Name;

            this.mBgMusicIcon.Image = MuteFmConfigUtil.GetImage(playerInfo.Id, 16);
        }
Beispiel #3
0
        private void reloadIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            WebServer.ClearOldEntries(DateTime.Now);

            for (int i = 0; i < SmartVolManagerPackage.BgMusicManager.MuteFmConfig.BgMusics.Length; i++)
            {
                MuteFmConfigUtil.GenerateIconImage(SmartVolManagerPackage.BgMusicManager.MuteFmConfig.BgMusics[i], false);
            }

            mBgMusicIcon.Image = MuteFmConfigUtil.GetImage(MuteFm.SmartVolManagerPackage.BgMusicManager.ActiveBgMusic.Id, 32);
        }
Beispiel #4
0
        public MusicInfoEditForm(SoundPlayerInfo playerInfo, bool editable)
        {
            InitializeComponent();
            this.Text = Constants.ProgramName + " - " + "Edit Sound Player Info";

#if NOAWE
            mWebsiteRadioButton.Text += " (Requires mute.fm+)";
#endif

            if (playerInfo == null)
            {
                this.Text  = Constants.ProgramName + " - Add Sound Info";
                _musicInfo = new SoundPlayerInfo();
#if !NOAWE
                _musicInfo.IsWeb            = true;
                mWebsiteRadioButton.Checked = true;
                mProgramRadioButton.Enabled = true;
                mWebsiteRadioButton.Enabled = true;
#else
                _musicInfo.IsWeb            = false;
                mWebsiteRadioButton.Enabled = false;
                mProgramRadioButton.Enabled = true;
                mProgramRadioButton.Checked = true;
                mWebsiteRadioButton_CheckedChanged_1(null, null);
#endif
                this.mIgnoreAutomuteCheckbox.Checked = false;
                this.mIgnoreAutomuteCheckbox.Visible = !_musicInfo.IsWeb;
                mStopIfMutedTooLongCheckbox.Checked  = true;

                _commands["OnLoad"]    = "";
                _commands["Play"]      = "";
                _commands["Pause"]     = "";
                _commands["PrevTrack"] = "";
                _commands["NextTrack"] = "";
                _commands["Like"]      = "";
                _commands["Dislike"]   = "";
                _commands["Stop"]      = "";
            }
            else
            {
                _musicInfo = playerInfo;
                mWebsiteRadioButton.Checked     = _musicInfo.IsWeb;
                mProgramRadioButton.Checked     = !_musicInfo.IsWeb;
                mIgnoreAutomuteCheckbox.Visible = !_musicInfo.IsWeb;
                mWebsiteRadioButton_CheckedChanged_1(null, null);

                bool ignoreForAutomute = false;
                SmartVolManagerPackage.BgMusicManager.IgnoreProcNameForAutomuteDict.TryGetValue(GetProcName(_musicInfo.UrlOrCommandLine), out ignoreForAutomute);
                this.mIgnoreAutomuteCheckbox.Checked = ignoreForAutomute;
                mStopIfMutedTooLongCheckbox.Checked  = playerInfo.KillAfterAutoMute;

                _commands["OnLoad"]    = _musicInfo.OnLoadCommand;
                _commands["Play"]      = _musicInfo.PlayCommand;
                _commands["Pause"]     = _musicInfo.PauseCommand;
                _commands["PrevTrack"] = _musicInfo.PrevSongCommand;
                _commands["NextTrack"] = _musicInfo.NextSongCommand;
                _commands["Like"]      = _musicInfo.LikeCommand;
                _commands["Dislike"]   = _musicInfo.DislikeCommand;
                _commands["Stop"]      = _musicInfo.StopCommand;

                mIcon.Image = MuteFmConfigUtil.GetImage(_musicInfo.Id, 16);
            }

            if (!editable)
            {
                foreach (Control control in this.Controls)
                {
                    if ((string)control.Tag != "+")
                    {
                        control.Enabled = false;
                    }
                }
            }
        }
Beispiel #5
0
        public void Init(MuteFmConfig muteTunesConfig, SoundPlayerInfo[] fgMusics)
        {
            TreeNode node;
            Object   currentTag = null;

            UpdateBgMusicUI();

            if (mSoundTree.SelectedNode != null)
            {
                currentTag = mSoundTree.SelectedNode.Tag;
            }


            ImageList imageList = new ImageList();

            mSoundTree.ImageList = imageList;
            TreeNode[] children = new TreeNode[0];

            imageList.Images.Add("0", UiCommands.mPlayerForm.Icon.ToBitmap());

            mSoundTree.Nodes.Clear();

            //TreeNode supportedWebNode = mSoundTree.Nodes.Add("Supported Web");
            _activeSoundsNode = new TreeNode("Recent Sounds", 0, 0, children);
            mSoundTree.Nodes.Add(_activeSoundsNode);
            _favoritesNode = new TreeNode("Favorites", 0, 0, children);
            mSoundTree.Nodes.Add(_favoritesNode);

            for (int i = 0; i < fgMusics.Length; i++)
            {
                string fgMusicName = fgMusics[i].ShortProcessName;
                if (fgMusicName.Trim() == "")
                {
                    fgMusicName = "System Sounds";
                }
                node = new TreeNode(fgMusicName, i + 1, i + 1, children);
                _activeSoundsNode.Nodes.Add(node);
                node.Tag = fgMusics[i].ShortProcessName;
                imageList.Images.Add((string)(node.Tag), MuteFmConfigUtil.GetImage(fgMusics[i].Id, 16));
                if ((string)node.Tag == (string)currentTag)
                {
                    mSoundTree.SelectedNode = node;
                }
            }

            int j = 0;

            for (int i = 0; i < muteTunesConfig.BgMusics.Length; i++)
            {
#if NOAWE
                // Don't show web-based music in the editor
                if (muteTunesConfig.BgMusics[i].IsWeb)
                {
                    continue;
                }
#endif

                node     = new TreeNode(muteTunesConfig.BgMusics[i].Name, j + 1 + fgMusics.Length, j + 1 + fgMusics.Length, children);
                node.Tag = muteTunesConfig.BgMusics[i].Id.ToString();
                _favoritesNode.Nodes.Add(node);
                Image image = MuteFmConfigUtil.GetImage(muteTunesConfig.BgMusics[i].Id, 16);
                if (image != null)
                {
                    imageList.Images.Add((string)(node.Tag), image);
                }

                if ((string)node.Tag == (string)currentTag)
                {
                    mSoundTree.SelectedNode = node;
                }
                j++;
            }
            _activeSoundsNode.ExpandAll();
            _favoritesNode.ExpandAll();
        }