コード例 #1
0
ファイル: MusicConfigForm.cs プロジェクト: jlami/mutefm
        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();
        }
コード例 #2
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();
        }